java.lang.Object | |
↳ | org.apache.commons.collections.CursorableLinkedList |
This class is deprecated.
Use new version in list subpackage, which has been rewritten
and now returns the cursor from the listIterator method. Will be removed in v4.0
A doubly-linked list implementation of the List interface, supporting a ListIterator that allows concurrent modifications to the underlying list.
Implements all of the optional List
operations, the
stack/queue/dequeue operations available in java.util.LinkedList
and supports a ListIterator
that allows concurrent modifications
to the underlying list (see cursor()
).
Note that this implementation is not synchronized.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CursorableLinkedList.Cursor |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
_cursors | A list of the currently CursorableLinkedList.Cursor s currently
open in this list. |
||||||||||
_head | A sentry node. | ||||||||||
_modCount | Tracks the number of structural modifications to me. | ||||||||||
_size | The number of elements in me. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Appends the specified element to the end of this list.
| |||||||||||
Inserts the specified element at the specified position in this list.
| |||||||||||
Appends all of the elements in the specified collection to the end of
this list, in the order that they are returned by the specified
Collection 's Iterator . | |||||||||||
Inserts all of the elements in the specified collection into this
list at the specified position.
| |||||||||||
Inserts the specified element at the beginning of this list.
| |||||||||||
Inserts the specified element at the end of this list.
| |||||||||||
Removes all of the elements from this list.
| |||||||||||
Returns true if this list contains the specified element.
| |||||||||||
Returns true if this list contains all of the elements of the
specified collection.
| |||||||||||
Returns a
ListIterator for iterating through the
elements of this list, initialized such that
next() will return the element at
the specified index (if any) and previous()
will return the element immediately preceding it (if any). | |||||||||||
Returns a
ListIterator for iterating through the
elements of this list. | |||||||||||
Compares the specified object with this list for equality.
| |||||||||||
Returns the element at the specified position in this list.
| |||||||||||
Returns the element at the beginning of this list.
| |||||||||||
Returns the element at the end of this list.
| |||||||||||
Returns the hash code value for this list.
| |||||||||||
Returns the index in this list of the first occurrence of the specified
element, or -1 if this list does not contain this element.
| |||||||||||
Returns true if this list contains no elements.
| |||||||||||
Returns a fail-fast iterator.
| |||||||||||
Returns the index in this list of the last occurrence of the specified
element, or -1 if this list does not contain this element.
| |||||||||||
Returns a fail-fast ListIterator.
| |||||||||||
Returns a fail-fast ListIterator.
| |||||||||||
Removes the element at the specified position in this list (optional
operation).
| |||||||||||
Removes the first occurrence in this list of the specified element.
| |||||||||||
Removes from this list all the elements that are contained in the
specified collection.
| |||||||||||
Removes the first element of this list, if any.
| |||||||||||
Removes the last element of this list, if any.
| |||||||||||
Retains only the elements in this list that are contained in the
specified collection.
| |||||||||||
Replaces the element at the specified position in this list with the
specified element.
| |||||||||||
Returns the number of elements in this list.
| |||||||||||
Returns a fail-fast sublist.
| |||||||||||
Returns an array containing all of the elements in this list in proper
sequence; the runtime type of the returned array is that of the
specified array.
| |||||||||||
Returns an array containing all of the elements in this list in proper
sequence.
| |||||||||||
Returns a
String representation of this list, suitable for debugging. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Informs all of my registered cursors that the specified
element was changed.
| |||||||||||
Informs all of my registered cursors that the specified
element was just added to my list.
| |||||||||||
Informs all of my registered cursors that the specified
element was just removed from my list.
| |||||||||||
Returns the
org.apache.commons.collections.CursorableLinkedList.Listable
at the specified index.
| |||||||||||
Inserts a new value into my
list, after the specified before element, and before the
specified after element
| |||||||||||
Informs all of my registered cursors that they are now
invalid.
| |||||||||||
Registers a
CursorableLinkedList.Cursor to be notified
of changes to this list. | |||||||||||
Removes the given
org.apache.commons.collections.CursorableLinkedList.Listable
from my list.
| |||||||||||
Removes a
CursorableLinkedList.Cursor from
the set of cursors to be notified of changes to this list. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Iterable
| |||||||||||
From interface
java.util.Collection
| |||||||||||
From interface
java.util.List
|
A list of the currently CursorableLinkedList.Cursor
s currently
open in this list.
A sentry node.
_head.next() points to the first element in the list, _head.prev() to the last. Note that it is possible for _head.next().prev() and _head.prev().next() to be non-null, as when I am a sublist for some larger list. Use == _head.next() and == _head.prev() to determine if a given org.apache.commons.collections.CursorableLinkedList.Listable is the first or last element in the list.
Tracks the number of structural modifications to me.
The number of elements in me.
Appends the specified element to the end of this list.
o | element to be appended to this list. |
---|
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
index | index at which the specified element is to be inserted. |
---|---|
element | element to be inserted. |
ClassCastException | if the class of the specified element prevents it from being added to this list. |
---|---|
IllegalArgumentException | if some aspect of the specified element prevents it from being added to this list. |
IndexOutOfBoundsException | if the index is out of range (index < 0 || index > size()). |
Appends all of the elements in the specified collection to the end of
this list, in the order that they are returned by the specified
Collection
's Iterator
. The behavior of this operation is
unspecified if the specified collection is modified while
the operation is in progress. (Note that this will occur if the
specified collection is this list, and it's nonempty.)
c | collection whose elements are to be added to this list. |
---|
ClassCastException | if the class of an element in the specified collection prevents it from being added to this list. |
---|---|
IllegalArgumentException | if some aspect of an element in the specified collection prevents it from being added to this list. |
Inserts all of the elements in the specified collection into this
list at the specified position. Shifts the element currently at
that position (if any) and any subsequent elements to the right
(increases their indices). The new elements will appear in this
list in the order that they are returned by the specified
Collection
's Iterator
. The behavior of this operation is
unspecified if the specified collection is modified while the
operation is in progress. (Note that this will occur if the specified
collection is this list, and it's nonempty.)
index | index at which to insert first element from the specified collection. |
---|---|
c | elements to be inserted into this list. |
ClassCastException | if the class of one of elements of the specified collection prevents it from being added to this list. |
---|---|
IllegalArgumentException | if some aspect of one of elements of the specified collection prevents it from being added to this list. |
IndexOutOfBoundsException | if the index is out of range (index < 0 || index > size()). |
Inserts the specified element at the beginning of this list.
(Equivalent to add(0,o)
).
o | element to be prepended to this list. |
---|
Inserts the specified element at the end of this list.
(Equivalent to add(java.lang.Object)
).
o | element to be appended to this list. |
---|
Removes all of the elements from this list. This list will be empty after this call returns (unless it throws an exception).
Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).
o | element whose presence in this list is to be tested. |
---|
Returns true if this list contains all of the elements of the specified collection.
c | collection to be checked for containment in this list. |
---|
Returns a ListIterator
for iterating through the
elements of this list, initialized such that
next()
will return the element at
the specified index (if any) and previous()
will return the element immediately preceding it (if any).
Unlike iterator()
, a cursor
is not bothered by concurrent modifications to the
underlying list.
IndexOutOfBoundsException | if the index is out of range (index < 0 || index > size()). |
---|
Returns a ListIterator
for iterating through the
elements of this list. Unlike iterator()
, a cursor
is not bothered by concurrent modifications to the
underlying list.
Specifically, when elements are added to the list before or
after the cursor, the cursor simply picks them up automatically.
When the "current" (i.e., last returned by next()
or previous()
) element of the list is removed,
the cursor automatically adjusts to the change (invalidating the
last returned value--i.e., it cannot be removed).
Note that the returned ListIterator
does not support the
nextIndex()
and previousIndex()
methods (they throw UnsupportedOperationException
when invoked.
Historical Note: In previous versions of this class, the object returned from this method was required to be explicitly closed. This is no longer necessary.
Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.
o | the object to be compared for equality with this list. |
---|
Returns the element at the specified position in this list.
index | index of element to return. |
---|
IndexOutOfBoundsException | if the index is out of range (index < 0 || index >= size()). |
---|
Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
hashCode = 1; Iterator i = list.iterator(); while (i.hasNext()) { Object obj = i.next(); hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode()); }This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object.hashCode.
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
o | element to search for. |
---|
Returns true if this list contains no elements.
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
o | element to search for. |
---|
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
index | the index of the element to removed. |
---|
IndexOutOfBoundsException | if the index is out of range (index < 0 || index >= size()). |
---|
Removes the first occurrence in this list of the specified element. If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists).
o | element to be removed from this list, if present. |
---|
Removes from this list all the elements that are contained in the specified collection.
c | collection that defines which elements will be removed from this list. |
---|
Retains only the elements in this list that are contained in the specified collection. In other words, removes from this list all the elements that are not contained in the specified collection.
c | collection that defines which elements this set will retain. |
---|
Replaces the element at the specified position in this list with the specified element.
index | index of element to replace. |
---|---|
element | element to be stored at the specified position. |
ClassCastException | if the class of the specified element prevents it from being added to this list. |
---|---|
IllegalArgumentException | if some aspect of the specified element prevents it from being added to this list. |
IndexOutOfBoundsException | if the index is out of range (index < 0 || index >= size()). |
Returns the number of elements in this list.
Returns an array containing all of the elements in this list in proper
sequence; the runtime type of the returned array is that of the
specified array. Obeys the general contract of the
toArray()
method.
a | the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose. |
---|
ArrayStoreException | if the runtime type of the specified array is not a supertype of the runtime type of every element in this list. |
---|
Returns an array containing all of the elements in this list in proper
sequence. Obeys the general contract of the toArray()
method.
Informs all of my registered cursors that the specified element was changed.
Informs all of my registered cursors that the specified element was just added to my list.
Informs all of my registered cursors that the specified element was just removed from my list.
Returns the org.apache.commons.collections.CursorableLinkedList.Listable at the specified index.
IndexOutOfBoundsException | if index is less than zero or greater than or equal to the size of this list. |
---|
Inserts a new value into my list, after the specified before element, and before the specified after element
Informs all of my registered cursors that they are now invalid.
Registers a CursorableLinkedList.Cursor
to be notified
of changes to this list.
Removes the given org.apache.commons.collections.CursorableLinkedList.Listable from my list.
Removes a CursorableLinkedList.Cursor
from
the set of cursors to be notified of changes to this list.