public class IntervalIterator extends AbstractInterval implements Iterator, Localizable
Interval in flat order, that is:
row by row, plane by plane, cube by cube, ... This is useful for iterating an
arbitrary interval in a defined order. For that, connect an
IntervalIterator to a Positionable.
...
IntervalIterator i = new IntervalIterator(image);
RandomAccess<T> s = image.randomAccess();
while (i.hasNext()) {
i.fwd();
s.setPosition(i);
s.get().performOperation(...);
...
}
...
Note that IntervalIterator is the right choice in situations where
not for each pixel you want to localize and/or set the
Positionable [Sampler], that is in a sparse sampling
situation. For localizing at each iteration step (as in the simplified
example above), use LocalizingIntervalIterator instead.| Modifier and Type | Field and Description |
|---|---|
protected long[] |
dimensions |
protected long |
index |
protected long |
lastIndex |
protected long[] |
steps |
max, minn| Constructor and Description |
|---|
IntervalIterator(int[] dimensions)
Iterates an
Interval of the given dimensions with min=
0n |
IntervalIterator(int[] min,
int[] max)
Iterates an
Interval with given min and max. |
IntervalIterator(Interval interval)
Iterates a given
Interval. |
IntervalIterator(long[] dimensions)
Iterates an
Interval of the given dimensions with min=
0n |
IntervalIterator(long[] min,
long[] max)
Iterates an
Interval with given min and max. |
| Modifier and Type | Method and Description |
|---|---|
static IntervalIterator |
create(Interval interval) |
long |
dimension(int d)
Default implementation of
Dimensions.dimension(int). |
void |
dimensions(long[] dim)
Write the number of pixels in each dimension into long[].
|
void |
fwd()
Move forward.
|
double |
getDoublePosition(int dim)
Return the current position in a given dimension.
|
float |
getFloatPosition(int dim)
Return the current position in a given dimension.
|
long |
getIndex() |
int |
getIntPosition(int dim)
Return the current position in a given dimension.
|
long |
getLongPosition(int dim)
Return the current position in a given dimension.
|
boolean |
hasNext()
Returns true if another step forward is possible.
|
void |
jumpFwd(long i)
Move steps × forward.
|
void |
localize(double[] position)
Write the current position into the passed array.
|
void |
localize(float[] position)
Write the current position into the passed array.
|
void |
localize(int[] position)
Write the current position into the passed array.
|
void |
localize(long[] position)
Write the current position into the passed array.
|
void |
reset()
Reset the
Iterator, that is put it to where it would be if newly
created. |
String |
toString() |
max, max, max, min, min, min, realMax, realMax, realMax, realMin, realMin, realMinnumDimensionsclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitlocalize, positionAsLongArray, positionAsPointlocalize, positionAsDoubleArray, positionAsRealPointnumDimensionsmaxAsLongArray, maxAsPoint, minAsLongArray, minAsPointmaxAsDoubleArray, maxAsRealPoint, minAsDoubleArray, minAsRealPointallPositive, allPositive, dimensions, dimensionsAsLongArray, dimensionsAsPoint, verify, verify, verifyAllPositive, verifyAllPositiveprotected final long[] dimensions
protected final long[] steps
protected final long lastIndex
protected long index
public IntervalIterator(long[] dimensions)
Interval of the given dimensions with min=
0ndimensions - public IntervalIterator(int[] dimensions)
Interval of the given dimensions with min=
0ndimensions - public IntervalIterator(long[] min,
long[] max)
Interval with given min and max.min - max - public IntervalIterator(int[] min,
int[] max)
Interval with given min and max.min - max - public static IntervalIterator create(Interval interval)
public void jumpFwd(long i)
Iteratorpublic void fwd()
Iteratorpublic void reset()
IteratorIterator, that is put it to where it would be if newly
created.public boolean hasNext()
Iteratorpublic long getIndex()
public long getLongPosition(int dim)
LocalizablegetLongPosition in interface Localizabledim - dimensionpublic void localize(long[] position)
Localizablelocalize in interface Localizableposition - receives current positionpublic int getIntPosition(int dim)
LocalizablegetIntPosition in interface Localizabledim - dimensionpublic void localize(int[] position)
Localizablelocalize in interface Localizableposition - receives current positionpublic double getDoublePosition(int dim)
RealLocalizablegetDoublePosition in interface LocalizablegetDoublePosition in interface RealLocalizabledim - dimensionpublic float getFloatPosition(int dim)
RealLocalizablegetFloatPosition in interface LocalizablegetFloatPosition in interface RealLocalizabledim - dimensionpublic void localize(float[] position)
RealLocalizablelocalize in interface RealLocalizableposition - receives current positionpublic void localize(double[] position)
RealLocalizablelocalize in interface RealLocalizableposition - receives current positionpublic String toString()
toString in class AbstractIntervalpublic long dimension(int d)
IntervalDimensions.dimension(int).dimension in interface Dimensionsdimension in interface Intervaldimension in class AbstractIntervalpublic void dimensions(long[] dim)
Dimensionsdimensions in interface Dimensionsdimensions in class AbstractIntervalCopyright © 2015–2022 ImgLib2. All rights reserved.