java.lang.Object | |
↳ | com.pnfsoftware.jeb.util.collect.ConcurrentList<T> |
A concurrent version of ArrayList. Unlike CopyOnWriteArrayList, only
iterator-returning operations return defensive copies. Other write operations (addition,
insertion, deletion) do not generate defensive copies. Also contains safe
versions of
add/set/get for convenience. Performing much better than CopyOnWriteArrayList if write
operations are frequent; get() operations are slightly slower than
CopyOnWriteArrayList's, so if they make up the majority of the invocations,
CopyOnWriteArrayList remains the best option.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ConcurrentList() | |||||||||||
ConcurrentList(int initialCapacity) | |||||||||||
ConcurrentList(ArrayList<T> list) |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean | add(T element) | ||||||||||
void |
add(int index, T element)
May raise ArrayIndexOutOfBoundsException if index is greater than the list's size by
the time the lock is acquired.
| ||||||||||
boolean |
addAll(int index, Collection<? extends T> c)
May raise ArrayIndexOutOfBoundsException if index is greater than the list's size by
the time the lock is acquired.
| ||||||||||
boolean | addAll(Collection<? extends T> c) | ||||||||||
boolean | addSafe(int index, T element) | ||||||||||
void | clear() | ||||||||||
boolean | contains(Object o) | ||||||||||
boolean | containsAll(Collection<?> c) | ||||||||||
boolean | equals(Object obj) | ||||||||||
T |
get(int index)
May raise ArrayIndexOutOfBoundsException if index is greater or equals than the
list's size by the time the lock is acquired.
| ||||||||||
T | getSafe(int index, T valueIfPastBound) | ||||||||||
int | hashCode() | ||||||||||
int | indexOf(Object o) | ||||||||||
boolean | isEmpty() | ||||||||||
Iterator<T> |
iterator()
Returns an iterator that will iterate over a defensive copy.
| ||||||||||
int | lastIndexOf(Object o) | ||||||||||
ListIterator<T> |
listIterator(int index)
Returns a list iterator that will iterate over a defensive copy.
| ||||||||||
ListIterator<T> |
listIterator()
Returns a list iterator that will iterate over a defensive copy.
| ||||||||||
T |
remove(int index)
May raise ArrayIndexOutOfBoundsException if index is greater or equals than the
list's size by the time the lock is acquired.
| ||||||||||
boolean | remove(Object o) | ||||||||||
boolean | removeAll(Collection<?> c) | ||||||||||
boolean | removeSafe(int index) | ||||||||||
boolean | retainAll(Collection<?> c) | ||||||||||
T |
set(int index, T element)
May raise ArrayIndexOutOfBoundsException if index is greater or equals than the
list's size by the time the lock is acquired.
| ||||||||||
boolean | setSafe(int index, T element) | ||||||||||
int | size() | ||||||||||
List<T> |
subList(int fromIndex, int toIndex)
Returns a defensive copy.
| ||||||||||
Object[] | toArray() | ||||||||||
<U> U[] | toArray(U[] a) | ||||||||||
String | toString() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Iterable
| |||||||||||
From interface
java.util.Collection
| |||||||||||
From interface
java.util.List
|
May raise ArrayIndexOutOfBoundsException if index is greater than the list's size by
the time the lock is acquired. Safe version: addSafe(int, Object)
.
May raise ArrayIndexOutOfBoundsException if index is greater than the list's size by the time the lock is acquired.
May raise ArrayIndexOutOfBoundsException if index is greater or equals than the
list's size by the time the lock is acquired. Safe version: getSafe(int, Object)
.
Returns an iterator that will iterate over a defensive copy. Modification operations will not impact the original list.
Returns a list iterator that will iterate over a defensive copy. Modification operations will not impact the original list.
Returns a list iterator that will iterate over a defensive copy. Modification operations will not impact the original list.
May raise ArrayIndexOutOfBoundsException if index is greater or equals than the
list's size by the time the lock is acquired. Safe version: removeSafe(int)
.
May raise ArrayIndexOutOfBoundsException if index is greater or equals than the
list's size by the time the lock is acquired. Safe version: setSafe(int, Object)
.
Returns a defensive copy. Modification operations will not impact the original list.