waba.util
Class Vector

waba.lang.Object
  |
  +--waba.util.Vector

public class Vector
extends Object

A vector is an array of object references. The vector grows and shrinks dynamically as objects are added and removed.

Here is an example showing a vector being used:

 ...
 Vector vec = new Vector();
 vec.add(obj1);
 vec.add(obj2);
 ...
 vec.insert(3, obj3);
 vec.del(2);
 if (vec.getCount() > 5)
 ...
 


Constructor Summary
Vector()
          Constructs an empty vector.
Vector(int size)
          Constructs an empty vector with a given initial size.
 
Method Summary
 void add(Object obj)
          Adds an object to the end of the vector.
 void del(int index)
          Deletes the object reference at the given index.
 int find(Object obj)
          Finds the index of the given object.
 Object get(int index)
          Returns the object at the given index.
 int getCount()
          Returns the number of objects in the vector.
 void insert(int index, Object obj)
          Inserts an object at the given index.
 void set(int index, Object obj)
          Sets the object at the given index.
 Object[] toObjectArray()
          Converts the vector to an array of objects.
 
Methods inherited from class waba.lang.Object
toString
 

Constructor Detail

Vector

public Vector()
Constructs an empty vector.

Vector

public Vector(int size)
Constructs an empty vector with a given initial size. The size is the initial size of the vector's internal object array. The vector will grow as needed when objects are added.
Method Detail

add

public void add(Object obj)
Adds an object to the end of the vector.

insert

public void insert(int index,
                   Object obj)
Inserts an object at the given index.

del

public void del(int index)
Deletes the object reference at the given index.

get

public Object get(int index)
Returns the object at the given index.

set

public void set(int index,
                Object obj)
Sets the object at the given index.

find

public int find(Object obj)
Finds the index of the given object. The list is searched using a O(n) linear search through all the objects in the vector.

getCount

public int getCount()
Returns the number of objects in the vector.

toObjectArray

public Object[] toObjectArray()
Converts the vector to an array of objects.