|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
com.tangosol.util.SafeLinkedList
public class SafeLinkedList
Implementation of the Collection Framework interface "List" using a linked list algorithm. Read-only operations avoid synchronizing. Some operations appear to be read-only but have side-effects, such as indexed operations against the List, because the List caches the last index used and the Node that it located (to facilitate processes that access the list sequentially using indexes etc.). Other operations, even if read-only, require the data structures to remain unchanged for the duration of the call to avoid potential exceptions (such as a NullPointerException if a reference is cleared).
Nested Class Summary | |
---|---|
protected static class |
SafeLinkedList.Node A Node in the List. |
Field Summary | |
---|---|
protected int |
m_cNodes The size of the List. |
protected SafeLinkedList.Node |
m_current The Node at the "cached position" in the List. |
protected SafeLinkedList.Node |
m_head The first Node in the List (or null if empty). |
protected int |
m_iPos The "cached position" in the List. |
protected SafeLinkedList.Node |
m_tail The last Node in the List (or null if empty). |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
SafeLinkedList() Construct an empty List. |
|
SafeLinkedList(java.util.Collection collection) Construct a List containing the elements of the specified Collection. |
Method Summary | |
---|---|
void |
add(int i, java.lang.Object o) Inserts the specified element at the specified position in this List. |
boolean |
add(java.lang.Object o) Appends the specified element to the end of this List. |
boolean |
addAll(java.util.Collection collection) 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. |
boolean |
addAll(int i, java.util.Collection collection) Inserts all of the elements in the specified collection at the specified location in this List. |
void |
clear() Removes all of the elements from this List. |
java.lang.Object |
clone() Create a clone of the SafeLinkedList. |
boolean |
contains(java.lang.Object o) Returns true if this List contains the specified element. |
boolean |
containsAll(java.util.Collection collection) Returns true if this List contains all of the elements of the specified collection. |
java.lang.Object |
get(int i) Returns the element at the specified position in this List. |
protected SafeLinkedList.Node |
getNode(int i) Find and return the specified Node. |
int |
indexOf(java.lang.Object o) Returns the index in this List of the first occurrence of the specified element, or -1 if this List does not contain this element. |
protected SafeLinkedList.Node |
instantiateNode(java.lang.Object o) Instantiate a Node. |
int |
lastIndexOf(java.lang.Object o) Returns the index in this List of the last occurrence of the specified element, or -1 if this List does not contain this element. |
static void |
main(java.lang.String[] asArg) Self-test for SafeLinkedList. |
protected void |
markPosition(int i, SafeLinkedList.Node node) Remember that a certain Node occurs at a certain index. |
java.lang.Object |
remove(int i) Removes the element at the specified position in this List. |
boolean |
remove(java.lang.Object o) Removes the first occurrence in this List of the specified element. |
protected void |
reset() Completely reset the state of the List. |
java.lang.Object |
set(int i, java.lang.Object o) Replaces the element at the specified position in this List with the specified element. |
int |
size() Returns the number of elements in this List. |
java.lang.Object[] |
toArray() Returns an array containing all of the elements in this List in the order that the elements occur in the List. |
java.lang.Object[] |
toArray(java.lang.Object[] a) Returns an array with a runtime type is that of the specified array and that contains all of the elements in this List. |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
isEmpty, removeAll, retainAll, toString |
Methods inherited from interface java.util.List |
---|
equals, hashCode, isEmpty, iterator, listIterator, listIterator, removeAll, retainAll, subList |
Field Detail |
---|
protected SafeLinkedList.Node m_head
protected SafeLinkedList.Node m_tail
protected volatile int m_cNodes
protected transient int m_iPos
protected transient SafeLinkedList.Node m_current
Constructor Detail |
---|
public SafeLinkedList()
public SafeLinkedList(java.util.Collection collection)
collection
- the Collection to fill this List fromMethod Detail |
---|
public int size()
synchronized(list) { int c = list.size() ... }
size
in interface java.util.Collection
size
in interface java.util.List
size
in class java.util.AbstractCollection
public boolean add(java.lang.Object o)
add
in interface java.util.Collection
add
in interface java.util.List
add
in class java.util.AbstractList
o
- element to be appended to this Listpublic boolean remove(java.lang.Object o)
remove
in interface java.util.Collection
remove
in interface java.util.List
remove
in class java.util.AbstractCollection
o
- element to be removed from this List, if presentpublic boolean contains(java.lang.Object o)
contains
in interface java.util.Collection
contains
in interface java.util.List
contains
in class java.util.AbstractCollection
o
- element whose presence in this List is to be testedpublic boolean containsAll(java.util.Collection collection)
containsAll
in interface java.util.Collection
containsAll
in interface java.util.List
containsAll
in class java.util.AbstractCollection
collection
- collection to be checked for containment in this ListAbstractCollection.contains(Object)
public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List
indexOf
in class java.util.AbstractList
o
- element to search for.public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List
lastIndexOf
in class java.util.AbstractList
o
- element to search for.public void add(int i, java.lang.Object o)
add
in interface java.util.List
add
in class java.util.AbstractList
i
- the index at which to insert the specified elemento
- element to be insertedjava.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()).public java.lang.Object remove(int i)
remove
in interface java.util.List
remove
in class java.util.AbstractList
i
- the index of the element to removedjava.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).public java.lang.Object get(int i)
get
in interface java.util.List
get
in class java.util.AbstractList
i
- the index of the element to returnjava.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).public java.lang.Object set(int i, java.lang.Object o)
set
in interface java.util.List
set
in class java.util.AbstractList
i
- the index of the element to replaceo
- the value to be stored at the specified positionjava.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size())public boolean addAll(int i, java.util.Collection collection)
addAll
in interface java.util.List
addAll
in class java.util.AbstractList
i
- the index at which insertion will occurcollection
- a collection whose elements are to be inserted into this Listjava.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()).public boolean addAll(java.util.Collection collection)
addAll
in interface java.util.Collection
addAll
in interface java.util.List
addAll
in class java.util.AbstractCollection
collection
- a collection whose elements are to be added to this ListAbstractCollection.add(Object)
public void clear()
clear
in interface java.util.Collection
clear
in interface java.util.List
clear
in class java.util.AbstractList
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
toArray
in interface java.util.List
toArray
in class java.util.AbstractCollection
Arrays.asList(Object[])
public java.lang.Object[] toArray(java.lang.Object[] a)
If the List fits in the specified array with room to spare (i.e., the array has more elements than the List), the element in the array immediately following the end of the last element is set to null. This is useful in determining the length of the List only if the caller knows that the List does not contain any null elements.)
toArray
in interface java.util.Collection
toArray
in interface java.util.List
toArray
in class java.util.AbstractCollection
a
- the array into which the elements of the List are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purposejava.lang.ArrayStoreException
- if the runtime type of the specified array is not a supertype of the runtime type of every element in this Listpublic java.lang.Object clone()
protected void markPosition(int i, SafeLinkedList.Node node)
i
- the index; the marker is updated only if the index is greater than zero and less than size() - 1node
- the Nodeprotected void reset()
protected SafeLinkedList.Node instantiateNode(java.lang.Object o)
o
- the value for the Nodeprotected SafeLinkedList.Node getNode(int i)
i
- the Node indexjava.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()).public static void main(java.lang.String[] asArg) throws java.lang.Exception
java.lang.Exception
|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |