public class ZippingIterator<E> extends Object implements Iterator<E>
Given two Iterator
instances A
and B
, the
next()
method on this iterator will switch between A.next()
and B.next()
until both iterators are exhausted.
Constructor and Description |
---|
ZippingIterator(Iterator<? extends E>... iterators)
Constructs a new
ZippingIterator that will provide
interleaved iteration of the specified iterators. |
ZippingIterator(Iterator<? extends E> a,
Iterator<? extends E> b)
Constructs a new
ZippingIterator that will provide
interleaved iteration over the two given iterators. |
ZippingIterator(Iterator<? extends E> a,
Iterator<? extends E> b,
Iterator<? extends E> c)
Constructs a new
ZippingIterator that will provide
interleaved iteration over the three given iterators. |
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Returns
true if any child iterator has remaining elements. |
E |
next()
Returns the next element from a child iterator.
|
void |
remove()
Removes the last returned element from the child iterator that produced it.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public ZippingIterator(Iterator<? extends E> a, Iterator<? extends E> b)
ZippingIterator
that will provide
interleaved iteration over the two given iterators.a
- the first child iteratorb
- the second child iteratorNullPointerException
- if either iterator is nullpublic ZippingIterator(Iterator<? extends E> a, Iterator<? extends E> b, Iterator<? extends E> c)
ZippingIterator
that will provide
interleaved iteration over the three given iterators.a
- the first child iteratorb
- the second child iteratorc
- the third child iteratorNullPointerException
- if either iterator is nullpublic ZippingIterator(Iterator<? extends E>... iterators)
ZippingIterator
that will provide
interleaved iteration of the specified iterators.iterators
- the array of iteratorsNullPointerException
- if any iterator is nullpublic boolean hasNext()
true
if any child iterator has remaining elements.public E next() throws NoSuchElementException
next
in interface Iterator<E>
NoSuchElementException
- if no child iterator has any more elementspublic void remove()
remove
in interface Iterator<E>
IllegalStateException
- if there is no last returned element, or if
the last returned element has already been removedCopyright © 2001–2019 The Apache Software Foundation. All rights reserved.