Class AbstractLinkedList.LinkedListIterator
- java.lang.Object
-
- org.apache.commons.collections.list.AbstractLinkedList.LinkedListIterator
-
- All Implemented Interfaces:
java.util.Iterator,java.util.ListIterator,OrderedIterator
- Direct Known Subclasses:
AbstractLinkedList.LinkedSubListIterator,CursorableLinkedList.Cursor
- Enclosing class:
- AbstractLinkedList
protected static class AbstractLinkedList.LinkedListIterator extends java.lang.Object implements java.util.ListIterator, OrderedIterator
A list iterator over the linked list.
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractLinkedList.NodecurrentThe last node that was returned bynext()orprevious().protected intexpectedModCountThe modification count that the list is expected to have.protected AbstractLinkedList.NodenextThe node that will be returned bynext().protected intnextIndexThe index ofnext.protected AbstractLinkedListparentThe parent list
-
Constructor Summary
Constructors Modifier Constructor Description protectedLinkedListIterator(AbstractLinkedList parent, int fromIndex)Create a ListIterator for a list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.Object obj)protected voidcheckModCount()Checks the modification count of the list is the value that this object expects.protected AbstractLinkedList.NodegetLastNodeReturned()Gets the last node returned.booleanhasNext()booleanhasPrevious()Checks to see if there is a previous element that can be iterated to.java.lang.Objectnext()intnextIndex()java.lang.Objectprevious()Gets the previous element from the collection.intpreviousIndex()voidremove()voidset(java.lang.Object obj)
-
-
-
Field Detail
-
parent
protected final AbstractLinkedList parent
The parent list
-
next
protected AbstractLinkedList.Node next
The node that will be returned bynext(). If this is equal toAbstractLinkedList.headerthen there are no more values to return.
-
nextIndex
protected int nextIndex
The index ofnext.
-
current
protected AbstractLinkedList.Node 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 behaviour.
-
expectedModCount
protected int 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 Detail
-
LinkedListIterator
protected LinkedListIterator(AbstractLinkedList parent, int fromIndex) throws java.lang.IndexOutOfBoundsException
Create a ListIterator for a list.- Parameters:
parent- the parent listfromIndex- the index to start at- Throws:
java.lang.IndexOutOfBoundsException
-
-
Method Detail
-
checkModCount
protected void checkModCount()
Checks the modification count of the list is the value that this object expects.- Throws:
java.util.ConcurrentModificationException- If the list's modification count isn't the value that was expected.
-
getLastNodeReturned
protected AbstractLinkedList.Node getLastNodeReturned() throws java.lang.IllegalStateException
Gets the last node returned.- Throws:
java.lang.IllegalStateException- Ifnext()orprevious()haven't been called, or if the node has been removed withremove()or a new node added withadd(Object).
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator- Specified by:
hasNextin interfacejava.util.ListIterator
-
next
public java.lang.Object next()
- Specified by:
nextin interfacejava.util.Iterator- Specified by:
nextin interfacejava.util.ListIterator
-
hasPrevious
public boolean hasPrevious()
Description copied from interface:OrderedIteratorChecks to see if there is a previous element that can be iterated to.- Specified by:
hasPreviousin interfacejava.util.ListIterator- Specified by:
hasPreviousin interfaceOrderedIterator- Returns:
trueif the iterator has a previous element
-
previous
public java.lang.Object previous()
Description copied from interface:OrderedIteratorGets the previous element from the collection.- Specified by:
previousin interfacejava.util.ListIterator- Specified by:
previousin interfaceOrderedIterator- Returns:
- the previous element in the iteration
-
nextIndex
public int nextIndex()
- Specified by:
nextIndexin interfacejava.util.ListIterator
-
previousIndex
public int previousIndex()
- Specified by:
previousIndexin interfacejava.util.ListIterator
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator- Specified by:
removein interfacejava.util.ListIterator
-
set
public void set(java.lang.Object obj)
- Specified by:
setin interfacejava.util.ListIterator
-
add
public void add(java.lang.Object obj)
- Specified by:
addin interfacejava.util.ListIterator
-
-