- java.lang.Object
-
- org.jooq.lambda.SeqBuffer.BufferSpliterator
-
- All Implemented Interfaces:
java.util.Spliterator<T>
private class SeqBuffer.BufferSpliterator extends java.lang.Object implements java.util.Spliterator<T>
SpecialSpliterator
whosetryAdvance
method can buffer (i.e. can advance thesource
spliterator). Instances of this class are NOT thread-safe but they interact in a thread-safe way withSeqBuffer
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface java.util.Spliterator
java.util.Spliterator.OfDouble, java.util.Spliterator.OfInt, java.util.Spliterator.OfLong, java.util.Spliterator.OfPrimitive<T extends java.lang.Object,T_CONS extends java.lang.Object,T_SPLITR extends java.util.Spliterator.OfPrimitive<T,T_CONS,T_SPLITR>>
-
-
Field Summary
Fields Modifier and Type Field Description private int
nextIndex
Index of the element that will be returned upon next call totryAdvance
if such element exists.
-
Constructor Summary
Constructors Modifier Constructor Description private
BufferSpliterator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private T
advanceThis()
private boolean
canAdvanceThisAtOnce()
private boolean
canAdvanceThisWithBuffering()
int
characteristics()
long
estimateSize()
private long
estimateSizeDuringBuffering()
Returns the estimate size of this Spliterator.java.util.Comparator<? super T>
getComparator()
private int
numberOfElementsLeftInBuffer()
(package private) SeqBuffer<T>
parentSeqBuffer()
boolean
tryAdvance(java.util.function.Consumer<? super T> action)
private boolean
tryAdvanceSource()
Buffers (i.e.private boolean
tryAdvanceThisAtOnce(java.util.function.Consumer<? super T> action)
Called only when buffering has been completed.private boolean
tryAdvanceThisWithBuffering(java.util.function.Consumer<? super T> action)
Tries to advance thisSpliterator
to element atnextIndex
, bufferingsource
elements intobuffer
if necessary.java.util.Spliterator<T>
trySplit()
-
-
-
Method Detail
-
tryAdvance
public boolean tryAdvance(java.util.function.Consumer<? super T> action)
- Specified by:
tryAdvance
in interfacejava.util.Spliterator<T>
-
tryAdvanceThisWithBuffering
private boolean tryAdvanceThisWithBuffering(java.util.function.Consumer<? super T> action)
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
private T advanceThis()
-
tryAdvanceThisAtOnce
private boolean tryAdvanceThisAtOnce(java.util.function.Consumer<? super T> action)
Called only when buffering has been completed.
-
estimateSize
public long estimateSize()
- Specified by:
estimateSize
in interfacejava.util.Spliterator<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
public java.util.Spliterator<T> trySplit()
- Specified by:
trySplit
in interfacejava.util.Spliterator<T>
-
characteristics
public int characteristics()
- Specified by:
characteristics
in interfacejava.util.Spliterator<T>
-
getComparator
public java.util.Comparator<? super T> getComparator()
- Specified by:
getComparator
in interfacejava.util.Spliterator<T>
-
-