public class CopyOnWriteLongArray<V> extends com.oracle.common.collections.CopyOnWriteLongArray<V> implements LongArray<V>
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
CopyOnWriteLongArray.UnmodifiableIterator<V> |
LongArray.Iterator<V>| Constructor and Description |
|---|
CopyOnWriteLongArray()
Default constructor.
|
CopyOnWriteLongArray(Class clazz)
Construct a CopyOnWriteLongArray with an underlying array of the specified
type.
|
CopyOnWriteLongArray(com.oracle.common.collections.LongArray array)
Construct a CopyOnWriteLongArray, initialized with the contents of the
specified LongArray.
|
| Modifier and Type | Method and Description |
|---|---|
com.oracle.common.collections.LongArray.Iterator<V> |
instantiateUnmodifiableIterator(com.oracle.common.collections.LongArray.Iterator iterator)
Factory pattern: instantiate an UnmodifiableIterator.
|
LongArray.Iterator<V> |
iterator()
Obtain a LongArray.Iterator of the contents of the LongArray in
order of increasing indices.
|
LongArray.Iterator<V> |
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. |
LongArray.Iterator<V> |
reverseIterator()
Obtain a LongArray.Iterator of the contents of the LongArray in
reverse order (decreasing indices).
|
LongArray.Iterator<V> |
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. |
add, clear, clone, copyArray, delegate, remove, remove, set, setDelegateceiling, ceilingIndex, contains, exists, floor, floorIndex, get, getFirstIndex, getLastIndex, getSize, indexOf, indexOf, isEmpty, lastIndexOf, lastIndexOfequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, ceiling, ceilingIndex, clear, clone, contains, equals, exists, floor, floorIndex, get, getFirstIndex, getLastIndex, getSize, indexOf, indexOf, isEmpty, keys, lastIndexOf, lastIndexOf, remove, remove, set, toStringforEach, spliteratorpublic CopyOnWriteLongArray()
public CopyOnWriteLongArray(Class clazz) throws IllegalAccessException, InstantiationException
clazz - the type of the internal array; must implement LongArray
and have a public no-arg constructorClassCastException - if the specified type does not implement
LongArrayIllegalAccessException - if the class or its no-arg constructor is
not accessibleInstantiationException - 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(com.oracle.common.collections.LongArray array)
array - the initial LongArraypublic LongArray.Iterator<V> iterator()
com.oracle.common.collections.CopyOnWriteLongArraypublic LongArray.Iterator<V> iterator(long lIndex)
com.oracle.common.collections.CopyOnWriteLongArraynext 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.public LongArray.Iterator<V> reverseIterator()
com.oracle.common.collections.CopyOnWriteLongArraypublic LongArray.Iterator<V> reverseIterator(long lIndex)
com.oracle.common.collections.CopyOnWriteLongArraynext 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.public com.oracle.common.collections.LongArray.Iterator<V> instantiateUnmodifiableIterator(com.oracle.common.collections.LongArray.Iterator iterator)
com.oracle.common.collections.CopyOnWriteLongArrayinstantiateUnmodifiableIterator in class com.oracle.common.collections.CopyOnWriteLongArray<V>iterator - the underlying iterator