In the multiple use iterable case, the iterable is usable for any number of iterative operations over the source iterator. Of special note, even though the iterable supports multiple iterations, it does not support concurrent iterations. To implicitly create a multiple use iterable, construct a new {@link IteratorIterable} using a {@link ResettableIterator} iterator:
Integer[] array = {Integer.valueOf(1),Integer.valueOf(2),Integer.valueOf(3)}; Iteratoriterator = IteratorUtils.arrayIterator(array); // a resettable iterator Iterable iterable = new IteratorIterable (iterator);
A multiple use iterable can also be explicitly constructed using any {@link Iterator} and specifying true
for themultipleUse
flag:
Iterator@since 4.0 @version $Id: IteratorIterable.java 1477802 2013-04-30 20:01:28Z tn $iterator = // some non-resettable iterator Iterable iterable = new IteratorIterable (iterator, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|