Class AbstractLinkedList.LinkedListIterator<E>
java.lang.Object
org.apache.commons.collections4.list.AbstractLinkedList.LinkedListIterator<E>
- Type Parameters:
E
- the type of elements in this iterator.
- All Implemented Interfaces:
Iterator<E>
,ListIterator<E>
,OrderedIterator<E>
- Direct Known Subclasses:
AbstractLinkedList.LinkedSubListIterator
,CursorableLinkedList.Cursor
- Enclosing class:
AbstractLinkedList<E>
protected static class AbstractLinkedList.LinkedListIterator<E>
extends Object
implements ListIterator<E>, OrderedIterator<E>
A list iterator over the linked list.
-
Field Summary
Modifier and TypeFieldDescriptionprotected AbstractLinkedList.Node
<E> The last node that was returned bynext()
orprevious()
.protected int
The modification count that the list is expected to have.protected AbstractLinkedList.Node
<E> The node that will be returned bynext()
.protected int
The index ofnext
.protected final AbstractLinkedList
<E> The parent list -
Constructor Summary
ModifierConstructorDescriptionprotected
LinkedListIterator
(AbstractLinkedList<E> parent, int fromIndex) Create a ListIterator for a list. -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
Checks the modification count of the list is the value that this object expects.protected AbstractLinkedList.Node
<E> Gets the last node returned.boolean
hasNext()
boolean
Checks to see if there is a previous element that can be iterated to.next()
int
previous()
Gets the previous element from the container.int
void
remove()
void
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
The parent list -
next
The node that will be returned bynext()
. If this is equal toAbstractLinkedList.header
then there are no more values to return. -
nextIndex
The index ofnext
. -
current
The last node that was returned bynext()
orprevious()
. Set tonull
ifnext()
orprevious()
haven't been called, or if the node has been removed withremove()
or a new node added withadd(Object)
. Should be accessed throughgetLastNodeReturned()
to enforce this behavior. -
expectedModCount
The modification count that the list is expected to have. If the list doesn't have this count, then aConcurrentModificationException
may be thrown by the operations.
-
-
Constructor Details
-
LinkedListIterator
protected LinkedListIterator(AbstractLinkedList<E> parent, int fromIndex) throws IndexOutOfBoundsException Create a ListIterator for a list.- Parameters:
parent
- the parent list.fromIndex
- The starting index.- Throws:
IndexOutOfBoundsException
- if fromIndex is less than 0 or greater than the size of the list.
-
-
Method Details
-
add
- Specified by:
add
in interfaceListIterator<E>
-
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
Gets the last node returned.- Returns:
- the last node returned
- Throws:
IllegalStateException
- Ifnext()
orprevious()
haven't been called, or if the node has been removed withremove()
or a new node added withadd(Object)
.
-
hasNext
-
hasPrevious
Description copied from interface:OrderedIterator
Checks to see if there is a previous element that can be iterated to.- Specified by:
hasPrevious
in interfaceListIterator<E>
- Specified by:
hasPrevious
in interfaceOrderedIterator<E>
- Returns:
true
if the iterator has a previous element
-
next
-
nextIndex
- Specified by:
nextIndex
in interfaceListIterator<E>
-
previous
Description copied from interface:OrderedIterator
Gets the previous element from the container.- Specified by:
previous
in interfaceListIterator<E>
- Specified by:
previous
in interfaceOrderedIterator<E>
- Returns:
- the previous element in the iteration
-
previousIndex
- Specified by:
previousIndex
in interfaceListIterator<E>
-
remove
-
set
- Specified by:
set
in interfaceListIterator<E>
-