Class ObjectSpliterators.EarlyBindingSizeIndexBasedSpliterator<K>
- All Implemented Interfaces:
it.unimi.dsi.fastutil.objects.ObjectSpliterator<K>,Spliterator<K>
- Enclosing class:
ObjectSpliterators
This class implements an early binding strategy for getMaxPos(). The last index
this spliterator covers is fixed at construction time and does not vary on changes to the
backing data store. This should usually be the size of the
backing data store (until a split at least), hence the class' name, but this is not required.
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 final intThe maximumObjectSpliterators.AbstractIndexBasedSpliterator.poscan beFields inherited from class it.unimi.dsi.fastutil.objects.ObjectSpliterators.AbstractIndexBasedSpliterator
posFields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEarlyBindingSizeIndexBasedSpliterator(int initialPos, int maxPos) -
Method Summary
Modifier and TypeMethodDescriptionprotected final intThe maximum pos can be, and is the logical end (exclusive) of the "range".Methods inherited from class it.unimi.dsi.fastutil.objects.ObjectSpliterators.AbstractIndexBasedSpliterator
characteristics, computeSplitPoint, estimateSize, forEachRemaining, get, makeForSplit, skip, tryAdvance, trySplitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Spliterator
getComparator, getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
maxPos
protected final int maxPosThe maximumObjectSpliterators.AbstractIndexBasedSpliterator.poscan be
-
-
Constructor Details
-
EarlyBindingSizeIndexBasedSpliterator
protected EarlyBindingSizeIndexBasedSpliterator(int initialPos, int maxPos)
-
-
Method Details
-
getMaxPos
protected final int getMaxPos()Description copied from class:ObjectSpliterators.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
ObjectSpliterators.AbstractIndexBasedSpliterator.tryAdvance(java.util.function.Consumer<? super K>)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,
ObjectSpliterators.EarlyBindingSizeIndexBasedSpliteratorandObjectSpliterators.LateBindingSizeIndexBasedSpliteratorgive an implementation of this method for the two most common strategies.- Specified by:
getMaxPosin classObjectSpliterators.AbstractIndexBasedSpliterator<K>
-