Class FilterIterator<T>

All Implemented Interfaces:
Iterator<T>, org.apache.jena.atlas.iterator.IteratorCloseable<T>, org.apache.jena.atlas.lib.Closeable, ClosableIterator<T>, ExtendedIterator<T>

public class FilterIterator<T> extends WrappedIterator<T>
Creates a sub-Iterator by filtering. This class should not be used directly any more; the subclasses FilterKeepIterator and FilterDropIterator should be used instead.
  • Constructor Details

    • FilterIterator

      public FilterIterator(Predicate<T> fl, Iterator<T> e)
      Initialises a FilterIterator with its filter and base.
      fl - An object is included if it is accepted by this Filter.
      e - The base Iterator.
  • Method Details

    • hasNext

      public boolean hasNext()
      Answer true iff there is at least one more acceptable object. [Stores reference into current, sets canRemove false; answer preserved in `hasCurrent`]
      Specified by:
      hasNext in interface Iterator<T>
      hasNext in class WrappedIterator<T>
    • remove

      public void remove()
      Remove the current member from the underlying iterator. Legal only after a .next() but before any subsequent .hasNext(), because that may advance the underlying iterator.
      Specified by:
      remove in interface Iterator<T>
      remove in class WrappedIterator<T>
    • next

      public T next()
      Answer the next acceptable object from the base iterator. The redundant test of `hasCurrent` appears to make a detectable speed difference. Crazy.
      Specified by:
      next in interface Iterator<T>
      next in class WrappedIterator<T>
    • forEachRemaining

      public void forEachRemaining(Consumer<? super T> action)
      Description copied from class: WrappedIterator
      forEachRemaining: defer to the base iterator
      Specified by:
      forEachRemaining in interface Iterator<T>
      forEachRemaining in class WrappedIterator<T>