consciouscode.util
Class CompositeIterator<T>

java.lang.Object
  extended by consciouscode.util.CompositeIterator<T>
All Implemented Interfaces:
Iterator<T>

public class CompositeIterator<T>
extends Object
implements Iterator<T>

An Iterator that composes the contents of other iterators or collections.

To use this, create a CompositeIterator and then call appendElements any number of times. When this iterator is used, the elements will all be returned in the order they were appended.

Note that this class does not implement the remove() method.


Constructor Summary
CompositeIterator()
           
 
Method Summary
 void appendElements(Collection<T> collection)
          Appends the given elements to the end of this iterator.
 void appendElements(Iterator<T> iterator)
          Appends the given elements to the end of this iterator.
 boolean hasNext()
           
 T next()
           
 void remove()
          Unsupported operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeIterator

public CompositeIterator()
Method Detail

appendElements

public void appendElements(Iterator<T> iterator)
Appends the given elements to the end of this iterator.


appendElements

public void appendElements(Collection<T> collection)
Appends the given elements to the end of this iterator.


hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<T>

next

public T next()
Specified by:
next in interface Iterator<T>

remove

public void remove()
            throws UnsupportedOperationException
Unsupported operation.

Specified by:
remove in interface Iterator<T>
Throws:
UnsupportedOperationException - in all cases.


Copyright © 2001–2012 Todd V. Jonker. All Rights Reserved.