Package org.apache.commons.collections4.list

# Class AbstractLinkedListJava21.LinkedListIterator<E>

java.lang.Object
org.apache.commons.collections4.list.AbstractLinkedListJava21.LinkedListIterator<E>

Type Parameters:
  `E` - the type of elements in this iterator.

All Implemented Interfaces:
  `Iterator<E>`, `ListIterator<E>`, `OrderedIterator<E>`

Direct Known Subclasses:
  `AbstractLinkedListJava21.LinkedSubListIterator`

Enclosing class:
  `AbstractLinkedListJava21<E>`

protected static class AbstractLinkedListJava21.LinkedListIterator<E> extends Object implements ListIterator<E>, OrderedIterator<E>
A list iterator over the linked list.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected AbstractLinkedListJava21.Node<E>`
  `current`
  The last node that was returned by `next()` or `previous()`.
  `protected int`
  `expectedModCount`
  The modification count that the list is expected to have.
  `protected AbstractLinkedListJava21.Node<E>`
  `next`
  The node that will be returned by `next()`.
  `protected int`
  `nextIndex`
  The index of `next`.
  `protected final AbstractLinkedListJava21<E>`
  `parent`
  The parent list

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `LinkedListIterator(AbstractLinkedListJava21<E> parent, int fromIndex)`
  Create a ListIterator for a list.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(E obj)`
  `protected void`
  `checkModCount()`
  Checks the modification count of the list is the value that this object expects.
  `protected AbstractLinkedListJava21.Node<E>`
  `getLastNodeReturned()`
  Gets the last node returned.
  `boolean`
  `hasNext()`
  `boolean`
  `hasPrevious()`
  Checks to see if there is a previous element that can be iterated to.
  `E`
  `next()`
  `int`
  `nextIndex()`
  `E`
  `previous()`
  Gets the previous element from the container.
  `int`
  `previousIndex()`
  `void`
  `remove()`
  `void`
  `set(E obj)`

  ### 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`

- ## Field Details

  - ### parent

    protected final AbstractLinkedListJava21<E> parent
    The parent list

  - ### next

    protected AbstractLinkedListJava21.Node<E> next
    The node that will be returned by `next()`. If this is equal to `AbstractLinkedListJava21.header` then there are no more values to return.

  - ### nextIndex

    protected int nextIndex
    The index of `next`.

  - ### current

    protected AbstractLinkedListJava21.Node<E> current
    The last node that was returned by `next()` or `previous()`. Set to `null` if `next()` or `previous()` haven't been called, or if the node has been removed with `remove()` or a new node added with `add(Object)`. Should be accessed through `getLastNodeReturned()` to enforce this behavior.

  - ### expectedModCount

    protected int expectedModCount
    The modification count that the list is expected to have. If the list doesn't have this count, then a `ConcurrentModificationException` may be thrown by the operations.

- ## Constructor Details

  - ### LinkedListIterator

    protected LinkedListIterator(AbstractLinkedListJava21<E> parent, int fromIndex) throws IndexOutOfBoundsException
    Create a ListIterator for a list.
    Parameters:
      `parent` - the parent list
      `fromIndex` - the index to start at
    Throws:
      `IndexOutOfBoundsException` - if fromIndex is less than 0 or greater than the size of the list

- ## Method Details

  - ### add

    public void add(E obj)
    Specified by:
      `add` in interface `ListIterator<E>`

  - ### checkModCount

    protected void checkModCount()
    Checks the modification count of the list is the value that this object expects.
    Throws:
      `ConcurrentModificationException` - If the list's modification count isn't the value that was expected.

  - ### getLastNodeReturned

    protected AbstractLinkedListJava21.Node<E> getLastNodeReturned() throws IllegalStateException
    Gets the last node returned.
    Returns:
      the last node returned
    Throws:
      `IllegalStateException` - If `next()` or `previous()` haven't been called, or if the node has been removed with `remove()` or a new node added with `add(Object)`.

  - ### hasNext

    public boolean hasNext()
    Specified by:
      `hasNext` in interface `Iterator<E>`
    Specified by:
      `hasNext` in interface `ListIterator<E>`

  - ### hasPrevious

    public boolean hasPrevious()
    Description copied from interface: `OrderedIterator`
    Checks to see if there is a previous element that can be iterated to.
    Specified by:
      `hasPrevious` in interface `ListIterator<E>`
    Specified by:
      `hasPrevious` in interface `OrderedIterator<E>`
    Returns:
      `true` if the iterator has a previous element

  - ### next

    public E next()
    Specified by:
      `next` in interface `Iterator<E>`
    Specified by:
      `next` in interface `ListIterator<E>`

  - ### nextIndex

    public int nextIndex()
    Specified by:
      `nextIndex` in interface `ListIterator<E>`

  - ### previous

    public E previous()
    Description copied from interface: `OrderedIterator`
    Gets the previous element from the container.
    Specified by:
      `previous` in interface `ListIterator<E>`
    Specified by:
      `previous` in interface `OrderedIterator<E>`
    Returns:
      the previous element in the iteration

  - ### previousIndex

    public int previousIndex()
    Specified by:
      `previousIndex` in interface `ListIterator<E>`

  - ### remove

    public void remove()
    Specified by:
      `remove` in interface `Iterator<E>`
    Specified by:
      `remove` in interface `ListIterator<E>`

  - ### set

    public void set(E obj)
    Specified by:
      `set` in interface `ListIterator<E>`