Class CursorableLinkedList<E>
- Type Parameters:
- E- the type of the elements in the list.
- All Implemented Interfaces:
- Serializable,- Iterable<E>,- Collection<E>,- List<E>
List implementation with a ListIterator that
 allows concurrent modifications to the underlying list.
 
 This implementation supports all of the optional List operations.
 It extends AbstractLinkedList and thus provides the
 stack/queue/dequeue operations available in 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 a Cursor instance which extends
 ListIterator. 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 behavior.
 
 The Cursor 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 a WeakReference.
 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.
- Since:
- 1.0
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classDeprecated.An extendedListIteratorthat allows concurrent changes to the underlying list.protected static classDeprecated.A cursor for the sublist based on LinkedSubListIterator.Nested classes/interfaces inherited from class org.apache.commons.collections4.list.AbstractLinkedListAbstractLinkedList.LinkedListIterator<E>, AbstractLinkedList.LinkedSubList<E>, AbstractLinkedList.LinkedSubListIterator<E>, AbstractLinkedList.Node<E>
- 
Constructor SummaryConstructorsConstructorDescriptionDeprecated.Constructor that creates.CursorableLinkedList(Collection<? extends E> coll) Deprecated.Constructor that copies the specified collection
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddNode(AbstractLinkedList.Node<E> nodeToInsert, AbstractLinkedList.Node<E> insertBeforeNode) Deprecated.Inserts a new node into the list.protected voidDeprecated.Informs all of my registered cursors that the specified element was changed.protected voidDeprecated.Informs all of my registered cursors that the specified element was just added to my list.protected voidDeprecated.Informs all of my registered cursors that the specified element was just removed from my list.protected ListIterator<E> createSubListListIterator(AbstractLinkedList.LinkedSubList<E> subList, int fromIndex) Deprecated.Creates a list iterator for the sublist.cursor()Deprecated.Returns aCursorableLinkedList.Cursorfor iterating through the elements of this list.cursor(int fromIndex) Deprecated.Returns aCursorableLinkedList.Cursorfor iterating through the elements of this list starting from a specified index.protected voidinit()Deprecated.The equivalent of a default constructor called by any constructor and byreadObject.iterator()Deprecated.Returns an iterator that does not support concurrent modification.Deprecated.Returns a cursor iterator that allows changes to the underlying list in parallel.listIterator(int fromIndex) Deprecated.Returns a cursor iterator that allows changes to the underlying list in parallel.protected voidregisterCursor(CursorableLinkedList.Cursor<E> cursor) Deprecated.Registers a cursor to be notified of changes to this list.protected voidDeprecated.Removes all nodes by iteration.protected voidremoveNode(AbstractLinkedList.Node<E> node) Deprecated.Removes the specified node from the list.protected voidunregisterCursor(CursorableLinkedList.Cursor<E> cursor) Deprecated.Deregisters a cursor from the list to be notified of changes.protected voidupdateNode(AbstractLinkedList.Node<E> node, E value) Deprecated.Updates the node with a new value.Methods inherited from class org.apache.commons.collections4.list.AbstractLinkedListadd, add, addAll, addAll, addFirst, addLast, addNodeAfter, addNodeBefore, clear, contains, containsAll, createHeaderNode, createNode, createSubListIterator, doReadObject, doWriteObject, equals, get, getFirst, getLast, getNode, hashCode, indexOf, isEmpty, isEqualValue, lastIndexOf, remove, remove, removeAll, removeFirst, removeLast, retainAll, set, size, subList, toArray, toArray, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.CollectionparallelStream, removeIf, streamMethods inherited from interface java.util.ListreplaceAll, sort, spliterator
- 
Constructor Details- 
CursorableLinkedList
- 
CursorableLinkedListDeprecated.Constructor that copies the specified collection- Parameters:
- coll- the collection to copy
 
 
- 
- 
Method Details- 
addNodeprotected void addNode(AbstractLinkedList.Node<E> nodeToInsert, AbstractLinkedList.Node<E> insertBeforeNode) Deprecated.Inserts a new node into the list.- Overrides:
- addNodein class- AbstractLinkedList<E>
- Parameters:
- nodeToInsert- new node to insert
- insertBeforeNode- node to insert before
- Throws:
- NullPointerException- if either node is null
 
- 
broadcastNodeChangedDeprecated.Informs all of my registered cursors that the specified element was changed.- Parameters:
- node- the node that was changed
 
- 
broadcastNodeInsertedDeprecated.Informs all of my registered cursors that the specified element was just added to my list.- Parameters:
- node- the node that was changed
 
- 
broadcastNodeRemovedDeprecated.Informs all of my registered cursors that the specified element was just removed from my list.- Parameters:
- node- the node that was changed
 
- 
createSubListListIteratorprotected ListIterator<E> createSubListListIterator(AbstractLinkedList.LinkedSubList<E> subList, int fromIndex) Deprecated.Creates a list iterator for the sublist.- Overrides:
- createSubListListIteratorin class- AbstractLinkedList<E>
- Parameters:
- subList- the sublist to get an iterator for
- fromIndex- the index to start from, relative to the sublist
- Returns:
- the list iterator for the sublist
 
- 
cursorDeprecated.Returns aCursorableLinkedList.Cursorfor iterating through the elements of this list.A Cursoris aListIteratorwith an additionalclose()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 aWeakReference.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()orListIterator.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 aCursorif theclosemethod is required.- Returns:
- a new cursor iterator
 
- 
cursorDeprecated.Returns aCursorableLinkedList.Cursorfor iterating through the elements of this list starting from a specified index.A Cursoris aListIteratorwith an additionalclose()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 aWeakReference.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()orListIterator.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 aCursorif theclosemethod is required.- Parameters:
- fromIndex- the index to start from
- Returns:
- a new cursor iterator
- Throws:
- IndexOutOfBoundsException- if the index is out of range (index < 0 || index > size()).
 
- 
initDeprecated.The equivalent of a default constructor called by any constructor and byreadObject.- Overrides:
- initin class- AbstractLinkedList<E>
 
- 
iteratorDeprecated.Returns an iterator that does not support concurrent modification.If the underlying list is modified while iterating using this iterator a ConcurrentModificationException will occur. The cursor behavior is available via listIterator().
- 
listIteratorDeprecated.Returns a cursor iterator that allows changes to the underlying list in parallel.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()orListIterator.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).- Specified by:
- listIteratorin interface- List<E>
- Overrides:
- listIteratorin class- AbstractLinkedList<E>
- Returns:
- a new cursor iterator
 
- 
listIteratorDeprecated.Returns a cursor iterator that allows changes to the underlying list in parallel.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()orListIterator.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).- Specified by:
- listIteratorin interface- List<E>
- Overrides:
- listIteratorin class- AbstractLinkedList<E>
- Parameters:
- fromIndex- the index to start from
- Returns:
- a new cursor iterator
 
- 
registerCursorDeprecated.Registers a cursor to be notified of changes to this list.- Parameters:
- cursor- the cursor to register
 
- 
removeAllNodesDeprecated.Removes all nodes by iteration.- Overrides:
- removeAllNodesin class- AbstractLinkedList<E>
 
- 
removeNodeDeprecated.Removes the specified node from the list.- Overrides:
- removeNodein class- AbstractLinkedList<E>
- Parameters:
- node- the node to remove
- Throws:
- NullPointerException- if- nodeis null
 
- 
unregisterCursorDeprecated.Deregisters a cursor from the list to be notified of changes.- Parameters:
- cursor- the cursor to deregister
 
- 
updateNodeDeprecated.Updates the node with a new value. This implementation sets the value on the node. Subclasses can override this to record the change.- Overrides:
- updateNodein class- AbstractLinkedList<E>
- Parameters:
- node- node to update
- value- new value of the node
 
 
- 
AbstractLinkedListis source incompatible with List methods added in Java 21