net.sourceforge.nite.util
Class IteratorChain
java.lang.Object
net.sourceforge.nite.util.IteratorChain
- All Implemented Interfaces:
- java.util.Iterator
public class IteratorChain
- extends java.lang.Object
- implements java.util.Iterator
An IteratorChain is used to chain several Iterators, i.e.
iterate consecutively through each of the Iterators and present
them as one Iterator. The order in qhich the original Iterators are
traversed is determined by the constructor parameter.
This implementation is lazy, meaning that the next object from a source
iterator will not be accessed before it is needed due to a call to the
next() method of this IteratorChain.
The original Iterators are stored internally in an array, though.
By default, the IteratorChain does not allow removal of objects.
Example:
..
Iterator[] iterators;
Iterator chainedIt = new IteratorChain(iterators);
..
Examples of the use of the different Iterator modifyers (IteratorFilter,
IteratorTransform, IteratorChain) can be found in the class RTSI.
- Author:
- Dennis Reidsma, UTwente
Adapted from the parlevink package (HMI group, University of Twente)
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IteratorChain
public IteratorChain(java.util.Iterator[] its)
- Parameters:
its
- The Iterators to be chained
remove
public void remove()
- Specified by:
remove
in interface java.util.Iterator
- Throws:
java.lang.UnsupportedOperationException
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator
next
public java.lang.Object next()
- Specified by:
next
in interface java.util.Iterator