Interface IteratorOperations<E>

    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default <C extends java.util.Collection<E>>
      C
      addTo​(C collection)
      Adds the remaining elements in the iterator to an arbitrary Collection.
      default E removeNext()
      Returns the next item and removes it from the iterator.
      default <C extends java.util.Collection<E>>
      C
      toCollection​(java.util.function.Supplier<C> collectionSupplier)
      Adds the remaining elements in the iterator to a new Collection provided by the supplier.
      default java.util.List<E> toList()
      Adds the remaining elements in the iterator to a new List.
      default java.util.Set<E> toSet()
      Adds the remaining elements in the iterator to a new Set.
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, hasNext, next, remove
    • Method Detail

      • addTo

        default <C extends java.util.Collection<E>> C addTo​(C collection)
        Adds the remaining elements in the iterator to an arbitrary Collection. 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 new Collection provided 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<EtoList()
        Adds the remaining elements in the iterator to a new List. This method consumes the iterator.
        Returns:
        a new List containing the remaining elements of this instance.
      • toSet

        default java.util.Set<EtoSet()
        Adds the remaining elements in the iterator to a new Set. This method consumes the iterator.
        Returns:
        a new Set containing the remaining elements of this instance.