chrriis.uihierarchy.compatibility
Class ArrayList

java.lang.Object
  extended bychrriis.uihierarchy.compatibility.ArrayList
All Implemented Interfaces:
Collection, List

public class ArrayList
extends Object
implements List

The arrayList compatible version.

Version:
1.0 2004.01.11
Author:
Christopher Deckers (chrriis@brainlex.com)

Constructor Summary
ArrayList()
          Constructs an empty list with an initial capacity of ten.
ArrayList(Collection c)
          Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
ArrayList(int initialCapacity)
          Constructs an empty list with the specified initial capacity.
 
Method Summary
 void add(int index, Object element)
          Inserts the specified element at the specified position in this list (optional operation).
 boolean add(Object o)
          Appends the specified element to the end of this list (optional operation).
 boolean addAll(Collection c)
          Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).
 boolean contains(Object o)
          Returns true if this collection contains the specified element.
 void ensureCapacity(int minCapacity)
          Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
 Object get(int index)
          Returns the element at the specified position in this list.
 int indexOf(Object o)
          Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
 boolean isEmpty()
          Returns true if this list contains no elements.
 Object remove(int index)
          Removes the element at the specified position in this list (optional operation).
 boolean remove(Object o)
          Removes the first occurrence in this list of the specified element (optional operation).
 boolean removeAll(Collection c)
          Removes all this collection's elements that are also contained in the specified collection (optional operation).
 Object set(int index, Object element)
          Replaces the element at the specified position in this list with the specified element (optional operation).
 int size()
          Returns the number of elements in this list.
 Object[] toArray()
          Returns an array containing all of the elements in this collection.
 Object[] toArray(Object[] a)
          Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayList

public ArrayList()
Constructs an empty list with an initial capacity of ten.


ArrayList

public ArrayList(Collection c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.

Parameters:
c - The collection.

ArrayList

public ArrayList(int initialCapacity)
Constructs an empty list with the specified initial capacity.

Parameters:
initialCapacity - The initial capacity.
Method Detail

contains

public boolean contains(Object o)
Returns true if this collection contains the specified element.

Specified by:
contains in interface Collection
Parameters:
o - The object to look for.
Returns:
True if found.

size

public int size()
Returns the number of elements in this list.

Specified by:
size in interface Collection
Returns:
The size.

get

public Object get(int index)
Returns the element at the specified position in this list.

Specified by:
get in interface List
Parameters:
index - The index.
Returns:
The element.

toArray

public Object[] toArray()
Returns an array containing all of the elements in this collection.

Specified by:
toArray in interface Collection
Returns:
The array.

toArray

public Object[] toArray(Object[] a)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

Specified by:
toArray in interface Collection
Parameters:
a - The array from which to get the type.
Returns:
The array.

add

public boolean add(Object o)
Appends the specified element to the end of this list (optional operation).

Specified by:
add in interface Collection
Parameters:
o - The object to add.
Returns:
True.

add

public void add(int index,
                Object element)
Inserts the specified element at the specified position in this list (optional operation).

Specified by:
add in interface List
Parameters:
index - The index.
element - The element.

addAll

public boolean addAll(Collection c)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

Specified by:
addAll in interface Collection
Parameters:
c - The collection.
Returns:
True if the list changed.

remove

public Object remove(int index)
Removes the element at the specified position in this list (optional operation).

Specified by:
remove in interface List
Parameters:
index - The index of the element to remove.
Returns:
The element that was removed.

remove

public boolean remove(Object o)
Removes the first occurrence in this list of the specified element (optional operation).

Specified by:
remove in interface Collection
Parameters:
o - The element to remove.
Returns:
True if the element was present.

removeAll

public boolean removeAll(Collection c)
Removes all this collection's elements that are also contained in the specified collection (optional operation).

Specified by:
removeAll in interface Collection
Parameters:
c - The collection of elements to remove.
Returns:
True if the collection was affected by this operation.

set

public Object set(int index,
                  Object element)
Replaces the element at the specified position in this list with the specified element (optional operation).

Specified by:
set in interface List
Parameters:
index - The index at which to set the element.
element - The element to set.
Returns:
The element previously located at the specified position.

indexOf

public int indexOf(Object o)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.

Specified by:
indexOf in interface List
Parameters:
o - The element to look for.
Returns:
The index.

isEmpty

public boolean isEmpty()
Returns true if this list contains no elements.

Specified by:
isEmpty in interface Collection
Returns:
True if this list is empty.

ensureCapacity

public void ensureCapacity(int minCapacity)
Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.

Parameters:
minCapacity - The minimum capacity.