Class AbstractIterator<E>

  • All Implemented Interfaces:
    Iterator<E>
    Direct Known Subclasses:
    LineIteratorImpl

    public abstract class AbstractIterator<E>
    extends Object
    implements Iterator<E>
    Base class of implementing iterators. All you have to do is implement advance which gets the next element.
    • Field Detail

      • next

        protected E next
    • Constructor Detail

      • AbstractIterator

        public AbstractIterator()
    • Method Detail

      • hasNext

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

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

        public void remove()
        Specified by:
        remove in interface Iterator<E>
      • advance

        protected abstract E advance()
        Returns:
        the next element or null if the iterator is at the end
      • peek

        public E peek()
        Returns the next element in the iterator, if one exists. Otherwise, returns null. Invoking this method does not advance the iterator.
        Returns:
        The next element in the iterator, without advancing, or, if no other element exists, null.
      • isIterating

        protected boolean isIterating()
        Returns:
        true after the first time hasNext() or next() have been called