public class ZippingIterator<E> extends Objectimplements 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
Constructs a new
ZippingIterator that will provide interleaved iteration of the specified iterators.
|
ZippingIterator(Iterator
Constructs a new
ZippingIterator that will provide interleaved iteration over the two given iterators.
|
ZippingIterator(Iterator
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, waitforEachRemainingpublic ZippingIterator(Iterator<? extends E> a, Iterator <? extends E> b)
ZippingIterator that will provide interleaved iteration over the two given iterators.
a - the first child iterator
b - the second child iterator
NullPointerException - if either iterator is null
public 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 iterator
b - the second child iterator
c - the third child iterator
NullPointerException - if either iterator is null
public ZippingIterator(Iterator<? extends E>... iterators)
ZippingIterator that will provide interleaved iteration of the specified iterators.
iterators - the array of iterators
NullPointerException - if any iterator is null
public 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 elements
public void remove()
remove in interface
Iterator<E>
IllegalStateException - if there is no last returned element, or if the last returned element has already been removed