|
Build 1.0_r1(from source) | |||||||||
| 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.ArrayList<E>
public class ArrayList<E>
ArrayList is an implementation of List, backed by an array. All optional operations are supported, adding, removing, and replacing. The elements can be any objects.
| Field Summary |
|---|
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
ArrayList()
Constructs a new instance of ArrayList with zero capacity. |
|
ArrayList(Collection<? extends E> collection)
Constructs a new instance of ArrayList containing the elements in the specified collection. |
|
ArrayList(int capacity)
Constructs a new instance of ArrayList with the specified capacity. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(E object)
Adds the specified object at the end of this ArrayList. |
|
void |
add(int location,
E object)
Inserts the specified object into this ArrayList at the specified location. |
|
boolean |
addAll(Collection<? extends E> collection)
Adds the objects in the specified Collection to this ArrayList. |
|
boolean |
addAll(int location,
Collection<? extends E> collection)
Inserts the objects in the specified Collection at the specified location in this ArrayList. |
|
void |
clear()
Removes all elements from this ArrayList, leaving it empty. |
|
Object |
clone()
Returns a new ArrayList with the same elements, size and capacity as this ArrayList. |
|
boolean |
contains(Object object)
Searches this ArrayList for the specified object. |
|
void |
ensureCapacity(int minimumCapacity)
Ensures that this ArrayList can hold the specified number of elements without growing. |
|
E |
get(int location)
Returns the element at the specified location in this ArrayList. |
|
int |
indexOf(Object object)
Searches this ArrayList for the specified object and returns the index of the first occurrence. |
|
boolean |
isEmpty()
Returns if this ArrayList has no elements, a size of zero. |
|
int |
lastIndexOf(Object object)
Searches this ArrayList for the specified object and returns the index of the last occurrence. |
|
E |
remove(int location)
Removes the object at the specified location from this ArrayList. |
|
boolean |
remove(Object object)
Removes the first occurrence of the specified object from this Collection. |
|
protected void |
removeRange(int start,
int end)
Removes the objects in the specified range from the start to the end, but not including the end index. |
|
E |
set(int location,
E object)
Replaces the element at the specified location in this ArrayList with the specified object. |
|
int |
size()
Returns the number of elements in this ArrayList. |
|
Object[] |
toArray()
Returns a new array containing all elements contained in this ArrayList. |
|
|
toArray(T[] contents)
Returns an array containing all elements contained in this ArrayList. |
|
void |
trimToSize()
Sets the capacity of this ArrayList to be the same as the size. |
|
| Methods inherited from class java.util.AbstractList |
|---|
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, 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, removeAll, retainAll, subList |
| Constructor Detail |
|---|
public ArrayList()
public ArrayList(int capacity)
capacity - the initial capacity of this ArrayListpublic ArrayList(Collection<? extends E> collection)
collection - the collection of elements to add| Method Detail |
|---|
public void add(int location,
E object)
add in interface List<E>add in class AbstractList<E>location - the index at which to insertobject - the object to add
IndexOutOfBoundsException - when location < 0 || >= size()public boolean add(E object)
add in interface Collection<E>add in interface List<E>add in class AbstractList<E>object - the object to add
public boolean addAll(int location,
Collection<? extends E> collection)
addAll in interface List<E>addAll in class AbstractList<E>location - the index at which to insertcollection - the Collection of objects
IndexOutOfBoundsException - when
location < 0 || > size()public boolean addAll(Collection<? extends E> collection)
addAll in interface Collection<E>addAll in interface List<E>addAll in class AbstractCollection<E>collection - the Collection of objects
public void clear()
clear in interface Collection<E>clear in interface List<E>clear in class AbstractList<E>isEmpty(),
size()public Object clone()
clone in class ObjectCloneablepublic boolean contains(Object object)
contains in interface Collection<E>contains in interface List<E>contains in class AbstractCollection<E>object - the object to search for
object is an element of this ArrayList,
false otherwisepublic void ensureCapacity(int minimumCapacity)
minimumCapacity - the minimum number of elements that this ArrayList will hold
before growingpublic E get(int location)
get in interface List<E>get in class AbstractList<E>location - the index of the element to return
IndexOutOfBoundsException - when location < 0 || >= size()public int indexOf(Object object)
indexOf in interface List<E>indexOf in class AbstractList<E>object - the object to search for
public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface List<E>isEmpty in class AbstractCollection<E>size()public int lastIndexOf(Object object)
lastIndexOf in interface List<E>lastIndexOf in class AbstractList<E>object - the object to search for
public E remove(int location)
remove in interface List<E>remove in class AbstractList<E>location - the index of the object to remove
IndexOutOfBoundsException - when location < 0 || >= size()public boolean remove(Object object)
AbstractCollection
remove in interface Collection<E>remove in interface List<E>remove in class AbstractCollection<E>object - the object to remove
protected void removeRange(int start,
int end)
removeRange in class AbstractList<E>start - the index at which to start removingend - the index one past the end of the range to remove
IndexOutOfBoundsException - when start < 0, start > end or
end > size()
public E set(int location,
E object)
set in interface List<E>set in class AbstractList<E>location - the index at which to put the specified objectobject - the object to add
IndexOutOfBoundsException - when location < 0 || >= size()public int size()
size in interface Collection<E>size in interface List<E>size in class AbstractCollection<E>public Object[] toArray()
toArray in interface Collection<E>toArray in interface List<E>toArray in class AbstractCollection<E>public <T> T[] toArray(T[] contents)
toArray in interface Collection<E>toArray in interface List<E>toArray in class AbstractCollection<E>contents - the array
ArrayStoreException - when the type of an element in this ArrayList cannot be
stored in the type of the specified arraypublic void trimToSize()
size()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||