Class LazyIterator<T>

java.lang.Object
de.renebergelt.quiterables.iterators.LazyIterator<T>
Type Parameters:
T - Type of the elements in this Iterable
All Implemented Interfaces:
Iterator<T>

public abstract class LazyIterator<T> extends Object implements Iterator<T>
Base class for the lazy iterators Derived classes only need to implement the findNextElement() function
Author:
René Bergelt
  • Field Details

    • nextElement

      protected T nextElement
      The cached next element (if any)
    • ended

      protected boolean ended
      Indicates if this iterator reached the end
  • Constructor Details

    • LazyIterator

      public LazyIterator()
  • Method Details

    • hasNext

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

      public T next()
      Specified by:
      next in interface Iterator<T>
    • findNextElement

      protected abstract T findNextElement()
      Return the next element which satisfies the predicate Return null to indicate that there will be no more objects
      Returns:
      The next element or null
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<T>