Class DoubleSpliterators.LateBindingSizeIndexBasedSpliterator
- All Implemented Interfaces:
it.unimi.dsi.fastutil.doubles.DoubleSpliterator,Spliterator<Double>,Spliterator.OfDouble,Spliterator.OfPrimitive<Double,DoubleConsumer, Spliterator.OfDouble>
- Enclosing class:
DoubleSpliterators
This class implements a late binding strategy. On a new, non-split instance, the
max pos will track the given data store (usually it's
size, hence the class' name). On the first
split, the last index will be read from the backing data store one
last time and then be fixed for the remaining duration of this instance.
The returned split should should also be have a constant maxPos.
As the abstract methods in this class are used in inner loops, it is generally a
good idea to override the class as final as to encourage the JVM to inline
them (or alternatively, override the abstract methods as final).
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T,T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe maximumDoubleSpliterators.AbstractIndexBasedSpliterator.poscan be, or -1 if it hasn't been fixed yet.Fields inherited from class it.unimi.dsi.fastutil.doubles.DoubleSpliterators.AbstractIndexBasedSpliterator
posFields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLateBindingSizeIndexBasedSpliterator(int initialPos) protectedLateBindingSizeIndexBasedSpliterator(int initialPos, int fixedMaxPos) -
Method Summary
Modifier and TypeMethodDescriptionprotected final intThe maximum pos can be, and is the logical end (exclusive) of the "range".protected abstract intReturn the maximum pos can be dynamically tracking the backing data store.it.unimi.dsi.fastutil.doubles.DoubleSpliteratortrySplit()Methods inherited from class it.unimi.dsi.fastutil.doubles.DoubleSpliterators.AbstractIndexBasedSpliterator
characteristics, computeSplitPoint, estimateSize, forEachRemaining, get, makeForSplit, skip, tryAdvanceMethods inherited from class it.unimi.dsi.fastutil.doubles.AbstractDoubleSpliterator
forEachRemaining, tryAdvanceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface it.unimi.dsi.fastutil.doubles.DoubleSpliterator
forEachRemaining, getComparator, tryAdvanceMethods inherited from interface java.util.Spliterator
getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
maxPos
protected int maxPosThe maximumDoubleSpliterators.AbstractIndexBasedSpliterator.poscan be, or -1 if it hasn't been fixed yet.
-
-
Constructor Details
-
LateBindingSizeIndexBasedSpliterator
protected LateBindingSizeIndexBasedSpliterator(int initialPos) -
LateBindingSizeIndexBasedSpliterator
protected LateBindingSizeIndexBasedSpliterator(int initialPos, int fixedMaxPos)
-
-
Method Details
-
getMaxPosFromBackingStore
protected abstract int getMaxPosFromBackingStore()Return the maximum pos can be dynamically tracking the backing data store.This method will be the return value of
getMaxPos()until this spliterator is trySplit() split, in which case its final return value will be saved and remain constant for the rest of the duration of this instance. -
getMaxPos
protected final int getMaxPos()Description copied from class:DoubleSpliterators.AbstractIndexBasedSpliteratorThe maximum pos can be, and is the logical end (exclusive) of the "range".If pos is equal to the return of this method, this means the last element has been returned and the next call to
DoubleSpliterators.AbstractIndexBasedSpliterator.tryAdvance(java.util.function.DoubleConsumer)will returnfalse.Usually set return the parent collection's size, but does not have to be (for example, sublists and subranges).
This method allows the implementation to decide how it binds on the size (late or early). However,
DoubleSpliterators.EarlyBindingSizeIndexBasedSpliteratorandDoubleSpliterators.LateBindingSizeIndexBasedSpliteratorgive an implementation of this method for the two most common strategies.- Specified by:
getMaxPosin classDoubleSpliterators.AbstractIndexBasedSpliterator
-
trySplit
public it.unimi.dsi.fastutil.doubles.DoubleSpliterator trySplit()Description copied from class:DoubleSpliterators.AbstractIndexBasedSpliterator- Specified by:
trySplitin interfaceit.unimi.dsi.fastutil.doubles.DoubleSpliterator- Specified by:
trySplitin interfaceSpliterator<Double>- Specified by:
trySplitin interfaceSpliterator.OfDouble- Specified by:
trySplitin interfaceSpliterator.OfPrimitive<Double,DoubleConsumer, Spliterator.OfDouble> - Overrides:
trySplitin classDoubleSpliterators.AbstractIndexBasedSpliterator
-