DCT Lightfoot v3 API specification

java.util
Class Vector

java.lang.Object
  |
  +--java.util.Vector
Direct Known Subclasses:
Stack

public class Vector
extends Object

Implement a growable array of objects


Field Summary
protected  int capacityIncrement
          The amount to increment the size by
protected  int elementCount
          number of elements
protected  Object[] elementData
          The element data
 
Constructor Summary
Vector()
          Create a new vector
Vector(int ic)
          Create a new vector of the particular size
Vector(int ic, int ci)
          Create a new vector of a particular size
 
Method Summary
 void addElement(Object obj)
          Add an element at the end of the Vector.
 int capacity()
          Return the current capacity - not the size
 boolean contains(Object elem)
          Does it contain an object
 void copyInto(Object[] dest)
          Copy the components into the array
 Object elementAt(int index)
          Return the element at the particular position
 Enumeration elements()
          Return the elements
 void ensureCapacity(int minCapacity)
          Ensure there is capacity
 Object firstElement()
          Return the first element in the vector
 int indexOf(Object elem)
          Return the index of the element
 int indexOf(Object elem, int index)
          Return the index of the element
 void insertElementAt(Object obj, int index)
          Insert an element at a particular location
 boolean isEmpty()
          Test to see if it is empty
 Object lastElement()
          Return the last element in the vector
 int lastIndexOf(Object elem)
          Return the last index of the element
 int lastIndexOf(Object elem, int index)
          Return the last index of the element
 void removeAllElements()
          Remove all the elements
 boolean removeElement(Object obj)
          Remove the first element with the particular value
 void removeElementAt(int index)
          Remove the element at a particular position and reduce the size of the vector
 void setElementAt(Object obj, int index)
          Set the element at a particular position
 void setSize(int newSize)
          Set the size
 int size()
          Return the current size
 java.lang.String toString()
          Convert to a string
 void trimToSize()
          Trim the capacity to the current size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

capacityIncrement

protected int capacityIncrement
The amount to increment the size by


elementCount

protected int elementCount
number of elements


elementData

protected Object[] elementData
The element data

Constructor Detail

Vector

public Vector(int ic,
              int ci)
       throws IllegalArgumentException
Create a new vector of a particular size

Parameters:
ic - The initial capacity
ci - The capacity increment
Throws:
IllegalArgumentException - if the initial capacity is negative

Vector

public Vector(int ic)
       throws IllegalArgumentException
Create a new vector of the particular size

Parameters:
ic - The initial capacity
Throws:
IllegalArgumentException - if the initial capacity is negative

Vector

public Vector()
Create a new vector

Method Detail

addElement

public void addElement(Object obj)
Add an element at the end of the Vector. If there was not room in the Vector then the capacity is increased as follows
  1. If the capacityIncrement is greater than zero then the capacity is increased by this amount
  2. If the capacityIncrement is less than or equal to zero then the capacity is increased by the size of the vector, unless the size is also zsero in which case the capacity is increased by 1

Parameters:
obj - The object to add

capacity

public int capacity()
Return the current capacity - not the size

Returns:
the capacity

contains

public boolean contains(Object elem)
Does it contain an object

Parameters:
elem - The element to find
Returns:
true if the element is here

copyInto

public void copyInto(Object[] dest)
Copy the components into the array

Parameters:
dest - The array to copy into
Throws:
ArrayIndexOutOfBoundsException
ArrayStoreException - if the arrays are of incompatible types
NullPointerException - if the destination array is null

elementAt

public Object elementAt(int index)
Return the element at the particular position

Parameters:
index - The index

elements

public Enumeration elements()
Return the elements

Returns:
an enumeration over the elements

ensureCapacity

public void ensureCapacity(int minCapacity)
Ensure there is capacity

Parameters:
minCapacity - the minimum capacity required

firstElement

public Object firstElement()
Return the first element in the vector

Returns:
the element

indexOf

public int indexOf(Object elem)
Return the index of the element

Parameters:
elem - The element to find
Returns:
the index of the element or -1

indexOf

public int indexOf(Object elem,
                   int index)
Return the index of the element

Parameters:
elem - The element
index - The index to start from
Returns:
the index of the element or -1

insertElementAt

public void insertElementAt(Object obj,
                            int index)
Insert an element at a particular location

Parameters:
obj - The object to insert
index - The index to insert to

isEmpty

public boolean isEmpty()
Test to see if it is empty

Returns:
true if it is empty

lastIndexOf

public int lastIndexOf(Object elem)
Return the last index of the element

Parameters:
elem - The element
Returns:
the index of the element or -1

lastIndexOf

public int lastIndexOf(Object elem,
                       int index)
Return the last index of the element

Parameters:
elem - The element
index - The index to start from
Returns:
the index of the element or -1

lastElement

public Object lastElement()
Return the last element in the vector

Returns:
the element

removeAllElements

public void removeAllElements()
Remove all the elements


removeElement

public boolean removeElement(Object obj)
Remove the first element with the particular value

Parameters:
obj -
Returns:
true if something was removed

removeElementAt

public void removeElementAt(int index)
Remove the element at a particular position and reduce the size of the vector

Parameters:
index - The index to remove

setElementAt

public void setElementAt(Object obj,
                         int index)
Set the element at a particular position

Parameters:
obj - The element to set
index - The index to set it at

setSize

public void setSize(int newSize)
Set the size

Parameters:
newSize - The new size

size

public int size()
Return the current size

Returns:
the size

trimToSize

public void trimToSize()
Trim the capacity to the current size


toString

public java.lang.String toString()
Convert to a string

Overrides:
toString in class Object
Returns:
the string representation

DCT Lightfoot v3 API specification

DCT Lightfoot v3 API specification