|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.concurrent.CopyOnWriteArrayList<E>
public class CopyOnWriteArrayList<E>
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
CopyOnWriteArrayList()
Construct a new ArrayList with the default capacity (16). |
|
CopyOnWriteArrayList(Collection<? extends E> c)
Construct a new ArrayList, and initialize it with the elements in the supplied Collection. |
|
CopyOnWriteArrayList(E[] array)
Construct a new ArrayList, and initialize it with the elements in the supplied array. |
Method Summary | ||
---|---|---|
boolean |
add(E e)
Appends the supplied element to the end of this list. |
|
void |
add(int index,
E e)
Adds the supplied element at the specified index, shifting all elements currently at that index or higher one to the right. |
|
boolean |
addAll(Collection<? extends E> c)
Add each element in the supplied Collection to this List. |
|
boolean |
addAll(int index,
Collection<? extends E> c)
Add all elements in the supplied collection, inserting them beginning at the specified index. c can contain objects of any type, as well as null values. |
|
int |
addAllAbsent(Collection<? extends E> c)
|
|
boolean |
addIfAbsent(E val)
|
|
void |
clear()
Removes all elements from this List |
|
Object |
clone()
Creates a shallow copy of this ArrayList (elements are not cloned). |
|
boolean |
contains(Object e)
Returns true iff element is in this ArrayList. |
|
E |
get(int index)
Retrieves the element at the user-supplied index. |
|
int |
indexOf(E e,
int index)
Return the lowest index greater equal index at which
e appears in this List, or -1 if it does not
appear. |
|
int |
indexOf(Object e)
Returns the lowest index at which element appears in this List, or -1 if it does not appear. |
|
boolean |
isEmpty()
Checks if the list is empty. |
|
int |
lastIndexOf(E e,
int index)
Returns the highest index lesser equal index at
which e appears in this List, or -1 if it does not
appear. |
|
int |
lastIndexOf(Object e)
Returns the highest index at which element appears in this List, or -1 if it does not appear. |
|
E |
remove(int index)
Removes the element at the user-supplied index. |
|
E |
set(int index,
E e)
Sets the element at the specified index. |
|
int |
size()
Returns the number of elements in this list. |
|
Object[] |
toArray()
Returns an Object array containing all of the elements in this ArrayList. |
|
|
toArray(T[] a)
Returns an Array whose component type is the runtime component type of the passed-in Array. |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, remove, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList |
Constructor Detail |
---|
public CopyOnWriteArrayList()
public CopyOnWriteArrayList(Collection<? extends E> c)
c
- the collection whose elements will initialize this list
NullPointerException
- if c is nullpublic CopyOnWriteArrayList(E[] array)
array
- the array used to initialize this list
NullPointerException
- if array is nullMethod Detail |
---|
public int size()
size
in interface Collection<E>
size
in interface List<E>
size
in class AbstractCollection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in interface List<E>
isEmpty
in class AbstractCollection<E>
AbstractCollection.size()
public boolean contains(Object e)
contains
in interface Collection<E>
contains
in interface List<E>
contains
in class AbstractCollection<E>
e
- the element whose inclusion in the List is being tested
public int indexOf(Object e)
indexOf
in interface List<E>
indexOf
in class AbstractList<E>
e
- the element whose inclusion in the List is being tested
public int indexOf(E e, int index)
index
at which
e
appears in this List, or -1 if it does not
appear.
e
- the element whose inclusion in the list is being testedindex
- the index at which the search begins
e
was foundpublic int lastIndexOf(Object e)
lastIndexOf
in interface List<E>
lastIndexOf
in class AbstractList<E>
e
- the element whose inclusion in the List is being tested
public int lastIndexOf(E e, int index)
index
at
which e
appears in this List, or -1 if it does not
appear.
e
- the element whose inclusion in the list is being testedindex
- the index at which the search begins
e
was foundpublic Object clone()
clone
in class Object
Cloneable
public Object[] toArray()
toArray
in interface Collection<E>
toArray
in interface List<E>
toArray
in class AbstractCollection<E>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<E>
toArray
in interface List<E>
toArray
in class AbstractCollection<E>
a
- the passed-in Array
ArrayStoreException
- if the runtime type of a does not allow an element in this list
NullPointerException
- if a is nullpublic E get(int index)
get
in interface List<E>
get
in class AbstractList<E>
index
- the index of the element we are fetching
IndexOutOfBoundsException
- if index < 0 || index >= size()public E set(int index, E e)
set
in interface List<E>
set
in class AbstractList<E>
index
- the index at which the element is being sete
- the element to be set
IndexOutOfBoundsException
- if index < 0 || index >= 0public boolean add(E e)
add
in interface Collection<E>
add
in interface List<E>
add
in class AbstractList<E>
e
- the element to be appended to this list
AbstractList.add(int, Object)
public void add(int index, E e)
add
in interface List<E>
add
in class AbstractList<E>
index
- the index at which the element is being addede
- the item being added
IndexOutOfBoundsException
- if index < 0 || index > size()AbstractList.modCount
public E remove(int index)
remove
in interface List<E>
remove
in class AbstractList<E>
index
- the index of the element to be removed
IndexOutOfBoundsException
- if index < 0 || index >= size()AbstractList.modCount
public void clear()
clear
in interface Collection<E>
clear
in interface List<E>
clear
in class AbstractList<E>
AbstractList.remove(int)
,
AbstractList.removeRange(int, int)
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in interface List<E>
addAll
in class AbstractCollection<E>
c
- a Collection containing elements to be added to this List
NullPointerException
- if c is nullAbstractCollection.add(Object)
public boolean addAll(int index, Collection<? extends E> c)
addAll
in interface List<E>
addAll
in class AbstractList<E>
index
- the index at which the elements will be insertedc
- the Collection containing the elements to be inserted
IndexOutOfBoundsException
- if index < 0 || index > 0
NullPointerException
- if c is nullAbstractList.add(int, Object)
public boolean addIfAbsent(E val)
public int addAllAbsent(Collection<? extends E> c)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |