|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knime.core.data.util.SynchronizedIterator<T>
T
- The elements contained in the Iterable.public final class SynchronizedIterator<T>
Synchronized (thread-safe) wrapper for an Iterator
. This class
does not implement the Iterator
interface as it does not
follow the usual hasNext()
, next()
procedure
(which is not a atomic sequence). Instead, this class should be used as
follows:
final SynchronizedIterator<T> it = new SynchronizedIterator<T>(wrappedIterator); // this is usually executed in different threads T next; while ((next = it.next()) != null) { }Alternatively, this class provides a method
nextWithIndex()
,
which wraps the iteration element and its index in the iteration loop
in a SynchronizedIterator.ElementAndIndex
.
Nested Class Summary | |
---|---|
static class |
SynchronizedIterator.ElementAndIndex<T>
Class combining an iteration element with its index in the iteration loop. |
Constructor Summary | |
---|---|
SynchronizedIterator(Iterable<T> iterable)
Creates new iterator from an Iterable. |
|
SynchronizedIterator(Iterator<T> it)
Creates new iterator from a given (unsynchronized) iterator. |
Method Summary | |
---|---|
T |
next()
|
SynchronizedIterator.ElementAndIndex<T> |
nextWithIndex()
Get the next element along with its index in the iteration (starting with 0 for the first element) or null if no more elements
are available. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SynchronizedIterator(Iterator<T> it)
it
- The iterator instance to wrap.
NullPointerException
- If the argument is null.public SynchronizedIterator(Iterable<T> iterable)
iterable
- Argument iterable.
NullPointerException
- If the argument is null.Method Detail |
---|
public T next()
null
if
no more are available.public SynchronizedIterator.ElementAndIndex<T> nextWithIndex()
null
if no more elements
are available.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |