DthingApi
Classes | Public Member Functions | Protected Member Functions | List of all members
java.util.ArrayList< E > Class Template Reference
Inheritance diagram for java.util.ArrayList< E >:
java.util.AbstractList< E > java.util.List< E > java.io.Serializable java.util.RandomAccess java.util.AbstractCollection< E > java.util.List< E > java.util.Collection< E > java.util.Collection< E > java.util.Collection< E >

Public Member Functions

 ArrayList (int capacity)
 
 ArrayList ()
 
 ArrayList (Collection<? extends E > collection)
 
boolean add (E object)
 
void add (int index, E object)
 
boolean addAll (Collection<? extends E > collection)
 
boolean addAll (int index, Collection<? extends E > collection)
 
void clear ()
 
Object clone ()
 
void ensureCapacity (int minimumCapacity)
 
get (int index)
 
int size ()
 
boolean isEmpty ()
 
boolean contains (Object object)
 
int indexOf (Object object)
 
int lastIndexOf (Object object)
 
remove (int index)
 
boolean remove (Object object)
 
set (int index, E object)
 
Object [] toArray ()
 
void trimToSize ()
 
Iterator< E > iterator ()
 
int hashCode ()
 
boolean equals (Object o)
 
- Public Member Functions inherited from java.util.AbstractList< E >
void add (int location, E object)
 
boolean add (E object)
 
boolean addAll (int location, Collection<? extends E > collection)
 
void clear ()
 
boolean equals (Object object)
 
abstract E get (int location)
 
int hashCode ()
 
int indexOf (Object object)
 
Iterator< E > iterator ()
 
int lastIndexOf (Object object)
 
ListIterator< E > listIterator ()
 
ListIterator< E > listIterator (int location)
 
remove (int location)
 
set (int location, E object)
 
List< E > subList (int start, int end)
 
- Public Member Functions inherited from java.util.AbstractCollection< E >
boolean add (E object)
 
boolean addAll (Collection<? extends E > collection)
 
void clear ()
 
boolean contains (Object object)
 
boolean containsAll (Collection<?> collection)
 
boolean isEmpty ()
 
abstract Iterator< E > iterator ()
 
boolean remove (Object object)
 
boolean removeAll (Collection<?> collection)
 
boolean retainAll (Collection<?> collection)
 
abstract int size ()
 
Object [] toArray ()
 
String toString ()
 
- Public Member Functions inherited from java.util.List< E >
boolean containsAll (Collection<?> collection)
 
boolean removeAll (Collection<?> collection)
 
boolean retainAll (Collection<?> collection)
 

Protected Member Functions

void removeRange (int fromIndex, int toIndex)
 
- Protected Member Functions inherited from java.util.AbstractList< E >
 AbstractList ()
 
void removeRange (int start, int end)
 
- Protected Member Functions inherited from java.util.AbstractCollection< E >
 AbstractCollection ()
 

Additional Inherited Members

- Protected Attributes inherited from java.util.AbstractList< E >
transient int modCount
 

Detailed Description

ArrayList is an implementation of List, backed by an array. All optional operations including adding, removing, and replacing elements are supported.

All elements are permitted, including null.

This class is a good choice as your default

List

implementation. Vector synchronizes all operations, but not necessarily in a way that's meaningful to your application: synchronizing each call to

get

, for example, is not equivalent to synchronizing the list and iterating over it (which is probably what you intended). java.util.concurrent.CopyOnWriteArrayList is intended for the special case of very high concurrency, frequent traversals, and very rare mutations.

Parameters
<E>The element type of this list.
Since
1.2

Constructor & Destructor Documentation

◆ ArrayList() [1/3]

java.util.ArrayList< E >.ArrayList ( int  capacity)
inline

Constructs a new instance of

with the specified initial capacity.

Parameters
capacitythe initial capacity of this .

◆ ArrayList() [2/3]

java.util.ArrayList< E >.ArrayList ( )
inline

Constructs a new

instance with zero initial capacity.

◆ ArrayList() [3/3]

java.util.ArrayList< E >.ArrayList ( Collection<? extends E >  collection)
inline

Constructs a new instance of

containing the elements of the specified collection.

Parameters
collectionthe collection of elements to add.

Member Function Documentation

◆ add() [1/2]

boolean java.util.ArrayList< E >.add ( object)
inline

Adds the specified object at the end of this

.

Parameters
objectthe object to add.
Returns
always true

Implements java.util.List< E >.

◆ add() [2/2]

void java.util.ArrayList< E >.add ( int  index,
object 
)
inline

Inserts the specified object into this

at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this

, the object is added at the end.

Parameters
indexthe index at which to insert the object.
objectthe object to add.
Exceptions
IndexOutOfBoundsExceptionwhen
location < 0 || > size()

Implements java.util.List< E >.

◆ addAll() [1/2]

boolean java.util.ArrayList< E >.addAll ( Collection<? extends E >  collection)
inline

Adds the objects in the specified collection to this

.

Parameters
collectionthe collection of objects.
Returns
true
if this is modified,
false
otherwise.

Implements java.util.List< E >.

◆ addAll() [2/2]

boolean java.util.ArrayList< E >.addAll ( int  index,
Collection<? extends E >  collection 
)
inline

Inserts the objects in the specified collection at the specified location in this List. The objects are added in the order they are returned from the collection's iterator.

Parameters
indexthe index at which to insert.
collectionthe collection of objects.
Returns
true
if this is modified,
false
otherwise.
Exceptions
IndexOutOfBoundsExceptionwhen
location < 0 || > size()

Implements java.util.List< E >.

◆ clear()

void java.util.ArrayList< E >.clear ( )
inline

Removes all elements from this

, leaving it empty.

See also
isEmpty
#size

Implements java.util.List< E >.

◆ clone()

Object java.util.ArrayList< E >.clone ( )
inline

Returns a new

with the same elements, the same size and the same capacity as this

.

Returns
a shallow copy of this
See also
java.lang.Cloneable

◆ contains()

boolean java.util.ArrayList< E >.contains ( Object  object)
inline

Searches this

for the specified object.

Parameters
objectthe object to search for.
Returns
true
if
object
is an element of this ,
false
otherwise

Implements java.util.List< E >.

◆ ensureCapacity()

void java.util.ArrayList< E >.ensureCapacity ( int  minimumCapacity)
inline

Ensures that after this operation the

can hold the specified number of elements without further growing.

Parameters
minimumCapacitythe minimum capacity asked for.

◆ equals()

boolean java.util.ArrayList< E >.equals ( Object  object)
inline

Compares the given object with the

List

, and returns true if they represent the same object using a class specific comparison. For

List

s, this means that they contain the same elements in exactly the same order.

Parameters
objectthe object to compare with this object.
Returns
boolean
true
if the object is the same as this object, and
false
if it is different from this object.
See also
hashCode

Implements java.util.List< E >.

◆ get()

E java.util.ArrayList< E >.get ( int  location)
inline

Returns the element at the specified location in this

List

.

Parameters
locationthe index of the element to return.
Returns
the element at the specified location.
Exceptions
IndexOutOfBoundsExceptionif
location < 0 || >= size()

Implements java.util.List< E >.

◆ hashCode()

int java.util.ArrayList< E >.hashCode ( )
inline

Returns the hash code for this

List

. It is calculated by taking each element' hashcode and its position in the

List

into account.

Returns
the hash code of the
List
.

Implements java.util.List< E >.

◆ indexOf()

int java.util.ArrayList< E >.indexOf ( Object  object)
inline

Searches this

List

for the specified object and returns the index of the first occurrence.

Parameters
objectthe object to search for.
Returns
the index of the first occurrence of the object or -1 if the object was not found.

Implements java.util.List< E >.

◆ isEmpty()

boolean java.util.ArrayList< E >.isEmpty ( )
inline

Returns whether this

List

contains no elements.

Returns
true
if this
List
has no elements,
false
otherwise.
See also
#size

Implements java.util.List< E >.

◆ iterator()

Iterator<E> java.util.ArrayList< E >.iterator ( )
inline

Returns an iterator on the elements of this

List

. The elements are iterated in the same order as they occur in the

List

.

Returns
an iterator on the elements of this
List
.
See also
Iterator

Implements java.util.List< E >.

◆ lastIndexOf()

int java.util.ArrayList< E >.lastIndexOf ( Object  object)
inline

Searches this

List

for the specified object and returns the index of the last occurrence.

Parameters
objectthe object to search for.
Returns
the index of the last occurrence of the object, or -1 if the object was not found.

Implements java.util.List< E >.

◆ remove() [1/2]

E java.util.ArrayList< E >.remove ( int  index)
inline

Removes the object at the specified location from this list.

Parameters
indexthe index of the object to remove.
Returns
the removed object.
Exceptions
IndexOutOfBoundsExceptionwhen
location < 0 || >= size()

Implements java.util.List< E >.

◆ remove() [2/2]

boolean java.util.ArrayList< E >.remove ( Object  object)
inline

Removes the first occurrence of the specified object from this

List

.

Parameters
objectthe object to remove.
Returns
true if this
List
was modified by this operation, false otherwise.
Exceptions
UnsupportedOperationExceptionif removing from this
List
is not supported.

Implements java.util.List< E >.

◆ set()

E java.util.ArrayList< E >.set ( int  index,
object 
)
inline

Replaces the element at the specified location in this

with the specified object.

Parameters
indexthe index at which to put the specified object.
objectthe object to add.
Returns
the previous element at the index.
Exceptions
IndexOutOfBoundsExceptionwhen
location < 0 || >= size()

Implements java.util.List< E >.

◆ size()

int java.util.ArrayList< E >.size ( )
inline

Returns the number of elements in this

.

Returns
the number of elements in this .

Implements java.util.List< E >.

◆ toArray()

Object [] java.util.ArrayList< E >.toArray ( )
inline

Returns a new array containing all elements contained in this

.

Returns
an array of the elements from this

Implements java.util.List< E >.

◆ trimToSize()

void java.util.ArrayList< E >.trimToSize ( )
inline

Sets the capacity of this

to be the same as the current size.

See also
#size

The documentation for this class was generated from the following file: