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 2004/07/17 23:08:05 UTC

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

scolebourne    2004/07/17 14:08:05

  Modified:    collections/src/java/org/apache/commons/collections
                        IteratorUtils.java
  Log:
  Add LoopingListIterator
  bug 30166
  
  Revision  Changes    Path
  1.28      +19 -1     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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- IteratorUtils.java	26 May 2004 21:53:46 -0000	1.27
  +++ IteratorUtils.java	17 Jul 2004 21:08:05 -0000	1.28
  @@ -42,6 +42,7 @@
   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.LoopingListIterator;
   import org.apache.commons.collections.iterators.ObjectArrayIterator;
   import org.apache.commons.collections.iterators.ObjectArrayListIterator;
   import org.apache.commons.collections.iterators.ObjectGraphIterator;
  @@ -683,6 +684,23 @@
               throw new NullPointerException("Collection must not be null");
           }
           return new LoopingIterator(coll);
  +    }
  +    
  +    /**
  +     * Gets an iterator that loops continuously over the supplied list.
  +     * <p>
  +     * The iterator will only stop looping if the remove method is called
  +     * enough times to empty the list, or if the list is empty to start with.
  +     *
  +     * @param list  the list to iterate over, not null
  +     * @return a new looping iterator
  +     * @throws NullPointerException if the list is null
  +     */
  +    public static ResettableIterator loopingListIterator(List list) {
  +        if (list == null) {
  +            throw new NullPointerException("List must not be null");
  +        }
  +        return new LoopingListIterator(list);
       }
       
       // Views
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org