Class FilterIterator<T>

java.lang.Object
com.github.basking2.sdsai.itrex.iterators.FilterIterator<T>
Type Parameters:
T - The element type to filter.
All Implemented Interfaces:
Iterator<T>

public class FilterIterator<T> extends Object implements Iterator<T>
Similar to the NullSkippingIterator, this will skip values if they fail a provided check. Skipping is done by prefetching 1 element to ensure we can accurately compute hasNext().
  • Constructor Details

    • FilterIterator

      public FilterIterator(Iterator<T> iterator, Predicate<T> predicate)
      Parameters:
      iterator - The iterator of elements.
      predicate - A predicate that checks elements returned by the iterator for inclusion in this iterator.
      See Also:
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<T>
    • next

      public T next()
      Specified by:
      next in interface Iterator<T>