public class CompoundIterator
extends java.lang.Object
implements java.util.Iterator
Iterator interface and combines two
Iterator objects into one single Iterator.
The constructor takes two Iterator arguments: parent
and child. Calling next() on this Iterator
will first try to return an element from the parent Iterator
and once the parent Iterator does not have any more elements
it will return elements from the child Iterator.
| Constructor and Description |
|---|
CompoundIterator(java.util.Iterator parent,
java.util.Iterator child)
Creates a
CompoundIterator based on parent
and child. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext()
Returns
true if either parent or child iterator
has a next element; false otherwise. |
java.lang.Object |
next()
Returns the next element from the parent or the child
iterator object.
|
void |
remove()
Always throws
UnsupportedOperationException |
public CompoundIterator(java.util.Iterator parent,
java.util.Iterator child)
CompoundIterator based on parent
and child. This CompountIterator will first
return elements from parent and then elements from
child.parent - the Iterator from where to return the elements
first.child - the Iterator from where to return the elements
after parent does not have elements any more.public boolean hasNext()
true if either parent or child iterator
has a next element; false otherwise.hasNext in interface java.util.Iteratortrue if either parent or child iterator
has a next element; false otherwise.public java.lang.Object next()
next in interface java.util.Iteratorpublic void remove()
throws java.lang.UnsupportedOperationException
UnsupportedOperationExceptionremove in interface java.util.Iteratorjava.lang.UnsupportedOperationException - always!Copyright © 2010 - 2023 Adobe. All Rights Reserved