Class FilteredRangeIterator

  • All Implemented Interfaces:
    java.util.Iterator, RangeIterator

    public class FilteredRangeIterator
    extends java.lang.Object
    implements RangeIterator
    Filtering decorator for iterators.
    • Constructor Summary

      Constructors 
      Constructor Description
      FilteredRangeIterator​(java.util.Iterator<?> iterator)
      Creates a pre-fetching decorator for the given iterator.
      FilteredRangeIterator​(java.util.Iterator<?> iterator, Predicate predicate)
      Creates a new filtered iterator with the default pre-fetch buffer size.
      FilteredRangeIterator​(java.util.Iterator<?> iterator, Predicate predicate, int bufferSize)
      Creates a new filtered iterator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getPosition()
      Returns the zero-based position of the next element in this iterator.
      long getSize()
      Returns the total number of elements in this iterator, or -1 if that number is unknown.
      boolean hasNext()
      Checks whether there are more elements in this iterator.
      java.lang.Object next()
      Returns the next element in this iterator.
      void remove()
      Not supported.
      void skip​(long n)
      Skips the next n elements.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • FilteredRangeIterator

        public FilteredRangeIterator​(java.util.Iterator<?> iterator,
                                     Predicate predicate,
                                     int bufferSize)
        Creates a new filtered iterator.
        Parameters:
        iterator - underlying iterator
        predicate -
        bufferSize -
      • FilteredRangeIterator

        public FilteredRangeIterator​(java.util.Iterator<?> iterator,
                                     Predicate predicate)
        Creates a new filtered iterator with the default pre-fetch buffer size.
        Parameters:
        iterator - underlying iterator
        predicate - predicate used for filtering
      • FilteredRangeIterator

        public FilteredRangeIterator​(java.util.Iterator<?> iterator)
        Creates a pre-fetching decorator for the given iterator. This constructor is mostly useful when it is desirable to use the pre-fetching feature to automatically
        Parameters:
        iterator - underlying iterator
    • Method Detail

      • getPosition

        public long getPosition()
        Returns the zero-based position of the next element in this iterator.
        Specified by:
        getPosition in interface RangeIterator
        Returns:
        position of the next element
      • getSize

        public long getSize()
        Returns the total number of elements in this iterator, or -1 if that number is unknown.
        Specified by:
        getSize in interface RangeIterator
        Returns:
        number of elements in this iterator, or -1
      • skip

        public void skip​(long n)
                  throws java.lang.IllegalArgumentException,
                         java.util.NoSuchElementException
        Skips the next n elements.
        Specified by:
        skip in interface RangeIterator
        Parameters:
        n - number of elements to skip
        Throws:
        java.lang.IllegalArgumentException - if n is negative
        java.util.NoSuchElementException - if there are not enough elements to skip
      • hasNext

        public boolean hasNext()
        Checks whether there are more elements in this iterator.
        Specified by:
        hasNext in interface java.util.Iterator
        Returns:
        true if there are more elements, false otherwise
      • next

        public java.lang.Object next()
                              throws java.util.NoSuchElementException
        Returns the next element in this iterator.
        Specified by:
        next in interface java.util.Iterator
        Returns:
        next element
        Throws:
        java.util.NoSuchElementException - if there are no more elements
      • remove

        public void remove()
                    throws java.lang.UnsupportedOperationException
        Not supported.
        Specified by:
        remove in interface java.util.Iterator
        Throws:
        java.lang.UnsupportedOperationException