|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-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(Collection collection) Construct a List containing the elements of the specified Collection. |
Method Summary | |
---|---|
void |
add(int i, Object o) Inserts the specified element at the specified position in this List. |
boolean |
add(Object o) Appends the specified element to the end of this List. |
boolean |
addAll(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, 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. |
Object |
clone() Create a clone of the SafeLinkedList. |
boolean |
contains(Object o) Returns true if this List contains the specified element. |
boolean |
containsAll(Collection collection) Returns true if this List contains all of the elements of the specified collection. |
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(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(Object o) Instantiate a Node. |
int |
lastIndexOf(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(String[] asArg) Self-test for SafeLinkedList. |
protected void |
markPosition(int i, SafeLinkedList.Node node) Remember that a certain Node occurs at a certain index. |
Object |
remove(int i) Removes the element at the specified position in this List. |
boolean |
remove(Object o) Removes the first occurrence in this List of the specified element. |
protected void |
reset() Completely reset the state of the List. |
Object |
set(int i, 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. |
Object[] |
toArray() Returns an array containing all of the elements in this List in the order that the elements occur in the List. |
Object[] |
toArray(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(Collection collection)
collection
- the Collection to fill this List fromMethod Detail |
---|
public int size()
synchronized(list) { int c = list.size() ... }
size
in interface Collection
size
in interface List
size
in class AbstractCollection
public boolean add(Object o)
add
in interface Collection
add
in interface List
add
in class AbstractList
o
- element to be appended to this Listpublic boolean remove(Object o)
remove
in interface Collection
remove
in interface List
remove
in class AbstractCollection
o
- element to be removed from this List, if presentpublic boolean contains(Object o)
contains
in interface Collection
contains
in interface List
contains
in class AbstractCollection
o
- element whose presence in this List is to be testedpublic boolean containsAll(Collection collection)
containsAll
in interface Collection
containsAll
in interface List
containsAll
in class AbstractCollection
collection
- collection to be checked for containment in this ListAbstractCollection.contains(Object)
public int indexOf(Object o)
indexOf
in interface List
indexOf
in class AbstractList
o
- element to search for.public int lastIndexOf(Object o)
lastIndexOf
in interface List
lastIndexOf
in class AbstractList
o
- element to search for.public void add(int i, Object o)
add
in interface List
add
in class AbstractList
i
- the index at which to insert the specified elemento
- element to be insertedIndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()).public Object remove(int i)
remove
in interface List
remove
in class AbstractList
i
- the index of the element to removedIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).public Object get(int i)
get
in interface List
get
in class AbstractList
i
- the index of the element to returnIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).public Object set(int i, Object o)
set
in interface List
set
in class AbstractList
i
- the index of the element to replaceo
- the value to be stored at the specified positionIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size())public boolean addAll(int i, Collection collection)
addAll
in interface List
addAll
in class AbstractList
i
- the index at which insertion will occurcollection
- a collection whose elements are to be inserted into this ListIndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()).public boolean addAll(Collection collection)
addAll
in interface Collection
addAll
in interface List
addAll
in class AbstractCollection
collection
- a collection whose elements are to be added to this ListAbstractCollection.add(Object)
public void clear()
clear
in interface Collection
clear
in interface List
clear
in class AbstractList
public Object[] toArray()
toArray
in interface Collection
toArray
in interface List
toArray
in class AbstractCollection
Arrays.asList(Object[])
public Object[] toArray(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 Collection
toArray
in interface List
toArray
in class 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 purposeArrayStoreException
- if the runtime type of the specified array is not a supertype of the runtime type of every element in this Listpublic 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(Object o)
o
- the value for the Nodeprotected SafeLinkedList.Node getNode(int i)
i
- the Node indexIndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()).public static void main(String[] asArg) throws Exception
Exception
|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |