org.apache.commons.collections.list

Class AbstractLinkedList.LinkedListIterator

Enclosing Class:
AbstractLinkedList
Implemented Interfaces:
Iterator, ListIterator, OrderedIterator
Known Direct Subclasses:
AbstractLinkedList.LinkedSubListIterator, CursorableLinkedList.Cursor

protected static class AbstractLinkedList.LinkedListIterator
extends java.lang.Object
implements ListIterator, OrderedIterator

A list iterator over the linked list.

Field Summary

protected AbstractLinkedList.Node
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 AbstractLinkedList.Node
next
The node that will be returned by next().
protected int
nextIndex
The index of next.
protected AbstractLinkedList
parent
The parent list

Constructor Summary

LinkedListIterator(AbstractLinkedList parent, int fromIndex)
Create a ListIterator for a list.

Method Summary

void
add(Object obj)
protected void
checkModCount()
Checks the modification count of the list is the value that this object expects.
protected AbstractLinkedList.Node
getLastNodeReturned()
Gets the last node returned.
boolean
hasNext()
boolean
hasPrevious()
Object
next()
int
nextIndex()
Object
previous()
int
previousIndex()
void
remove()
void
set(Object obj)

Field Details

current

protected AbstractLinkedList.Node 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 behaviour.

expectedModCount

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

AbstractLinkedList.Node next
The node that will be returned by next(). If this is equal to AbstractLinkedList.header then there are no more values to return.

nextIndex

protected int nextIndex

parent

protected final AbstractLinkedList parent
The parent list

Constructor Details

LinkedListIterator

protected LinkedListIterator(AbstractLinkedList parent,
                             int fromIndex)
            throws IndexOutOfBoundsException
Create a ListIterator for a list.
Parameters:
parent - the parent list
fromIndex - the index to start at

Method Details

add

public void add(Object obj)

checkModCount

protected void checkModCount()
Checks the modification count of the list is the value that this object expects.

getLastNodeReturned

protected AbstractLinkedList.Node getLastNodeReturned()
            throws IllegalStateException
Gets the last node returned.

hasNext

public boolean hasNext()

hasPrevious

public boolean hasPrevious()
Specified by:
hasPrevious in interface OrderedIterator

next

public Object next()

nextIndex

public int nextIndex()

previous

public Object previous()
Specified by:
previous in interface OrderedIterator

previousIndex

public int previousIndex()

remove

public void remove()

set

public void set(Object obj)

Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.