astex
Class DynamicArray

java.lang.Object
  extended by astex.DynamicArray
Direct Known Subclasses:
EnergyTerm

public class DynamicArray
extends java.lang.Object

An object that implements a dynamic array. The array grows as necessary as objects are added to it. Array copying is currently performed by explicit loops rather than using System.arraycopy.


Constructor Summary
DynamicArray()
          Default constructor.
DynamicArray(int initialSize)
          Constructor which specifies the initial size.
DynamicArray(int initialSize, int increment)
          Constructor which specifies the initial size and the capacity increment.
 
Method Summary
 int add(java.lang.Object object)
          Add an entry to the CLASSNAME.
 boolean contains(java.lang.Object object)
          Does the array contain the specified object.
 java.lang.Object get(int index)
          Return a specified element from the array.
 java.lang.Object[] getArray()
          Return the reference to the object array.
 int getIndex(java.lang.Object object)
          Return the location of the object or -1 if its not present.
 java.lang.Object getReverse(int index)
          Return a specified element from the array end of the array.
static void print(java.lang.String message, DynamicArray array)
          Print a CLASSNAME contents.
 void remove(java.lang.Object object)
          Remove an object from the CLASSNAME.
 void removeAllElements()
          Remove all elements from the dynamic array.
 void removeElement(int element)
          Remove a specified element from the CLASSNAME.
 void set(int index, java.lang.Object val)
          Set a specified element in the array.
 void setCapacity(int count)
          Set the capacity for the object.
 int size()
          Return the number of objects in the object array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicArray

public DynamicArray(int initialSize,
                    int increment)
Constructor which specifies the initial size and the capacity increment.


DynamicArray

public DynamicArray()
Default constructor.


DynamicArray

public DynamicArray(int initialSize)
Constructor which specifies the initial size.

Method Detail

setCapacity

public void setCapacity(int count)
Set the capacity for the object.


add

public int add(java.lang.Object object)
Add an entry to the CLASSNAME.


remove

public void remove(java.lang.Object object)
Remove an object from the CLASSNAME. All occurrences of the object will be removed.


removeElement

public void removeElement(int element)
Remove a specified element from the CLASSNAME.


removeAllElements

public void removeAllElements()
Remove all elements from the dynamic array.


get

public java.lang.Object get(int index)
Return a specified element from the array.


getReverse

public java.lang.Object getReverse(int index)
Return a specified element from the array end of the array.


set

public void set(int index,
                java.lang.Object val)
Set a specified element in the array.


getArray

public java.lang.Object[] getArray()
Return the reference to the object array.


contains

public boolean contains(java.lang.Object object)
Does the array contain the specified object.


getIndex

public int getIndex(java.lang.Object object)
Return the location of the object or -1 if its not present.


size

public int size()
Return the number of objects in the object array.


print

public static void print(java.lang.String message,
                         DynamicArray array)
Print a CLASSNAME contents.