|
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
com.tangosol.util.CopyOnWriteLongArray
public class CopyOnWriteLongArray
A thread-safe variant of LongArray
in which all mutating operations (e.g. add, set) are implemented by making a fresh copy of the underlying array.
Iterators over this LongArray are guaranteed to produce a safe-iteration and not to throw ConcurrentModificationException. The iterator will not reflect concurrent additions, removals, or changes to this array. Mutating operations on iterators themselves (e.g. remove, setValue) are not supported (and will throw UnsupportedOperationException).
Note: mutations on this LongArray are costly, but may be more efficient than alternatives when traversal operations vastly outnumber mutations. All mutating operations are synchronized, so concurrent mutation can be prevented by holding synchronization on this object.
Nested Class Summary | |
---|---|
static class |
CopyOnWriteLongArray.UnmodifiableIterator Unmodifiable view of a LongArray.Iterator. |
Nested classes/interfaces inherited from interface com.tangosol.util.LongArray |
---|
LongArray.Iterator |
Field Summary | |
---|---|
protected static LongArray |
EMPTY_ARRAY An empty placeholder array. |
Fields inherited from interface com.tangosol.util.LongArray |
---|
NOT_FOUND |
Constructor Summary | |
---|---|
CopyOnWriteLongArray() Default constructor. |
|
CopyOnWriteLongArray(java.lang.Class clazz) Construct a CopyOnWriteLongArray with an underlying array of the specified type. |
|
CopyOnWriteLongArray(LongArray array) Construct a CopyOnWriteLongArray, initialized with the contents of the specified LongArray. |
Method Summary | |
---|---|
long |
add(java.lang.Object oValue) Add the passed element value to the LongArray and return the index at which the element value was stored. |
void |
clear() Remove all nodes from the LongArray. |
java.lang.Object |
clone() Make a clone of the LongArray. |
boolean |
contains(java.lang.Object oValue) Determine if the LongArray contains the specified element. |
LongArray |
copyArray(LongArray array) Return a shallow copy of the specified LongArray. |
boolean |
exists(long lIndex) Determine if the specified index is in use. |
java.lang.Object |
get(long lIndex) Return the value stored at the specified index. |
long |
getFirstIndex() Determine the first index that exists in the LongArray. |
protected LongArray |
getInternalArray() Return the internal LongArray. |
long |
getLastIndex() Determine the last index that exists in the LongArray. |
int |
getSize() Determine the size of the LongArray. |
long |
indexOf(java.lang.Object oValue) Return the index in this LongArray of the first occurrence of the specified element, or NOT_FOUND if this LongArray does not contain the specified element. |
long |
indexOf(java.lang.Object oValue, long lIndex) Return the index in this LongArray of the first occurrence of the specified element such that (index >= lIndex), or NOT_FOUND if this LongArray does not contain the specified element. |
LongArray.Iterator |
instantiateUnmodifiableIterator(LongArray.Iterator iterator) Factory pattern: instantiate an UnmodifiableIterator. |
boolean |
isEmpty() Test for empty LongArray. |
LongArray.Iterator |
iterator() Obtain a LongArray.Iterator of the contents of the LongArray in order of increasing indices. |
LongArray.Iterator |
iterator(long lIndex) Obtain a LongArray.Iterator of the contents of the LongArray in order of increasing indices, starting at a particular index such that the first call to next will set the location of the iterator at the first existent index that is greater than or equal to the specified index, or will throw a NoSuchElementException if there is no such existent index. |
long |
lastIndexOf(java.lang.Object oValue) Return the index in this LongArray of the last occurrence of the specified element, or NOT_FOUND if this LongArray does not contain the specified element. |
long |
lastIndexOf(java.lang.Object oValue, long lIndex) Return the index in this LongArray of the last occurrence of the specified element such that (index <= lIndex), or NOT_FOUND if this LongArray does not contain the specified element. |
java.lang.Object |
remove(long lIndex) Remove the specified index from the LongArray, returning its associated value. |
LongArray.Iterator |
reverseIterator() Obtain a LongArray.Iterator of the contents of the LongArray in reverse order (decreasing indices). |
LongArray.Iterator |
reverseIterator(long lIndex) Obtain a LongArray.Iterator of the contents of the LongArray in reverse order (decreasing indices), starting at a particular index such that the first call to next will set the location of the iterator at the first existent index that is less than or equal to the specified index, or will throw a NoSuchElementException if there is no such existent index. |
java.lang.Object |
set(long lIndex, java.lang.Object oValue) Add the passed item to the LongArray at the specified index. |
protected void |
setInternalArray(LongArray array) Set the internal LongArray. |
Methods inherited from interface com.tangosol.util.LongArray |
---|
equals, toString |
Field Detail |
---|
protected static final LongArray EMPTY_ARRAY
Constructor Detail |
---|
public CopyOnWriteLongArray()
public CopyOnWriteLongArray(java.lang.Class clazz) throws java.lang.IllegalAccessException, java.lang.InstantiationException
clazz
- the type of the internal array; must implement LongArray and have a public no-arg constructorjava.lang.ClassCastException
- if the specified type does not implement LongArrayjava.lang.IllegalAccessException
- if the class or its no-arg constructor is not accessiblejava.lang.InstantiationException
- if the specified Class represents an abstract class or interface; or if the class does not have a no-arg constructor; or if the instantiation fails for some other reason.public CopyOnWriteLongArray(LongArray array)
array
- the initial LongArrayMethod Detail |
---|
protected LongArray getInternalArray()
protected void setInternalArray(LongArray array)
array
- the new internal LongArraypublic LongArray copyArray(LongArray array)
array
- the array to be copiedpublic java.lang.Object get(long lIndex)
get
in interface LongArray
lIndex
- a long index valuepublic java.lang.Object set(long lIndex, java.lang.Object oValue)
If the index is already used, the passed value will replace the current value stored with the key, and the replaced value will be returned.
It is expected that LongArray implementations will "grow" as necessary to support the specified index.
set
in interface LongArray
lIndex
- a long index valueoValue
- the object to store at the specified indexpublic long add(java.lang.Object oValue)
add
in interface LongArray
oValue
- the object to add to the LongArraypublic boolean exists(long lIndex)
exists
in interface LongArray
lIndex
- a long index valuepublic java.lang.Object remove(long lIndex)
remove
in interface LongArray
lIndex
- the index into the LongArraypublic boolean contains(java.lang.Object oValue)
More formally, returns true if and only if this LongArray contains at least one element e such that (o==null ? e==null : o.equals(e)).
contains
in interface LongArray
oValue
- element whose presence in this list is to be testedpublic void clear()
clear
in interface LongArray
public boolean isEmpty()
isEmpty
in interface LongArray
public int getSize()
getSize
in interface LongArray
public LongArray.Iterator iterator()
iterator
in interface LongArray
public LongArray.Iterator iterator(long lIndex)
iterator
in interface LongArray
lIndex
- the LongArray index to iterate frompublic LongArray.Iterator reverseIterator()
reverseIterator
in interface LongArray
public LongArray.Iterator reverseIterator(long lIndex)
reverseIterator
in interface LongArray
lIndex
- the LongArray index to iterate frompublic long getFirstIndex()
getFirstIndex
in interface LongArray
public long getLastIndex()
getLastIndex
in interface LongArray
public long indexOf(java.lang.Object oValue)
indexOf
in interface LongArray
public long indexOf(java.lang.Object oValue, long lIndex)
indexOf
in interface LongArray
public long lastIndexOf(java.lang.Object oValue)
lastIndexOf
in interface LongArray
public long lastIndexOf(java.lang.Object oValue, long lIndex)
lastIndexOf
in interface LongArray
public java.lang.Object clone()
clone
in interface LongArray
public LongArray.Iterator instantiateUnmodifiableIterator(LongArray.Iterator iterator)
iterator
- the underlying iterator
|
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 |