weiss.util
Class ArrayList

java.lang.Object
  |
  +--weiss.util.AbstractCollection
        |
        +--weiss.util.ArrayList
All Implemented Interfaces:
Collection, List, java.io.Serializable

public class ArrayList
extends AbstractCollection
implements List

The ArrayList implements a growable array. Insertions are always done at the end.

See Also:
Serialized Form

Constructor Summary
ArrayList()
          Construct an empty ArrayList.
ArrayList(Collection other)
          Construct an ArrayList with same items as another Collection.
 
Method Summary
 boolean add(java.lang.Object x)
          Adds an item to this collection, at the end.
 void clear()
          Change the size of this collection to zero.
 boolean contains(java.lang.Object x)
          Tests if some item is in this collection.
 java.lang.Object get(int idx)
          Returns the item at position idx.
 Iterator iterator()
          Obtains an Iterator object used to traverse the collection.
 ListIterator listIterator(int idx)
          Obtains a ListIterator object used to traverse the collection bidirectionally.
 java.lang.Object remove(int idx)
          Removes an item from this collection.
 boolean remove(java.lang.Object x)
          Removes an item from this collection.
 java.lang.Object set(int idx, java.lang.Object newVal)
          Changes the item at position idx.
 int size()
          Returns the number of items in this collection.
 
Methods inherited from class weiss.util.AbstractCollection
equals, hashCode, isEmpty, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface weiss.util.Collection
isEmpty, toArray
 

Constructor Detail

ArrayList

public ArrayList()
Construct an empty ArrayList.

ArrayList

public ArrayList(Collection other)
Construct an ArrayList with same items as another Collection.
Method Detail

size

public int size()
Returns the number of items in this collection.
Specified by:
size in interface Collection
Returns:
the number of items in this collection.

get

public java.lang.Object get(int idx)
Returns the item at position idx.
Specified by:
get in interface List
Parameters:
idx - the index to search in.
Throws:
ArrayIndexOutOfBoundsException - if index is out of range.

set

public java.lang.Object set(int idx,
                            java.lang.Object newVal)
Changes the item at position idx.
Specified by:
set in interface List
Parameters:
idx - the index to change.
newVal - the new value.
Returns:
the old value.
Throws:
ArrayIndexOutOfBoundsException - if index is out of range.

contains

public boolean contains(java.lang.Object x)
Tests if some item is in this collection.
Specified by:
contains in interface Collection
Overrides:
contains in class AbstractCollection
Parameters:
x - any object.
Returns:
true if this collection contains an item equal to x.

add

public boolean add(java.lang.Object x)
Adds an item to this collection, at the end.
Specified by:
add in interface Collection
Parameters:
x - any object.
Returns:
true.

remove

public boolean remove(java.lang.Object x)
Removes an item from this collection.
Specified by:
remove in interface Collection
Overrides:
remove in class AbstractCollection
Parameters:
x - any object.
Returns:
true if this item was removed from the collection.

remove

public java.lang.Object remove(int idx)
Removes an item from this collection.
Parameters:
idx - the index of the object.
Returns:
the item was removed from the collection.

clear

public void clear()
Change the size of this collection to zero.
Specified by:
clear in interface Collection
Overrides:
clear in class AbstractCollection

iterator

public Iterator iterator()
Obtains an Iterator object used to traverse the collection.
Specified by:
iterator in interface Collection

listIterator

public ListIterator listIterator(int idx)
Obtains a ListIterator object used to traverse the collection bidirectionally.
Specified by:
listIterator in interface List
Parameters:
idx - the index to start the iterator. Use size() to do complete reverse traversal. Use 0 to do complete forward traversal.
Throws:
IndexOutOfBoundsException - if idx is not between 0 and size(), inclusive.