Class LoopingIterator<E>
- Type Parameters:
- E- the type of elements returned by this iterator.
- All Implemented Interfaces:
- Iterator<E>,- ResettableIterator<E>
 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:
- 3.0
- 
Constructor SummaryConstructorsConstructorDescriptionLoopingIterator(Collection<? extends E> collection) Constructor that wraps a collection.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanhasNext()Has the iterator any more elements.next()Returns the next object in the collection.voidremove()Removes the previously retrieved item from the underlying collection.voidreset()Resets the iterator back to the start of the collection.intsize()Gets the size of the collection underlying the iterator.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.IteratorforEachRemaining
- 
Constructor Details- 
LoopingIteratorConstructor 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:
- collection- the collection to wrap
- Throws:
- NullPointerException- if the collection is null
 
 
- 
- 
Method Details- 
hasNext
- 
next
- 
removeRemoves the previously retrieved item from the underlying collection.This feature is only supported if the underlying collection's Collection.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 thereset()is called, then remove may not be called untilnext()is called again.
- 
resetResets the iterator back to the start of the collection.- Specified by:
- resetin interface- ResettableIterator<E>
 
- 
sizeGets the size of the collection underlying the iterator.- Returns:
- the current collection size
 
 
-