- 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>SpecialSpliteratorwhosetryAdvancemethod can buffer (i.e. can advance thesourcespliterator). 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 intnextIndexIndex of the element that will be returned upon next call totryAdvanceif such element exists.
-
Constructor Summary
Constructors Modifier Constructor Description privateBufferSpliterator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private TadvanceThis()private booleancanAdvanceThisAtOnce()private booleancanAdvanceThisWithBuffering()intcharacteristics()longestimateSize()private longestimateSizeDuringBuffering()Returns the estimate size of this Spliterator.java.util.Comparator<? super T>getComparator()private intnumberOfElementsLeftInBuffer()(package private) SeqBuffer<T>parentSeqBuffer()booleantryAdvance(java.util.function.Consumer<? super T> action)private booleantryAdvanceSource()Buffers (i.e.private booleantryAdvanceThisAtOnce(java.util.function.Consumer<? super T> action)Called only when buffering has been completed.private booleantryAdvanceThisWithBuffering(java.util.function.Consumer<? super T> action)Tries to advance thisSpliteratorto element atnextIndex, bufferingsourceelements intobufferif necessary.java.util.Spliterator<T>trySplit()
-
-
-
Method Detail
-
tryAdvance
public boolean tryAdvance(java.util.function.Consumer<? super T> action)
- Specified by:
tryAdvancein interfacejava.util.Spliterator<T>
-
tryAdvanceThisWithBuffering
private boolean tryAdvanceThisWithBuffering(java.util.function.Consumer<? super T> action)
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
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:
estimateSizein 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:
trySplitin interfacejava.util.Spliterator<T>
-
characteristics
public int characteristics()
- Specified by:
characteristicsin interfacejava.util.Spliterator<T>
-
getComparator
public java.util.Comparator<? super T> getComparator()
- Specified by:
getComparatorin interfacejava.util.Spliterator<T>
-
-