public class

ConcurrentList

extends Object
implements List<E>
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.collect.ConcurrentList<T>

Class Overview

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.

Summary

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

Public Constructors

public ConcurrentList ()

public ConcurrentList (int initialCapacity)

public ConcurrentList (ArrayList<T> list)

Public Methods

public boolean add (T element)

public 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. Safe version: addSafe(int, Object).

public 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.

public boolean addAll (Collection<? extends T> c)

public boolean addSafe (int index, T element)

public void clear ()

public boolean contains (Object o)

public boolean containsAll (Collection<?> c)

public boolean equals (Object obj)

public 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. Safe version: getSafe(int, Object).

public T getSafe (int index, T valueIfPastBound)

public int hashCode ()

public int indexOf (Object o)

public boolean isEmpty ()

public Iterator<T> iterator ()

Returns an iterator that will iterate over a defensive copy. Modification operations will not impact the original list.

public int lastIndexOf (Object o)

public ListIterator<T> listIterator (int index)

Returns a list iterator that will iterate over a defensive copy. Modification operations will not impact the original list.

public ListIterator<T> listIterator ()

Returns a list iterator that will iterate over a defensive copy. Modification operations will not impact the original list.

public 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. Safe version: removeSafe(int).

public boolean remove (Object o)

public boolean removeAll (Collection<?> c)

public boolean removeSafe (int index)

public boolean retainAll (Collection<?> c)

public 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. Safe version: setSafe(int, Object).

public boolean setSafe (int index, T element)

public int size ()

public List<T> subList (int fromIndex, int toIndex)

Returns a defensive copy. Modification operations will not impact the original list.

public Object[] toArray ()

public U[] toArray (U[] a)

public String toString ()