Class AbstractPrimedIterator<E>

java.lang.Object
com.globalmentor.collections.iterators.AbstractPrimedIterator<E>
Type Parameters:
E - The type of element returned by the iterator.
All Implemented Interfaces:
Iterator<E>
Direct Known Subclasses:
AbstractFilteredIterator

public abstract class AbstractPrimedIterator<E> extends Object implements 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
  • Constructor Details

    • AbstractPrimedIterator

      public AbstractPrimedIterator()
  • Method Details

    • hasNext

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

      public E next()
      Specified by:
      next in interface 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 Iterator<E>