Class pmr.euclid.ObjectArray
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pmr.euclid.ObjectArray

java.lang.Object
   |
   +----pmr.euclid.Status
           |
           +----pmr.euclid.ObjectArray

public class ObjectArray
extends Status

ObjectArray - array of Objects.

ObjectArray represents a 1-dimensional vector/array of Objects, and is used in SpreadSheets, etc. The class is designed with the idea that all Objects are of the same type, but this is not enforced, and you may wish to experiment.

There is provision for 2 homegenous arrays, INT and REAL , for compatibility with RealArray and IntArray In some cases the type of the Object (e.g. integer) might lead to additional features.

Hacked from RealArray - it shares a number of functions.

Author:
(C) P. Murray-Rust, 1996

Variable Index

 o INT
 o OBJECT
 o REAL

Constructor Index

 o ObjectArray()
default is an array of zero points
 o ObjectArray(int)
creates n-element array initialised to null
 o ObjectArray(int, Object)
set all elements of the array to a given Object
 o ObjectArray(IntArray)
convert an IntArray to a ObjectArray
 o ObjectArray(ObjectArray)
copy constructor
 o ObjectArray(ObjectArray, int, int)
subarray of another array - inclusive; if low > high or other silly indices, creates default array
 o ObjectArray(RealArray)
convert an RealArray to a ObjectArray

Method Index

 o addArray(ObjectArray)
append elements
 o addElement(Object)
append element
 o clearArray()
clear all elements of array to null (or 0 or 0.0)
 o copy(Object[])
copy a Object[] into a new one
 o deleteElement(int)
delete element and close up; if outside range, take no action
 o deleteElements(int, int)
delete elements and close up; if outside range take no action
 o elementAt(int)
extracts a given element from the array
 o equals(ObjectArray)
are two arrays equal in all elements?
 o getArray()
return the array as a Object[]; this has to resize the array to the precise length used , or confusion will result! Note that this gives the user access to the actual array, so that they can alter its contents.
 o getIntArray()
return contents as a IntArray if INT, else null
 o getObjectClass()
get the Class of the objects, if this is common to all, else null.
 o getObjectType()
get the type of the Objects as INT, etc
 o getRealArray()
return contents as a RealArray if REAL , else null
 o getReorderedArray(IntSet)
reorder by index in IntSet; does NOT modify array
 o getReverseArray()
return the elements in reverse order as Object[]
 o getStringValues()
returns values as strings
 o getSubArray(int, int)
RHS: get a subObjectArray from element start to end
 o insertArray(int, ObjectArray)
insert a ObjectArray at position elem and expand
 o insertElementAt(int, Object)
insert element and expand; if outside range, take no action
 o isHomogeneous()
 o setElementAt(int, Object)
set a given element into the array; must be less than current max index
 o setElements(int, Object[])
copy a smaller array into the array statrting at start
 o setMaxIndex(int)
reset the maximum index (for when poking elements) (no other effect)
 o shallowCopy(ObjectArray)
shallowCopy
 o size()
get actual number of elements
 o toString()
concatenates values with spaces

Variables

 o OBJECT
  public final static int OBJECT
 o INT
  public final static int INT
 o REAL
  public final static int REAL

Constructors

 o ObjectArray
  public ObjectArray()
default is an array of zero points
 o ObjectArray
  public ObjectArray(int n)
creates n-element array initialised to null
 o ObjectArray
  public ObjectArray(int n,
                     Object elem1)
set all elements of the array to a given Object
 o ObjectArray
  public ObjectArray(IntArray ia)
convert an IntArray to a ObjectArray
 o ObjectArray
  public ObjectArray(RealArray ra)
convert an RealArray to a ObjectArray
 o ObjectArray
  public ObjectArray(ObjectArray m,
                     int low,
                     int high)
subarray of another array - inclusive; if low > high or other silly indices, creates default array
 o ObjectArray
  public ObjectArray(ObjectArray m)
copy constructor

Methods

 o getObjectClass
  public Class getObjectClass()
get the Class of the objects, if this is common to all, else null. some of the elements can be null (i.e. 'missing')
 o isHomogeneous
  public boolean isHomogeneous()
 o getObjectType
  public int getObjectType()
get the type of the Objects as INT, etc
 o shallowCopy
  public void shallowCopy(ObjectArray m)
shallowCopy
 o elementAt
  public Object elementAt(int elem) throws ArrayIndexOutOfBoundsException
extracts a given element from the array
Throws: ArrayIndexOutOfBoundsException
elem >= size of this
 o size
  public int size()
get actual number of elements
 o getArray
  public Object[] getArray()
return the array as a Object[]; this has to resize the array to the precise length used , or confusion will result! Note that this gives the user access to the actual array, so that they can alter its contents. This should be used with care, but Java should stop any access outside the buffer limits.
 o getRealArray
  public RealArray getRealArray()
return contents as a RealArray if REAL , else null
 o getIntArray
  public IntArray getIntArray()
return contents as a IntArray if INT, else null
 o clearArray
  public void clearArray()
clear all elements of array to null (or 0 or 0.0)
 o getReverseArray
  public Object[] getReverseArray()
return the elements in reverse order as Object[]
 o setMaxIndex
  public void setMaxIndex(int max)
reset the maximum index (for when poking elements) (no other effect)
 o equals
  public boolean equals(ObjectArray f) throws UnequalLengthArraysException
are two arrays equal in all elements?
Throws: UnequalLengthArraysException
f is different size from this
 o setElementAt
  public void setElementAt(int elem,
                           Object f) throws ArrayIndexOutOfBoundsException
set a given element into the array; must be less than current max index
Throws: ArrayIndexOutOfBoundsException
elem >= size of this
 o getSubArray
  public ObjectArray getSubArray(int start,
                                 int end)
RHS: get a subObjectArray from element start to end
 o setElements
  public void setElements(int start,
                          Object a[])
copy a smaller array into the array statrting at start
 o deleteElement
  public void deleteElement(int elem)
delete element and close up; if outside range, take no action
 o deleteElements
  public void deleteElements(int low,
                             int high)
delete elements and close up; if outside range take no action
 o insertElementAt
  public void insertElementAt(int elem,
                              Object f)
insert element and expand; if outside range, take no action
 o insertArray
  public void insertArray(int elem,
                          ObjectArray f)
insert a ObjectArray at position elem and expand
 o addElement
  public void addElement(Object f)
append element
 o addArray
  public void addArray(ObjectArray f)
append elements
 o getReorderedArray
  public ObjectArray getReorderedArray(IntSet idx) throws BadSubscriptException
reorder by index in IntSet; does NOT modify array
Throws: BadSubscriptException
an element of idx is outside range of this
 o getStringValues
  public String[] getStringValues()
returns values as strings
 o toString
  public String toString()
concatenates values with spaces
Overrides:
toString in class Object
 o copy
  public static Object[] copy(Object f[])
copy a Object[] into a new one

All Packages  Class Hierarchy  This Package  Previous  Next  Index