Class FilterIterator<T>

    • Constructor Detail

      • FilterIterator

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

      • 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 java.util.Iterator<T>
        Overrides:
        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 java.util.Iterator<T>
        Overrides:
        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 java.util.Iterator<T>
        Overrides:
        next in class WrappedIterator<T>