Class LoopingIterator

java.lang.Object
org.apache.commons.collections.iterators.LoopingIterator
All Implemented Interfaces:
Iterator, ResettableIterator

@Deprecated(since="2021-04-30") public class LoopingIterator extends Object implements ResettableIterator
Deprecated.
Apache Commons Collections version 3.x is being deprecated from AEMaaCS. The upgraded version 4.4 of Commons Collections is already included as replacement. Customers are advised to upgrade to this version of the library. Please note: the package name was changed to org.apache.commons.collections4. Further note that there are AEM APIs currently exposing the old collections classes; these will be updated in upcoming releases.
An Iterator that restarts when it reaches the end.

The iterator will loop continuously around the provided elements, unless there are no elements in the collection to begin with, or all the elements have been removed.

Concurrent modifications are not directly supported, and for most collection implementations will throw a ConcurrentModificationException.

Since:
Commons Collections 3.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
    Constructor that wraps a collection.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Deprecated.
    Has the iterator any more elements.
    Deprecated.
    Returns the next object in the collection.
    void
    Deprecated.
    Removes the previously retrieved item from the underlying collection.
    void
    Deprecated.
    Resets the iterator back to the start of the collection.
    int
    Deprecated.
    Gets the size of the collection underlying 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
  • Constructor Details

    • LoopingIterator

      public LoopingIterator(Collection coll)
      Deprecated.
      Constructor that wraps a collection.

      There is no way to reset an Iterator instance without recreating it from the original source, so the Collection must be passed in.

      Parameters:
      coll - the collection to wrap
      Throws:
      NullPointerException - if the collection is null
  • Method Details

    • hasNext

      public boolean hasNext()
      Deprecated.
      Has the iterator any more elements.

      Returns false only if the collection originally had zero elements, or all the elements have been removed.

      Specified by:
      hasNext in interface Iterator
      Returns:
      true if there are more elements
    • next

      public Object next()
      Deprecated.
      Returns the next object in the collection.

      If at the end of the collection, return the first element.

      Specified by:
      next in interface Iterator
      Throws:
      NoSuchElementException - if there are no elements at all. Use hasNext() to avoid this error.
    • remove

      public void remove()
      Deprecated.
      Removes the previously retrieved item from the underlying collection.

      This feature is only supported if the underlying collection's iterator method returns an implementation that supports it.

      This method can only be called after at least one next() method call. After a removal, the remove method may not be called again until another next has been performed. If the reset() is called, then remove may not be called until next() is called again.

      Specified by:
      remove in interface Iterator
    • reset

      public void reset()
      Deprecated.
      Resets the iterator back to the start of the collection.
      Specified by:
      reset in interface ResettableIterator
    • size

      public int size()
      Deprecated.
      Gets the size of the collection underlying the iterator.
      Returns:
      the current collection size