Class ListIteratorImpl<E>

  • Type Parameters:
    E - type of list
    All Implemented Interfaces:
    Iterator<E>, ListIterator<E>

    public final class ListIteratorImpl<E>
    extends IteratorImpl<E>
    implements ListIterator<E>
    An iterator for lists that allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator's current position in the list.
    Author:
    Andrea "Stock" Stocchero
    • Method Detail

      • hasPrevious

        public boolean hasPrevious()
        Returns true if this list iterator has more elements when traversing the list in the forward direction.
        Specified by:
        hasPrevious in interface ListIterator<E>
      • nextIndex

        public int nextIndex()
        Returns the index of the element that would be returned by a subsequent call to next().
        Specified by:
        nextIndex in interface ListIterator<E>
      • previousIndex

        public int previousIndex()
        Returns the index of the element that would be returned by a subsequent call to previous().
        Specified by:
        previousIndex in interface ListIterator<E>
      • previous

        public E previous()
        Returns the previous element in the list and moves the cursor position backwards.
        Specified by:
        previous in interface ListIterator<E>
      • set

        public void set​(E e)
        Replaces the last element returned by next() or previous() with the specified element .
        Specified by:
        set in interface ListIterator<E>
      • add

        public void add​(E e)
        Inserts the specified element in the list
        Specified by:
        add in interface ListIterator<E>