Interface IteratorOperations<E>
- Type Parameters:
E- the type of elements returned by this iterator.
- All Superinterfaces:
Iterator<E>
- All Known Implementing Classes:
ExtendedIterator,FilterIterator,UniqueFilterIterator
Extends
Iterator with additional default methods.- Since:
- 4.5.0-M3
-
Method Summary
Modifier and TypeMethodDescriptiondefault <C extends Collection<E>>
CaddTo(C collection) Adds the remaining elements in the iterator to an arbitraryCollection.default EReturns the next item and removes it from the iterator.default <C extends Collection<E>>
CtoCollection(Supplier<C> collectionSupplier) Adds the remaining elements in the iterator to a newCollectionprovided by the supplier.toList()Adds the remaining elements in the iterator to a newList.toSet()Adds the remaining elements in the iterator to a newSet.Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
addTo
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
Returns the next item and removes it from the iterator.- Returns:
- the next item from the iterator.
-
toCollection
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
-
toSet
-