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.
- Since:
- 3.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AbstractLinkedList.Node<E> The last node that was returned bynext()orprevious().protected intThe modification count that the list is expected to have.protected AbstractLinkedList.Node<E> The node that will be returned bynext().protected intThe index ofnext.protected final AbstractLinkedList<E> The parent list -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLinkedListIterator(AbstractLinkedList<E> parent, int fromIndex) Create a ListIterator for a list. -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidChecks the modification count of the list is the value that this object expects.protected AbstractLinkedList.Node<E> Gets the last node returned.booleanhasNext()booleanChecks to see if there is a previous element that can be iterated to.next()intprevious()Gets the previous element from the container.intvoidremove()voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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.headerthen there are no more values to return. -
nextIndex
-
current
The last node that was returned bynext()orprevious(). Set tonullifnext()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 aConcurrentModificationExceptionmay 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:
addin 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:OrderedIteratorChecks to see if there is a previous element that can be iterated to.- Specified by:
hasPreviousin interfaceListIterator<E>- Specified by:
hasPreviousin interfaceOrderedIterator<E>- Returns:
trueif the iterator has a previous element
-
next
-
nextIndex
- Specified by:
nextIndexin interfaceListIterator<E>
-
previous
Description copied from interface:OrderedIteratorGets the previous element from the container.- Specified by:
previousin interfaceListIterator<E>- Specified by:
previousin interfaceOrderedIterator<E>- Returns:
- the previous element in the iteration
-
previousIndex
- Specified by:
previousIndexin interfaceListIterator<E>
-
remove
-
set
- Specified by:
setin interfaceListIterator<E>
-