Class SeqBuffer.BufferSpliterator
java.lang.Object
org.jooq.lambda.SeqBuffer.BufferSpliterator
- All Implemented Interfaces:
Spliterator<T>
Special
Spliterator whose tryAdvance method can buffer
(i.e. can advance the source spliterator).
Instances of this class are NOT thread-safe but they interact in a thread-safe way with SeqBuffer.-
Nested Class Summary
Nested classes/interfaces inherited from interface Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T,T_CONS, T_SPLITR> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intIndex of the element that will be returned upon next call totryAdvanceif such element exists.Fields inherited from interface Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Tprivate booleanprivate booleanintlongprivate longReturns the estimate size of this Spliterator.Comparator<? super T> private intbooleantryAdvance(Consumer<? super T> action) private booleanBuffers (i.e.private booleantryAdvanceThisAtOnce(Consumer<? super T> action) Called only when buffering has been completed.private booleantryAdvanceThisWithBuffering(Consumer<? super T> action) Tries to advance thisSpliteratorto element atnextIndex, bufferingsourceelements intobufferif necessary.trySplit()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Spliterator
forEachRemaining, getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
nextIndex
private int nextIndexIndex of the element that will be returned upon next call totryAdvanceif such element exists.
-
-
Constructor Details
-
BufferSpliterator
private BufferSpliterator()
-
-
Method Details
-
tryAdvance
- Specified by:
tryAdvancein interfaceSpliterator<T>
-
tryAdvanceThisWithBuffering
Tries to advance thisSpliteratorto element atnextIndex, bufferingsourceelements intobufferif necessary. Synchronized onbufferin order to: - obtain accuratebuffer.size()- safely copy fromsourcetobuffer(if needed) - safely callbuffer.get() -
canAdvanceThisWithBuffering
private boolean canAdvanceThisWithBuffering() -
canAdvanceThisAtOnce
private boolean canAdvanceThisAtOnce() -
tryAdvanceSource
private boolean tryAdvanceSource()Buffers (i.e. advances thesource) until an item atnextIndexis added to thebuffer, or until thesourceis exhausted. Guarded by:buffer -
advanceThis
-
tryAdvanceThisAtOnce
-
estimateSize
public long estimateSize()- Specified by:
estimateSizein interfaceSpliterator<T>
-
estimateSizeDuringBuffering
private long estimateSizeDuringBuffering()Returns the estimate size of this Spliterator. Synchronized to get an accurate sum ofbuffer.size()andsource.estimateSize(). -
numberOfElementsLeftInBuffer
private int numberOfElementsLeftInBuffer() -
trySplit
- Specified by:
trySplitin interfaceSpliterator<T>
-
characteristics
public int characteristics()- Specified by:
characteristicsin interfaceSpliterator<T>
-
getComparator
- Specified by:
getComparatorin interfaceSpliterator<T>
-
parentSeqBuffer
-