Package com.day.util
Class CompoundIterator
- java.lang.Object
-
- com.day.util.CompoundIterator
-
- All Implemented Interfaces:
Iterator
public class CompoundIterator extends Object implements Iterator
Implements theIteratorinterface and combines twoIteratorobjects into one singleIterator.The constructor takes two
Iteratorarguments:parentandchild. Callingnext()on thisIteratorwill first try to return an element from the parentIteratorand once the parentIteratordoes not have any more elements it will return elements from the childIterator.- Since:
- fennec Audience wad
-
-
Constructor Summary
Constructors Constructor Description CompoundIterator(Iterator parent, Iterator child)Creates aCompoundIteratorbased onparentandchild.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasNext()Returnstrueif either parent or child iterator has a next element;falseotherwise.Objectnext()Returns the next element from the parent or the child iterator object.voidremove()Always throwsUnsupportedOperationException-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
CompoundIterator
public CompoundIterator(Iterator parent, Iterator child)
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 Detail
-
hasNext
public boolean hasNext()
Returnstrueif either parent or child iterator has a next element;falseotherwise.
-
next
public Object next()
Returns the next element from the parent or the child iterator object.
-
remove
public void remove() throws UnsupportedOperationExceptionAlways throwsUnsupportedOperationException- Specified by:
removein interfaceIterator- Throws:
UnsupportedOperationException- always!
-
-