Interface IteratorOperations<E>
-
- Type Parameters:
E- the type of elements returned by this iterator.
- All Superinterfaces:
java.util.Iterator<E>
- All Known Implementing Classes:
ExtendedIterator,FilterIterator,UniqueFilterIterator
public interface IteratorOperations<E> extends java.util.Iterator<E>
ExtendsIteratorwith additional default methods.- Since:
- 4.5.0-M3
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default <C extends java.util.Collection<E>>
CaddTo(C collection)Adds the remaining elements in the iterator to an arbitraryCollection.default EremoveNext()Returns the next item and removes it from the iterator.default <C extends java.util.Collection<E>>
CtoCollection(java.util.function.Supplier<C> collectionSupplier)Adds the remaining elements in the iterator to a newCollectionprovided by the supplier.default java.util.List<E>toList()Adds the remaining elements in the iterator to a newList.default java.util.Set<E>toSet()Adds the remaining elements in the iterator to a newSet.
-
-
-
Method Detail
-
addTo
default <C extends java.util.Collection<E>> C addTo(C collection)
Adds the remaining elements in the iterator to an arbitraryCollection. This method consumes the iterator.- Type Parameters:
C- A collection of objects of type<E>.- Parameters:
collection- The target collection to add elements to.- Returns:
- the given
collection.
-
removeNext
default E removeNext()
Returns the next item and removes it from the iterator.- Returns:
- the next item from the iterator.
-
toCollection
default <C extends java.util.Collection<E>> C toCollection(java.util.function.Supplier<C> collectionSupplier)
Adds the remaining elements in the iterator to a newCollectionprovided by the supplier. This method consumes the iterator.- Type Parameters:
C- the collection type.- Parameters:
collectionSupplier- supplies a collection target.- Returns:
- a new Collection containing the remaining elements of this instance.
-
toList
default java.util.List<E> toList()
Adds the remaining elements in the iterator to a newList. This method consumes the iterator.- Returns:
- a new List containing the remaining elements of this instance.
-
-