Class AbstractSequentialIterator<T>

  • All Implemented Interfaces:

    public abstract class AbstractSequentialIterator<T>
    extends UnmodifiableIterator<T>
    This class provides a skeletal implementation of the Iterator interface for sequences whose next element can always be derived from the previous element. Null elements are not supported, nor is the UnmodifiableIterator.remove() method.


       Iterator<Integer> powersOfTwo = 
           new AbstractSequentialIterator<Integer>(1) {
             protected Integer computeNext(Integer previous) {
               return (previous == 1 << 30) ? null : previous * 2;
    12.0 (in Guava as AbstractLinkedIterator since 8.0)
    • Method Detail

      • hasNext

        public final boolean hasNext()
      • next

        public final T next()