Package com.day.util
Class CompoundIterator
java.lang.Object
com.day.util.CompoundIterator
- All Implemented Interfaces:
Iterator
Implements the
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.
- Since:
- fennec Audience wad
-
Constructor Summary
ConstructorsConstructorDescriptionCompoundIterator(Iterator parent, Iterator child) Creates aCompoundIteratorbased onparentandchild. -
Method Summary
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
CompoundIterator
Creates aCompoundIteratorbased onparentandchild. ThisCompountIteratorwill first return elements fromparentand then elements fromchild.- Parameters:
parent- theIteratorfrom where to return the elements first.child- theIteratorfrom where to return the elements afterparentdoes not have elements any more.
-
-
Method Details
-
hasNext
public boolean hasNext()Returnstrueif either parent or child iterator has a next element;falseotherwise. -
next
Returns the next element from the parent or the child iterator object. -
remove
Always throwsUnsupportedOperationException- Specified by:
removein interfaceIterator- Throws:
UnsupportedOperationException- always!
-