Class AbstractSequentialIterator<T>

java.lang.Object
org.docx4j.com.google.common.collect.UnmodifiableIterator<T>
org.docx4j.com.google.common.collect.AbstractSequentialIterator<T>
All Implemented Interfaces:
java.util.Iterator<T>

@GwtCompatible
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.

Example:


 Iterator<Integer> powersOfTwo =
     new AbstractSequentialIterator<Integer>(1) {
       protected Integer computeNext(Integer previous) {
         return (previous == 1 << 30) ? null : previous * 2;
       }
     };
 
Since:
12.0 (in Guava as AbstractLinkedIterator since 8.0)
Author:
Chris Povirk
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected AbstractSequentialIterator​(@Nullable T firstOrNull)
    Creates a new iterator with the given first element, or, if firstOrNull is null, creates a new empty iterator.
  • Method Summary

    Modifier and Type Method Description
    protected abstract @Nullable T computeNext​(T previous)
    Returns the element that follows previous, or returns null if no elements remain.
    boolean hasNext()  
    T next()  

    Methods inherited from class org.docx4j.com.google.common.collect.UnmodifiableIterator

    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 Details

    • AbstractSequentialIterator

      protected AbstractSequentialIterator​(@Nullable T firstOrNull)
      Creates a new iterator with the given first element, or, if firstOrNull is null, creates a new empty iterator.
  • Method Details

    • computeNext

      protected abstract @Nullable T computeNext​(T previous)
      Returns the element that follows previous, or returns null if no elements remain. This method is invoked during each call to next() in order to compute the result of a future call to next().
    • hasNext

      public final boolean hasNext()
    • next

      public final T next()