public class IteratorIterable<T> extends Object implements Iterable<T>
Iterator
that allows it to be used in for-each
loops. This is useful when working with objects that return an iterator rather
than a collection in order to protect access to their state.
Note: this class does not allow re-iteration of the iterator. Calling iterator()
multiple times will return iterators that refer to the same source
iterator.
Constructor and Description |
---|
IteratorIterable(Iterator<T> iterator) |
Modifier and Type | Method and Description |
---|---|
Iterator<T> |
iterator() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator