Class AbstractPrimedIterator<E>

  • Type Parameters:
    E - The type of element returned by the iterator.
    All Implemented Interfaces:
    java.util.Iterator<E>
    Direct Known Subclasses:
    AbstractFilteredIterator

    public abstract class AbstractPrimedIterator<E>
    extends java.lang.Object
    implements java.util.Iterator<E>
    Abstract implementation of an iterator that lazily primes its next value.

    This version does not support remove().

    This class is not thread safe.

    Author:
    Garret Wilson
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      E next()  
      protected abstract E primeNext()
      Returns the next available element for the iterator.
      void remove()  
      • Methods inherited from class java.lang.Object

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

        forEachRemaining
    • Constructor Detail

      • AbstractPrimedIterator

        public AbstractPrimedIterator()
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<E>
      • next

        public E next()
        Specified by:
        next in interface java.util.Iterator<E>
      • primeNext

        protected abstract E primeNext()
        Returns the next available element for the iterator. The value returned by this method will be returned by the next call to next. The implementation guarantees that this method will not be called again after null is returned.
        Returns:
        The next primed value for the iterator, or null if there are no further values.
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<E>