# Class: com.pnfsoftware.jeb.util.collect.ConcurrentList

A concurrent version of [ArrayList](ArrayList). Unlike [CopyOnWriteArrayList](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](CopyOnWriteArrayList) if write operations are frequent; get\(\) operations are slightly slower than [CopyOnWriteArrayList](CopyOnWriteArrayList)'s, so if they make up the majority of the invocations, [CopyOnWriteArrayList](CopyOnWriteArrayList) remains the best option.

## Constructor: ConcurrentList

Description: Create an empty concurrent list.

## Constructor: ConcurrentList
- parameter: `initialCapacity`, type: `int`

Description: Create an empty concurrent list.
parameter: initialCapacity: initial capacity

## Constructor: ConcurrentList
- parameter: `collection`, type: `java.util.Collection<? extends T>`

Description: Create a concurrent list initialized from a collection.
parameter: collection: source collection

## Method: add
- parameter: `index`, type: `int`
- parameter: `element`, type: `T`

Description: May raise [ArrayIndexOutOfBoundsException](ArrayIndexOutOfBoundsException) if index is greater than the list's size by the time the lock is acquired. Safe version: [#addSafe(int, Object)](#addSafe(int, Object)).

## Method: add
- parameter: `element`, type: `T`
- return type: `boolean`


## Method: addAll
- parameter: `c`, type: `java.util.Collection<? extends T>`
- return type: `boolean`


## Method: addAll
- parameter: `index`, type: `int`
- parameter: `c`, type: `java.util.Collection<? extends T>`
- return type: `boolean`

Description: May raise [ArrayIndexOutOfBoundsException](ArrayIndexOutOfBoundsException) if index is greater than the list's size by the time the lock is acquired.

## Method: addSafe
- parameter: `index`, type: `int`
- parameter: `element`, type: `T`
- return type: `boolean`

Description: Safely insert an element.
parameter: index: insertion index
parameter: element: element to insert
return: true if the element was inserted

## Method: clear


## Method: contains
- parameter: `o`, type: `java.lang.Object`
- return type: `boolean`


## Method: containsAll
- parameter: `c`, type: `java.util.Collection<?>`
- return type: `boolean`


## Method: equals
- parameter: `obj`, type: `java.lang.Object`
- return type: `boolean`


## Method: get
- parameter: `index`, type: `int`
- return type: `T`

Description: May raise [ArrayIndexOutOfBoundsException](ArrayIndexOutOfBoundsException) if index is greater or equals than the list's size by the time the lock is acquired. Safe version: [#getSafe(int, Object)](#getSafe(int, Object)).

## Method: getSafe
- parameter: `index`, type: `int`
- parameter: `valueIfPastBound`, type: `T`
- return type: `T`

Description: Safely retrieve an element.
parameter: index: element index
parameter: valueIfPastBound: value returned if the index is past the current end
return: element at the index, or `valueIfPastBound`

## Method: hashCode
- return type: `int`


## Method: indexOf
- parameter: `o`, type: `java.lang.Object`
- return type: `int`


## Method: isEmpty
- return type: `boolean`


## Method: iterator
- return type: `java.util.Iterator<T>`

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

## Method: lastIndexOf
- parameter: `o`, type: `java.lang.Object`
- return type: `int`


## Method: listIterator
- return type: `java.util.ListIterator<T>`

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

## Method: listIterator
- parameter: `index`, type: `int`
- return type: `java.util.ListIterator<T>`

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

## Method: remove
- parameter: `o`, type: `java.lang.Object`
- return type: `boolean`


## Method: remove
- parameter: `index`, type: `int`
- return type: `T`

Description: May raise [ArrayIndexOutOfBoundsException](ArrayIndexOutOfBoundsException) if index is greater or equals than the list's size by the time the lock is acquired. Safe version: [#removeSafe(int)](#removeSafe(int)).

## Method: removeAll
- parameter: `c`, type: `java.util.Collection<?>`
- return type: `boolean`


## Method: removeSafe
- parameter: `index`, type: `int`
- return type: `boolean`

Description: Safely remove an element by index.
parameter: index: element index
return: true if an element was removed

## Method: retainAll
- parameter: `c`, type: `java.util.Collection<?>`
- return type: `boolean`


## Method: set
- parameter: `index`, type: `int`
- parameter: `element`, type: `T`
- return type: `T`

Description: May raise [ArrayIndexOutOfBoundsException](ArrayIndexOutOfBoundsException) if index is greater or equals than the list's size by the time the lock is acquired. Safe version: [#setSafe(int, Object)](#setSafe(int, Object)).

## Method: setSafe
- parameter: `index`, type: `int`
- parameter: `element`, type: `T`
- return type: `boolean`

Description: Safely set an element.
parameter: index: element index
parameter: element: replacement element
return: true if the element was set

## Method: size
- return type: `int`


## Method: subList
- parameter: `fromIndex`, type: `int`
- parameter: `toIndex`, type: `int`
- return type: `java.util.List<T>`

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

## Method: toArray
- return type: `java.lang.Object[]`


## Method: toArray
- parameter: `a`, type: `U[]`
- return type: `U[]`


## Method: toString
- return type: `java.lang.String`


