Class LoopIterator<T>
java.lang.Object
io.github.bakedlibs.dough.collections.LoopIterator<T>
- Type Parameters:
T- The Type of element stored in the givenCollection
- All Implemented Interfaces:
Streamable<T>,Iterator<T>
This is an infite implementation of
Iterator.
When you pass a Collection or Streamable to the constructor,
this instance will represent an Iterator which will iterate over the given
Collection, when the end of the Collection is reached, it will start again at the beginning.
This will create an infinite Stream of elements.
Note that this LoopIterator will create a copy of the given Collection
and not operate on the original.- Author:
- TheBusyBiscuit
-
Constructor Summary
ConstructorsConstructorDescriptionLoopIterator(Streamable<T> streamable) This will create a new instance ofLoopIteratorthat will operate on the elements of the givenStreamableLoopIterator(Collection<T> collection) This will create a new instance ofLoopIteratorthat operates on a copy of the givenCollection -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
LoopIterator
This will create a new instance ofLoopIteratorthat operates on a copy of the givenCollection- Parameters:
collection- The collection to create aLoopIteratorof
-
LoopIterator
This will create a new instance ofLoopIteratorthat will operate on the elements of the givenStreamable- Parameters:
streamable- The streamable to create aLoopIteratorof
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
find
This method loops thisLoopIteratoruntil a matching item has been found. It will not loop more than once though. -
stream
- Specified by:
streamin interfaceStreamable<T>
-
getIndex
public int getIndex()
-