public abstract static class LongBigSpliterators.LateBindingSizeIndexBasedSpliterator extends LongBigSpliterators.AbstractIndexBasedSpliterator
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).
| Modifier and Type | Field and Description |
|---|---|
protected long |
maxPos
The maximum
LongBigSpliterators.AbstractIndexBasedSpliterator.pos can be, or -1 if it hasn't been fixed yet. |
pos| Modifier | Constructor and Description |
|---|---|
protected |
LateBindingSizeIndexBasedSpliterator(long initialPos) |
protected |
LateBindingSizeIndexBasedSpliterator(long initialPos,
long fixedMaxPos) |
| Modifier and Type | Method and Description |
|---|---|
protected long |
getMaxPos()
The maximum pos can be, and is the logical end (exclusive) of the "range".
|
protected abstract long |
getMaxPosFromBackingStore()
Return the maximum pos can be dynamically tracking the backing data store.
|
it.unimi.dsi.fastutil.longs.LongSpliterator |
trySplit() |
characteristics, computeSplitPoint, estimateSize, forEachRemaining, get, makeForSplit, skip, tryAdvanceforEachRemaining, tryAdvanceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprotected long maxPos
LongBigSpliterators.AbstractIndexBasedSpliterator.pos can be, or -1 if it hasn't been fixed yet.protected LateBindingSizeIndexBasedSpliterator(long initialPos)
protected LateBindingSizeIndexBasedSpliterator(long initialPos,
long fixedMaxPos)
protected abstract long getMaxPosFromBackingStore()
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.
protected final long getMaxPos()
LongBigSpliterators.AbstractIndexBasedSpliteratorIf pos is equal to the return of this method, this means the last element has been returned and the next call to LongBigSpliterators.AbstractIndexBasedSpliterator.tryAdvance(java.util.function.LongConsumer) 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, LongBigSpliterators.EarlyBindingSizeIndexBasedSpliterator and LongBigSpliterators.LateBindingSizeIndexBasedSpliterator give
an implementation of this method for the two most common strategies.
getMaxPos in class LongBigSpliterators.AbstractIndexBasedSpliteratorpublic it.unimi.dsi.fastutil.longs.LongSpliterator trySplit()
LongBigSpliterators.AbstractIndexBasedSpliteratortrySplit in interface it.unimi.dsi.fastutil.longs.LongSpliteratortrySplit in interface java.util.Spliterator<java.lang.Long>trySplit in interface java.util.Spliterator.OfLongtrySplit in interface java.util.Spliterator.OfPrimitive<java.lang.Long,java.util.function.LongConsumer,java.util.Spliterator.OfLong>trySplit in class LongBigSpliterators.AbstractIndexBasedSpliterator