@@ -0,0 +1,1615 @@
+//%0A// $Id: IteratorIterator.java,v 1.1 2002/11/07 05:58:31 mdb Exp $%0A%0Apackage com.samskivert.util;%0A%0Aimport java.util.Collection;%0Aimport java.util.Iterator;%0Aimport java.util.NoSuchElementException;%0A%0A/**%0A * An iterator that can iterate over the elements in several collections%0A * contained within a master collection.%0A */%0Apublic class IteratorIterator implements Iterator%0A%7B%0A    /**%0A     * @param collections a Collection containing more Collections%0A     * whose elements we are to iterate over.%0A     */%0A    public IteratorIterator (Collection collections)%0A    %7B%0A        _meta = collections.iterator();%0A    %7D%0A%0A    // documentation inherited from interface Iterator%0A    public boolean hasNext ()%0A    %7B%0A        while ((_current == null) %7C%7C (!_current.hasNext())) %7B%0A            if (_meta.hasNext()) %7B%0A                _current = ((Collection) _meta.next()).iterator();%0A            %7D else %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A    // documentation inherited from interface Iterator%0A    public Object next ()%0A    %7B%0A        if (hasNext()) %7B%0A            return _current.next();%0A        %7D else %7B%0A            throw new NoSuchElementException();%0A        %7D%0A    %7D%0A%0A    // documentation inherited from interface Iterator%0A    public void remove ()%0A    %7B%0A        if (_current != null) %7B%0A            _current.remove();%0A        %7D else %7B%0A            throw new IllegalStateException();%0A        %7D%0A    %7D%0A%0A    /** The iterator through the collection we were constructed with. */%0A    protected Iterator _meta;%0A%0A    /** The current sub-collection's iterator. */%0A    protected Iterator _current;%0A%7D%0A

An iterator that iterates over the union of the iterators provided by a collection of collections.