|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.util.Iterators.Sequence<E>
public static class Iterators.Sequence<E>
An Iterators.Sequence iterates over the elements of an
ordered sequence of iterators in turn. Each iterator is exhausted
before moving to the next. These iterators may be supplied as a
pair of iterators, as an array of iterators, or as an iterator of
iterators. The sequence iterator delegates calls to next() and remove() to the relevant iterator in the
underlying sequence of iterators. For next(), this is
the current underlying iterator. For remove(), it's
the last iterator whose next() element was called, and
it throws an illegal state exception if there isn't one.
Implementation Note: Because of the requirements of
Iterator.remove(), a reference to the last iterator is
kept, as well as to the current iterator. Otherwise, the sequence
iterator will release resources as soon as possible. If the
supplied sequence is an array, the elements will not be
automatically returned from that array; it is simply wrapped in an
instance of Iterators.Array.
| Constructor Summary | |
|---|---|
Iterators.Sequence(Iterator<? extends E>[] iterators)
Construct a sequence iterator that calls the iterators in the specified array in the order they are given in the array. |
|
Iterators.Sequence(Iterator<? extends E> iterator1,
Iterator<? extends E> iterator2)
Construct a sequenc iterator that calls the pair of iterators specified in turn. |
|
Iterators.Sequence(Iterator<? extends Iterator<? extends E>> iteratorOfIterators)
Construct a sequence iterator that calls the iterators returned by the iterator of iterators specified. |
|
| Method Summary | |
|---|---|
boolean |
hasNext()
Returns true if this iterator has another element. |
E |
next()
Return the next element returned by the next iterator in the iterator sequence. |
void |
remove()
Removes the last element returned by this iterator from the collection underlying the iterator from which it was returned. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Iterators.Sequence(Iterator<? extends E> iterator1,
Iterator<? extends E> iterator2)
iterator1 - First iterator.iterator2 - Second iterator.public Iterators.Sequence(Iterator<? extends E>[] iterators)
iterators - Sequence of iterators.public Iterators.Sequence(Iterator<? extends Iterator<? extends E>> iteratorOfIterators)
hasNext() and
next() will throw a
ClassCastException.
iteratorOfIterators - Iterator of iterators.| Method Detail |
|---|
public boolean hasNext()
true if this iterator has another element.
This sequence of iterators has another element if it has
another iterator that has another element.
hasNext in interface Iterator<E>true if this sequence of iterators
has another iterator with another element.
ClassCastException - If an object is returned by
the iterator of iterators specified at construction time
that is not an iterator.public E next()
next in interface Iterator<E>ClassCastException - If an object is returned by
the iterator of iterators specified at construction time
that is not an iterator.public void remove()
next().
remove in interface Iterator<E>IllegalStateException - If next() has not
yet been called, or remove() method has
been called after the last call to next().
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||