Documentation of 'org.clapper.util.misc.MultiIterator' Java class
MultiIterator
org.clapper.util.misc

Class MultiIterator<T>

  • All Implemented Interfaces:
    java.lang.Iterable<T>, java.util.Iterator<T>


    public class MultiIterator<T>
    extends java.lang.Object
    implements java.util.Iterator<T>, java.lang.Iterable<T>

    The MultiIterator class provides a way to iterate over multiple Collection, Enumeration and Iterator objects at once. You instantiate a MultiIterator object and add one or more Collection, Enumeration or Iterator objects to it; when you use the iterator, it iterates over the contents of each contained composite object, one by one, in the order they were added to the MultiIterator. When the iterator reaches the end of one object's contents, it moves on to the next object, until no more composite objects are left.

    See Also:
    Iterator, Enumeration, Collection
    • Constructor Summary

      Constructors 
      Constructor and Description
      MultiIterator()
      Allocate a new MultiIterator object.
      MultiIterator(java.util.Collection<java.util.Collection<T>> coll)
      Allocate a new MultiIterator object that will iterate, in turn, over the contents of each Collection in the supplied Collection
      MultiIterator(java.util.Collection<T>[] array)
      Allocate a new MultiIterator object that will iterate, in turn, over the contents of each Collection in the supplied array.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addCollection(java.util.Collection<T> collection)
      Add a Collection to the end of the list of composite objects being iterated over.
      void addEnumeration(java.util.Enumeration<T> enumeration)
      Add an Enumeration to the end of the list of composite objects being iterated over.
      void addIterator(java.util.Iterator<T> iterator)
      Add an Iterator to the end of the list of composite objects being iterated over.
      boolean hasNext()
      Determine whether the underlying Iterator has more elements.
      java.util.Iterator<T> iterator()
      Returns this iterator.
      T next()
      Get the next element from the underlying array.
      void remove()
      Remove the object most recently extracted from the iterator.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • MultiIterator

        public MultiIterator()
        Allocate a new MultiIterator object.
      • MultiIterator

        public MultiIterator(java.util.Collection<T>[] array)
        Allocate a new MultiIterator object that will iterate, in turn, over the contents of each Collection in the supplied array.
        Parameters:
        array - The Collections over which to iterate
        See Also:
        addCollection(Collection)
      • MultiIterator

        public MultiIterator(java.util.Collection<java.util.Collection<T>> coll)
        Allocate a new MultiIterator object that will iterate, in turn, over the contents of each Collection in the supplied Collection
        Parameters:
        coll - A Collection of Collection objects
        See Also:
        addCollection(Collection)
    • Method Detail

      • addCollection

        public void addCollection(java.util.Collection<T> collection)

        Add a Collection to the end of the list of composite objects being iterated over. It's safe to call this method while iterating, as long as you haven't reached the end of the last composite object currently in the iterator.

        Note: This method is simply shorthand for:

        addIterator (collection.iterator());
        Parameters:
        collection - The Collection to add.
        See Also:
        addIterator(java.util.Iterator<T>), addEnumeration(java.util.Enumeration<T>)
      • addIterator

        public void addIterator(java.util.Iterator<T> iterator)
        Add an Iterator to the end of the list of composite objects being iterated over. It's safe to call this method while iterating, as long as you haven't reached the end of the last composite object currently in the iterator.
        Parameters:
        iterator - The Iterator to add.
        See Also:
        addCollection(java.util.Collection<T>), addEnumeration(java.util.Enumeration<T>)
      • addEnumeration

        public void addEnumeration(java.util.Enumeration<T> enumeration)
        Add an Enumeration to the end of the list of composite objects being iterated over. It's safe to call this method while iterating, as long as you haven't reached the end of the last composite object currently in the iterator.

        Note: This method is simply shorthand for:

        addIterator (new EnumerationIterator (enumeration));
        Parameters:
        enumeration - The Enumeration to add.
        See Also:
        addCollection(java.util.Collection<T>), addIterator(java.util.Iterator<T>), EnumerationIterator
      • hasNext

        public boolean hasNext()
        Determine whether the underlying Iterator has more elements.
        Specified by:
        hasNext in interface java.util.Iterator<T>
        Returns:
        true if and only if a call to nextElement() will return an element, false otherwise.
        See Also:
        next()
      • iterator

        public java.util.Iterator<T> iterator()
        Returns this iterator. Necessary for the Iterable interface.
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Returns:
        this object
      • next

        public T next()
               throws java.util.NoSuchElementException
        Get the next element from the underlying array.
        Specified by:
        next in interface java.util.Iterator<T>
        Returns:
        the next element from the underlying array
        Throws:
        java.util.NoSuchElementException - No more elements exist
        See Also:
        Iterator.next()
      • remove

        public void remove()
        Remove the object most recently extracted from the iterator. The object is removed from whatever underlying Collection is currently being traversed.
        Specified by:
        remove in interface java.util.Iterator<T>

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.