Package net.imglib2.stream
Class CursorSpliterator<T>
- java.lang.Object
-
- net.imglib2.stream.CursorSpliterator<T>
-
- Type Parameters:
T- the type of elements returned by this Spliterator, and the pixel type of the underlying cursor.
- All Implemented Interfaces:
java.util.Spliterator<T>,EuclideanSpace,Localizable,RealLocalizable,Sampler<T>,LocalizableSpliterator<T>,RealLocalizableSpliterator<T>,Typed<T>
public class CursorSpliterator<T> extends java.lang.Object implements LocalizableSpliterator<T>
Spliterator implementation on top ofRealCursor.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface java.util.Spliterator
java.util.Spliterator.OfDouble, java.util.Spliterator.OfInt, java.util.Spliterator.OfLong, java.util.Spliterator.OfPrimitive<T extends java.lang.Object,T_CONS extends java.lang.Object,T_SPLITR extends java.util.Spliterator.OfPrimitive<T,T_CONS,T_SPLITR>>
-
-
Field Summary
Fields Modifier and Type Field Description private intcharacteristicsCharacteristics always includeSIZED | SUBSIZED.private Cursor<T>cursorThe underlying cursor, positioned such thatcursor.next()yields the element atindex.private longfenceOne past last indexprivate longindexThe current index, modified on advance/split.
-
Constructor Summary
Constructors Constructor Description CursorSpliterator(Cursor<T> cursor, long origin, long fence, int additionalCharacteristics)Creates a spliterator covering the given range.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcharacteristics()CursorSpliterator<T>copy()longestimateSize()Tget()Access the actual T instance providing access to a pixel, sub-pixel or integral region value theSamplerpoints at.doublegetDoublePosition(int d)Return the current position in a given dimension.floatgetFloatPosition(int d)Return the current position in a given dimension.intgetIntPosition(int d)Return the current position in a given dimension.longgetLongPosition(int d)Return the current position in a given dimension.TgetType()Get an instance ofT.voidlocalize(double[] position)Write the current position into the passed array.voidlocalize(float[] position)Write the current position into the passed array.voidlocalize(int[] position)Write the current position into the passed array.voidlocalize(long[] position)Write the current position into the passed array.voidlocalize(Positionable position)Write the current position into the passedPositionable.voidlocalize(RealPositionable position)Write the current position into the passedPositionable.intnumDimensions()Gets the space's number of dimensions.double[]positionAsDoubleArray()Allocate and return a double array with the position.long[]positionAsLongArray()Allocate and return a long array containing the localizable's position.PointpositionAsPoint()Allocate and return aPointcontaining the localizable's position.RealPointpositionAsRealPoint()Allocate and return aRealPointwith the current position.booleantryAdvance(java.util.function.Consumer<? super T> action)CursorSpliterator<T>trySplit()
-
-
-
Field Detail
-
cursor
private final Cursor<T> cursor
The underlying cursor, positioned such thatcursor.next()yields the element atindex.
-
index
private long index
The current index, modified on advance/split.
-
fence
private final long fence
One past last index
-
characteristics
private final int characteristics
Characteristics always includeSIZED | SUBSIZED.
-
-
Constructor Detail
-
CursorSpliterator
public CursorSpliterator(Cursor<T> cursor, long origin, long fence, int additionalCharacteristics)
Creates a spliterator covering the given range.- Parameters:
cursor- provides elements, starting with the element at origin, on cursor.next()origin- the least index (inclusive) to coverfence- one past the greatest index to coveradditionalCharacteristics- additional characteristics besidesSIZED | SUBSIZED
-
-
Method Detail
-
tryAdvance
public boolean tryAdvance(java.util.function.Consumer<? super T> action)
- Specified by:
tryAdvancein interfacejava.util.Spliterator<T>
-
trySplit
public CursorSpliterator<T> trySplit()
- Specified by:
trySplitin interfaceLocalizableSpliterator<T>- Specified by:
trySplitin interfaceRealLocalizableSpliterator<T>- Specified by:
trySplitin interfacejava.util.Spliterator<T>
-
estimateSize
public long estimateSize()
- Specified by:
estimateSizein interfacejava.util.Spliterator<T>
-
characteristics
public int characteristics()
- Specified by:
characteristicsin interfacejava.util.Spliterator<T>
-
get
public T get()
Description copied from interface:SamplerAccess the actual T instance providing access to a pixel, sub-pixel or integral region value theSamplerpoints at.
-
getType
public T getType()
Description copied from interface:TypedGet an instance ofT.It should not be assumed that the returned
Tinstance is an independent copy. In particular, repeated calls togetType()may return the same instance.
-
copy
public CursorSpliterator<T> copy()
- Specified by:
copyin interfaceLocalizableSpliterator<T>- Specified by:
copyin interfaceRealLocalizableSpliterator<T>- Specified by:
copyin interfaceSampler<T>- Returns:
- - A new
Samplerin the same state accessing the same values. It does NOT copy T, just the state of theSampler. Otherwise use T.copy() if available. Sampler.copy().get() == Sampler.get(), i.e. both hold the same value, not necessarily the same instance (this is the case for anArrayCursorfor example)
-
numDimensions
public int numDimensions()
Description copied from interface:EuclideanSpaceGets the space's number of dimensions.- Specified by:
numDimensionsin interfaceEuclideanSpace
-
localize
public void localize(float[] position)
Description copied from interface:RealLocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceRealLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
localize
public void localize(double[] position)
Description copied from interface:RealLocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceRealLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
localize
public void localize(RealPositionable position)
Description copied from interface:RealLocalizableWrite the current position into the passedPositionable. Note for developers: This default implementation forwards toRealPositionable.setPosition(RealLocalizable), so don't do the same there.- Specified by:
localizein interfaceLocalizable- Specified by:
localizein interfaceRealLocalizable- Parameters:
position- receives current positionEuclideanSpace.numDimensions()must be ≥EuclideanSpace.numDimensions()
-
positionAsDoubleArray
public double[] positionAsDoubleArray()
Description copied from interface:RealLocalizableAllocate and return a double array with the position. Please note that his method allocates a new array each time which introduces notable overhead in both compute and memory. If you query it frequently, you should allocate a dedicated array first and reuse it withRealLocalizable.localize(double[]).- Specified by:
positionAsDoubleArrayin interfaceRealLocalizable- Returns:
- the position
-
positionAsRealPoint
public RealPoint positionAsRealPoint()
Description copied from interface:RealLocalizableAllocate and return aRealPointwith the current position. Please note that his method allocates a newRealPointeach time which introduces notable overhead in both compute and memory. If you query it frequently, you should allocate a dedicatedRealPointfirst and reuse it withRealLocalizable.localize(RealPositionable).- Specified by:
positionAsRealPointin interfaceRealLocalizable- Returns:
- the position
-
getFloatPosition
public float getFloatPosition(int d)
Description copied from interface:RealLocalizableReturn the current position in a given dimension.- Specified by:
getFloatPositionin interfaceLocalizable- Specified by:
getFloatPositionin interfaceRealLocalizable- Parameters:
d- dimension- Returns:
- dimension of current position
-
getDoublePosition
public double getDoublePosition(int d)
Description copied from interface:RealLocalizableReturn the current position in a given dimension.- Specified by:
getDoublePositionin interfaceLocalizable- Specified by:
getDoublePositionin interfaceRealLocalizable- Parameters:
d- dimension- Returns:
- dimension of current position
-
localize
public void localize(int[] position)
Description copied from interface:LocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
localize
public void localize(long[] position)
Description copied from interface:LocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
localize
public void localize(Positionable position)
Description copied from interface:LocalizableWrite the current position into the passedPositionable. Note for developers: This default implementation forwards toPositionable.setPosition(Localizable), so don't do the same there.- Specified by:
localizein interfaceLocalizable- Parameters:
position- receives current position,EuclideanSpace.numDimensions()must be ≥EuclideanSpace.numDimensions()
-
getIntPosition
public int getIntPosition(int d)
Description copied from interface:LocalizableReturn the current position in a given dimension.- Specified by:
getIntPositionin interfaceLocalizable- Parameters:
d- dimension- Returns:
- dimension of current position
-
positionAsLongArray
public long[] positionAsLongArray()
Description copied from interface:LocalizableAllocate and return a long array containing the localizable's position. Please note that his method allocates a new array each time which introduces notable overhead in both compute and memory. If you query it frequently, you should allocate a dedicated array first and reuse it withLocalizable.localize(long[]).- Specified by:
positionAsLongArrayin interfaceLocalizable- Returns:
- the position
-
positionAsPoint
public Point positionAsPoint()
Description copied from interface:LocalizableAllocate and return aPointcontaining the localizable's position. Please note that his method allocates a newPointeach time which introduces notable overhead in both compute and memory. If you query it frequently, you should allocate a dedicatedPointfirst and reuse it withLocalizable.localize(Positionable).- Specified by:
positionAsPointin interfaceLocalizable- Returns:
- the position
-
getLongPosition
public long getLongPosition(int d)
Description copied from interface:LocalizableReturn the current position in a given dimension.- Specified by:
getLongPositionin interfaceLocalizable- Parameters:
d- dimension- Returns:
- dimension of current position
-
-