public class ZippingIterator<E>
extends java.lang.Object
implements java.util.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(java.util.Iterator<? extends E>... iterators)
Constructs a new
ZippingIterator that will provide
interleaved iteration of the specified iterators. |
ZippingIterator(java.util.Iterator<? extends E> a,
java.util.Iterator<? extends E> b)
Constructs a new
ZippingIterator that will provide
interleaved iteration over the two given iterators. |
ZippingIterator(java.util.Iterator<? extends E> a,
java.util.Iterator<? extends E> b,
java.util.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.
|
public ZippingIterator(java.util.Iterator<? extends E> a, java.util.Iterator<? extends E> b)
ZippingIterator
that will provide
interleaved iteration over the two given iterators.a
- the first child iteratorb
- the second child iteratorjava.lang.NullPointerException
- if either iterator is nullpublic ZippingIterator(java.util.Iterator<? extends E> a, java.util.Iterator<? extends E> b, java.util.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 iteratorjava.lang.NullPointerException
- if either iterator is nullpublic ZippingIterator(java.util.Iterator<? extends E>... iterators)
ZippingIterator
that will provide
interleaved iteration of the specified iterators.iterators
- the array of iteratorsjava.lang.NullPointerException
- if any iterator is nullpublic boolean hasNext()
true
if any child iterator has remaining elements.hasNext
in interface java.util.Iterator<E>
public E next() throws java.util.NoSuchElementException
next
in interface java.util.Iterator<E>
java.util.NoSuchElementException
- if no child iterator has any more elementspublic void remove()
remove
in interface java.util.Iterator<E>
java.lang.IllegalStateException
- if there is no last returned element, or if
the last returned element has already been removed"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"