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 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 TypeFieldDescriptionprivate int
Index of the element that will be returned upon next call totryAdvance
if such element exists.Fields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate T
private boolean
private boolean
int
long
private long
Returns the estimate size of this Spliterator.Comparator
<? super T> private int
boolean
tryAdvance
(Consumer<? super T> action) private boolean
Buffers (i.e.private boolean
tryAdvanceThisAtOnce
(Consumer<? super T> action) Called only when buffering has been completed.private boolean
tryAdvanceThisWithBuffering
(Consumer<? super T> action) Tries to advance thisSpliterator
to element atnextIndex
, bufferingsource
elements intobuffer
if necessary.trySplit()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Spliterator
forEachRemaining, getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
nextIndex
private int nextIndexIndex of the element that will be returned upon next call totryAdvance
if such element exists.
-
-
Constructor Details
-
BufferSpliterator
private BufferSpliterator()
-
-
Method Details
-
tryAdvance
- Specified by:
tryAdvance
in interfaceSpliterator<T>
-
tryAdvanceThisWithBuffering
Tries to advance thisSpliterator
to element atnextIndex
, bufferingsource
elements intobuffer
if necessary. Synchronized onbuffer
in order to: - obtain accuratebuffer.size()
- safely copy fromsource
tobuffer
(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 atnextIndex
is added to thebuffer
, or until thesource
is exhausted. Guarded by:buffer
-
advanceThis
-
tryAdvanceThisAtOnce
Called only when buffering has been completed. -
estimateSize
public long estimateSize()- Specified by:
estimateSize
in 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:
trySplit
in interfaceSpliterator<T>
-
characteristics
public int characteristics()- Specified by:
characteristics
in interfaceSpliterator<T>
-
getComparator
- Specified by:
getComparator
in interfaceSpliterator<T>
-
parentSeqBuffer
-