public abstract static class ObjectSpliterators.EarlyBindingSizeIndexBasedSpliterator<K> extends ObjectSpliterators.AbstractIndexBasedSpliterator<K>
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).
| Modifier and Type | Field and Description |
|---|---|
protected int |
maxPos
The maximum
ObjectSpliterators.AbstractIndexBasedSpliterator.pos can be |
pos| Modifier | Constructor and Description |
|---|---|
protected |
EarlyBindingSizeIndexBasedSpliterator(int initialPos,
int maxPos) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
getMaxPos()
The maximum pos can be, and is the logical end (exclusive) of the "range".
|
characteristics, computeSplitPoint, estimateSize, forEachRemaining, get, makeForSplit, skip, tryAdvance, trySplitprotected final int maxPos
ObjectSpliterators.AbstractIndexBasedSpliterator.pos can beprotected EarlyBindingSizeIndexBasedSpliterator(int initialPos,
int maxPos)
protected final int getMaxPos()
ObjectSpliterators.AbstractIndexBasedSpliteratorIf 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 return false.
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.EarlyBindingSizeIndexBasedSpliterator and ObjectSpliterators.LateBindingSizeIndexBasedSpliterator give
an implementation of this method for the two most common strategies.
getMaxPos in class ObjectSpliterators.AbstractIndexBasedSpliterator<K>