Interface ResourceIterator<E extends @Nullable Object, X extends Exception>

Type Parameters:
E - the element type
X - an exception that can be thrown on closing the resource
All Superinterfaces:
AutoCloseable, Iterator<E>, Iterator<E>, Resource<X>
All Known Subinterfaces:
CloseableIterator<E>

public interface ResourceIterator<E extends @Nullable Object, X extends Exception> extends Resource<X>, Iterator<E>
An Iterator that is also a Resource
Since:
0.5.0
  • Method Details

    • filter

      default ResourceIterator<E,X> filter(Predicate<? super E> predicate)
      Description copied from interface: Iterator
      Return an iterator over the elements that satisfy predicate
      Specified by:
      filter in interface Iterator<E extends @Nullable Object>
      Parameters:
      predicate - the predicate each element must satisfy
      Returns:
      the filtered iterator
      Since:
      0.6.0
    • map

      default <R extends @Nullable Object> ResourceIterator<R,X> map(Function<? super E, ? extends R> mapper)
      Description copied from interface: Iterator
      Return an iterator that applies mapper to each element
      Specified by:
      map in interface Iterator<E extends @Nullable Object>
      Type Parameters:
      R - the mapped element type
      Parameters:
      mapper - the function applied to each element
      Returns:
      the mapped iterator
    • peek

      default ResourceIterator<E,X> peek(Consumer<? super E> action)
      Description copied from interface: Iterator
      Return an iterator that applies action to each element as it is returned
      Specified by:
      peek in interface Iterator<E extends @Nullable Object>
      Parameters:
      action - the action applied to each element
      Returns:
      the peeking iterator
      Since:
      0.6.0
    • limit

      default ResourceIterator<E,X> limit(long limit)
      Description copied from interface: Iterator
      Return an iterator over at most limit elements
      Specified by:
      limit in interface Iterator<E extends @Nullable Object>
      Parameters:
      limit - the maximum number of elements
      Returns:
      the truncated iterator
      Since:
      0.6.0
    • skip

      default ResourceIterator<E,X> skip(long skip)
      Description copied from interface: Iterator
      Return an iterator over the elements after the first skip
      Specified by:
      skip in interface Iterator<E extends @Nullable Object>
      Parameters:
      skip - the number of leading elements to discard
      Returns:
      the remaining iterator
      Since:
      0.6.0
    • takeWhile

      default ResourceIterator<E,X> takeWhile(Predicate<? super E> predicate)
      Description copied from interface: Iterator
      Return an iterator over the leading elements that satisfy predicate
      Specified by:
      takeWhile in interface Iterator<E extends @Nullable Object>
      Parameters:
      predicate - the predicate the leading elements must satisfy
      Returns:
      the leading iterator
      Since:
      0.6.0
    • dropWhile

      default ResourceIterator<E,X> dropWhile(Predicate<? super E> predicate)
      Description copied from interface: Iterator
      Return an iterator over the elements after the leading elements that satisfy predicate
      Specified by:
      dropWhile in interface Iterator<E extends @Nullable Object>
      Parameters:
      predicate - the predicate the skipped leading elements satisfy
      Returns:
      the remaining iterator
      Since:
      0.6.0