Package org.postgresql.pljava.internal
Class MarkableSequenceInputStream.FetchingListIterator<E>
java.lang.Object
org.postgresql.pljava.internal.MarkableSequenceInputStream.FetchingListIterator<E>
- All Implemented Interfaces:
Iterator<E>
,ListIterator<E>
- Enclosing class:
MarkableSequenceInputStream
public static class MarkableSequenceInputStream.FetchingListIterator<E>
extends Object
implements ListIterator<E>
A
ListIterator
that will fetch an element from a
BlockingQueue
whenever hasNext
would (otherwise)
return false
, adding it to the end of the list where the next
next()
will retrieve it.
It is possible for the hasNext
, next
, and
nextIndex
methods to throw CancellationException
, if the
thread is interrupted while they await something on the queue.
-
Constructor Summary
ConstructorDescriptionFetchingListIterator
(List<E> list, BlockingQueue<E> queue, E sentinel) Construct aFetchingListIterator
given an existing list, aBlockingQueue
, and a particular instance of the list's element type to use as an end-of-queue sentinel (it is not possible to enqueue a null value on aBlockingQueue
). -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
FetchingListIterator
Construct aFetchingListIterator
given an existing list, aBlockingQueue
, and a particular instance of the list's element type to use as an end-of-queue sentinel (it is not possible to enqueue a null value on aBlockingQueue
).- Parameters:
list
- An existing list.queue
- A blocking queue whose elements will be taken in order following any existing elements in the original list.sentinel
- A value that the supplier, feeding the blocking queue, will enqueue when no more actual values will be forthcoming. When an element is dequeued that matches this sentinel (per reference equality), it is not added to the list, and nothing more will be fetched from the queue.- Throws:
NullPointerException
- if any parameter is null.
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
nextIndex
public int nextIndex()- Specified by:
nextIndex
in interfaceListIterator<E>
-
add
- Specified by:
add
in interfaceListIterator<E>
-
hasPrevious
public boolean hasPrevious()- Specified by:
hasPrevious
in interfaceListIterator<E>
-
previous
- Specified by:
previous
in interfaceListIterator<E>
-
previousIndex
public int previousIndex()- Specified by:
previousIndex
in interfaceListIterator<E>
-
remove
public void remove() -
set
- Specified by:
set
in interfaceListIterator<E>
-