You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2002/11/22 00:08:27 UTC

cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections IteratorUtils.java

scolebourne    2002/11/21 15:08:27

  Modified:    collections/src/java/org/apache/commons/collections
                        IteratorUtils.java
  Log:
  Add LoopingIterator
  
  Revision  Changes    Path
  1.5       +22 -4     jakarta-commons/collections/src/java/org/apache/commons/collections/IteratorUtils.java
  
  Index: IteratorUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/IteratorUtils.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IteratorUtils.java	12 Oct 2002 22:15:18 -0000	1.4
  +++ IteratorUtils.java	21 Nov 2002 23:08:27 -0000	1.5
  @@ -81,6 +81,7 @@
   import org.apache.commons.collections.iterators.IteratorChain;
   import org.apache.commons.collections.iterators.IteratorEnumeration;
   import org.apache.commons.collections.iterators.ListIteratorWrapper;
  +import org.apache.commons.collections.iterators.LoopingIterator;
   import org.apache.commons.collections.iterators.SingletonIterator;
   import org.apache.commons.collections.iterators.SingletonListIterator;
   import org.apache.commons.collections.iterators.TransformIterator;
  @@ -393,6 +394,23 @@
               throw new NullPointerException("Predicate must not be null");
           }
           return new FilterListIterator(listIterator, predicate);
  +    }
  +    
  +    /**
  +     * Gets an iterator that loops continuously over the supplied collection.
  +     * <p>
  +     * The iterator will only stop looping if the remove method is called
  +     * enough times to empty the collection, or if the collection is empty
  +     * to start with.
  +     *
  +     * @param coll  the collection to iterate over, not null
  +     * @throws NullPointerException if the collection is null
  +     */
  +    public static Iterator loopingIterator(Collection coll) {
  +        if (coll == null) {
  +            throw new NullPointerException("Collection must not be null");
  +        }
  +        return new LoopingIterator(coll);
       }
       
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>