org.graffiti.util
Class ConcatIterator<T>

java.lang.Object
  extended by org.graffiti.util.ConcatIterator<T>
Type Parameters:
T - The type of the elements iterated over. Must be a supertype of all of the element types of the underlying iterator.
All Implemented Interfaces:
Iterator<T>

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

A wrapper for concatenating multiple Iterators into a single one. Iterating a ConcatIterator is equivalent to iterating the given iterators one after the other. The iteration is efficient in the sense that the iteration of the underlying iterators does not occur until it is needed, i. e., no caching is done. The overhead in comparison to direct iteration of the underlying iterators is negligible.

The remove() method is implemented and removes the current element from the underlying iterator (provided it supports removal).

Version:
$Revision: 5767 $ $Date: 2006-01-13 11:54:43 +0100 (Fr, 13 Jan 2006) $
Author:
Michael Forster

Constructor Summary
ConcatIterator()
          Constructs a new empty ConcatIterator.
ConcatIterator(Collection<? extends Iterable<? extends T>> iterables)
          Constructs a new ConcatIterator from the concatenation of the given iterables.
ConcatIterator(Iterable<? extends T>... iterables)
          Constructs a new ConcatIterator from the concatenation of the given iterables.
ConcatIterator(Iterator<? extends T>... iterators)
          Constructs a new ConcatIterator from the concatenation of the given iterators.
 
Method Summary
 boolean hasNext()
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcatIterator

public ConcatIterator()
Constructs a new empty ConcatIterator.


ConcatIterator

public ConcatIterator(Iterator<? extends T>... iterators)
Constructs a new ConcatIterator from the concatenation of the given iterators.

Parameters:
iterators - The iterators to be concatenated.

ConcatIterator

public ConcatIterator(Iterable<? extends T>... iterables)
Constructs a new ConcatIterator from the concatenation of the given iterables.

Parameters:
iterables - The iterables to be concatenated.

ConcatIterator

public ConcatIterator(Collection<? extends Iterable<? extends T>> iterables)
Constructs a new ConcatIterator from the concatenation of the given iterables.

Parameters:
iterables - The iterables to be concatenated.
Method Detail

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()
Specified by:
remove in interface Iterator<T>


Generated at 2012-05-30 11:00:14 PM CEST