ukcrobots.util
Class ArrayList

java.lang.Object
  |
  +--ukcrobots.util.ArrayList

public class ArrayList
extends Object

A dynamic array-backed list. Based on java.util.ArrayList.

Version:
2001.12.20
Author:
d.j.barnes @at@ kent.ac.uk

Constructor Summary
ArrayList()
          Create an array list of default capacity.
ArrayList(int capacity)
          Create an array list of required capacity.
 
Method Summary
 boolean add(Object obj)
          Store a new object at index size().
 void ensureCapacity(int minCapacity)
          Ensure that the list is of the given capacity.
 Object get(int index)
          Return the object at the given index.
 Object remove(int index)
          Remove the object at the given index.
 Object set(int index, Object element)
          Replace the item at the given index with element.
 int size()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Constructor Detail

ArrayList

public ArrayList()
Create an array list of default capacity.


ArrayList

public ArrayList(int capacity)
Create an array list of required capacity.

Parameters:
capacity - The desired capacity.
Method Detail

get

public Object get(int index)
           throws IndexOutOfBoundsException
Return the object at the given index.

Parameters:
index - Which object to return. Must be in the range [0 ... size()-1]
Throws:
IndexOutOfBoundsException - if index is out of bounds.

add

public boolean add(Object obj)
Store a new object at index size().

Parameters:
obj - The object to be stored.

remove

public Object remove(int index)
              throws IndexOutOfBoundsException
Remove the object at the given index. All items to its right are moved one place left.

Parameters:
index - The index of the item to be removed. It must lie in the [0 ... size()-1].
Throws:
IndexOutOfBoundsException - if index is out of bounds.

set

public Object set(int index,
                  Object element)
Replace the item at the given index with element.

Parameters:
index - An index in the range 0 .. size()-1
element - The replacement item.
Returns:
The previous element at index.

ensureCapacity

public void ensureCapacity(int minCapacity)
Ensure that the list is of the given capacity.

Parameters:
minCapacity - The minimum capacity.

size

public int size()
Returns:
The number of items in the list.