java.lang.Object | +--org.apache.commons.collections.list.AbstractLinkedList | +--org.apache.commons.collections.list.CursorableLinkedListAll Implemented Interfaces:
java.util.LinkedList
transient List | A list of the cursor currently open on this list |
Constructor that creates. |
CursorableLinkedList(Collection coll) Constructor that copies the specified collection |
void | addNode(AbstractLinkedList.Node nodeToInsert, AbstractLinkedList.Node insertBeforeNode) Inserts a new node into the list. |
void | broadcastNodeChanged(AbstractLinkedList.Node node) Informs all of my registered cursors that the specified element was changed. |
void | broadcastNodeInserted(AbstractLinkedList.Node node) Informs all of my registered cursors that the specified element was just added to my list. |
void | broadcastNodeRemoved(AbstractLinkedList.Node node) Informs all of my registered cursors that the specified element was just removed from my list. |
cursor() Returns a Cursor for iterating through the elements of this list. | |
cursor(int fromIndex) Returns a Cursor for iterating through the elements of this list starting from a specified index. | |
void | init() The equivalent of a default constructor called by any constructor and by readObject. |
Iterator | iterator() Returns an iterator that does not support concurrent modification. |
ListIterator | Returns a cursor iterator that allows changes to the underlying list in parallel. |
ListIterator | listIterator(int fromIndex) Returns a cursor iterator that allows changes to the underlying list in parallel. |
void | registerCursor(CursorableLinkedList.Cursor cursor) Registers a cursor to be notified of changes to this list. |
void | Removes all nodes by iteration. |
void | removeNode(AbstractLinkedList.Node node) Removes the specified node from the list. |
void | unregisterCursor(CursorableLinkedList.Cursor cursor) Deregisters a cursor from the list to be notified of changes. |
void | updateNode(AbstractLinkedList.Node node, Object value) Updates the node with a new value. |
protected transient List cursors
public CursorableLinkedList()
public CursorableLinkedList(Collection coll)
protected void addNode(AbstractLinkedList.Node nodeToInsert, AbstractLinkedList.Node insertBeforeNode)
- if either node is nullprotected void broadcastNodeChanged(AbstractLinkedList.Node node)
protected void broadcastNodeInserted(AbstractLinkedList.Node node)
protected void broadcastNodeRemoved(AbstractLinkedList.Node node)
public CursorableLinkedList.Cursor cursor()
Cursor
is a ListIterator
with an additional
close()
method. Calling this method immediately discards the
references to the cursor. If it is not called, then the garbage collector
will still remove the reference as it is held via a WeakReference
.
The cursor enables iteration and list changes to occur in any order without
invalidating the iterator (from one thread). When elements are added to the
list, an event is fired to all active cursors enabling them to adjust to the
change in the list.
When the "current" (i.e., last returned by ListIterator.next
or ListIterator.previous) element of the list is removed,
the cursor automatically adjusts to the change (invalidating the
last returned value such that it cannot be removed).
The listIterator() method returns the same as this method, and can
be cast to a Cursor
if the close
method is required.
public CursorableLinkedList.Cursor cursor(int fromIndex)
Cursor
is a ListIterator
with an additional
close()
method. Calling this method immediately discards the
references to the cursor. If it is not called, then the garbage collector
will still remove the reference as it is held via a WeakReference
.
The cursor enables iteration and list changes to occur in any order without
invalidating the iterator (from one thread). When elements are added to the
list, an event is fired to all active cursors enabling them to adjust to the
change in the list.
When the "current" (i.e., last returned by ListIterator.next
or ListIterator.previous) element of the list is removed,
the cursor automatically adjusts to the change (invalidating the
last returned value such that it cannot be removed).
The listIterator(int) method returns the same as this method, and can
be cast to a Cursor
if the close
method is required.
- if the index is out of range
(index < 0 || index > size()).protected void init()
readObject
.
public Iterator iterator()
public ListIterator listIterator()
public ListIterator listIterator(int fromIndex)
protected void registerCursor(CursorableLinkedList.Cursor cursor)
protected void removeAllNodes()
protected void removeNode(AbstractLinkedList.Node node)
- if node is nullprotected void unregisterCursor(CursorableLinkedList.Cursor cursor)
protected void updateNode(AbstractLinkedList.Node node, Object value)
List
implementation with aListIterator
that allows concurrent modifications to the underlying list. This implementation supports all of the optional List operations. It extendsAbstractLinkedList
and thus provides the stack/queue/dequeue operations available in java.util.LinkedList. The main feature of this class is the ability to modify the list and the iterator at the same time. Both the listIterator() and cursor() methods provides access to aCursor
instance which extendsListIterator
. The cursor allows changes to the list concurrent with changes to the iterator. Note that the iterator() method and sublists do not provide this cursor behaviour. TheCursor
class is provided partly for backwards compatibility and partly because it allows the cursor to be directly closed. Closing the cursor is optional because references are held via aWeakReference
. For most purposes, simply modify the iterator and list at will, and then let the garbage collector to the rest. Note that this implementation is not synchronized.