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>
AListIterator
that will fetch an element from aBlockingQueue
wheneverhasNext
would (otherwise) returnfalse
, adding it to the end of the list where the nextnext()
will retrieve it.It is possible for the
hasNext
,next
, andnextIndex
methods to throwCancellationException
, if the thread is interrupted while they await something on the queue.
-
-
Constructor Summary
Constructors Constructor Description FetchingListIterator(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
).
-
-
-
Constructor Detail
-
FetchingListIterator
public FetchingListIterator(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
).- 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 Detail
-
hasNext
public boolean hasNext()
-
next
public E next()
-
nextIndex
public int nextIndex()
- Specified by:
nextIndex
in interfaceListIterator<E>
-
add
public void add(E e)
- Specified by:
add
in interfaceListIterator<E>
-
hasPrevious
public boolean hasPrevious()
- Specified by:
hasPrevious
in interfaceListIterator<E>
-
previous
public E previous()
- Specified by:
previous
in interfaceListIterator<E>
-
previousIndex
public int previousIndex()
- Specified by:
previousIndex
in interfaceListIterator<E>
-
remove
public void remove()
-
set
public void set(E e)
- Specified by:
set
in interfaceListIterator<E>
-
-