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
-
INT
-
-
OBJECT
-
-
REAL
-
-
ObjectArray()
- default is an array of zero points
-
ObjectArray(int)
- creates n-element array initialised to null
-
ObjectArray(int, Object)
- set all elements of the array to a given Object
-
ObjectArray(IntArray)
- convert an IntArray to a ObjectArray
-
ObjectArray(ObjectArray)
- copy constructor
-
ObjectArray(ObjectArray, int, int)
- subarray of another array - inclusive; if low > high or other silly
indices, creates default array
-
ObjectArray(RealArray)
- convert an RealArray to a ObjectArray
-
addArray(ObjectArray)
- append elements
-
addElement(Object)
- append element
-
clearArray()
- clear all elements of array to null (or 0 or 0.0)
-
copy(Object[])
- copy a Object[] into a new one
-
deleteElement(int)
- delete element and close up; if outside range, take no action
-
deleteElements(int, int)
- delete elements and close up; if outside range take no action
-
elementAt(int)
- extracts a given element from the array
-
equals(ObjectArray)
- are two arrays equal in all elements?
-
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.
-
getIntArray()
- return contents as a IntArray if INT, else null
-
getObjectClass()
- get the Class of the objects, if this is common to all, else null.
-
getObjectType()
- get the type of the Objects as INT, etc
-
getRealArray()
- return contents as a RealArray if REAL , else null
-
getReorderedArray(IntSet)
- reorder by index in IntSet; does NOT modify array
-
getReverseArray()
- return the elements in reverse order as Object[]
-
getStringValues()
- returns values as strings
-
getSubArray(int, int)
- RHS: get a subObjectArray from element start to end
-
insertArray(int, ObjectArray)
- insert a ObjectArray at position elem and expand
-
insertElementAt(int, Object)
- insert element and expand; if outside range, take no action
-
isHomogeneous()
-
-
setElementAt(int, Object)
- set a given element into the array; must be less than current max index
-
setElements(int, Object[])
- copy a smaller array into the array statrting at start
-
setMaxIndex(int)
- reset the maximum index (for when poking elements) (no other effect)
-
shallowCopy(ObjectArray)
- shallowCopy
-
size()
- get actual number of elements
-
toString()
- concatenates values with spaces
OBJECT
public final static int OBJECT
INT
public final static int INT
REAL
public final static int REAL
ObjectArray
public ObjectArray()
- default is an array of zero points
ObjectArray
public ObjectArray(int n)
- creates n-element array initialised to null
ObjectArray
public ObjectArray(int n,
Object elem1)
- set all elements of the array to a given Object
ObjectArray
public ObjectArray(IntArray ia)
- convert an IntArray to a ObjectArray
ObjectArray
public ObjectArray(RealArray ra)
- convert an RealArray to a ObjectArray
ObjectArray
public ObjectArray(ObjectArray m,
int low,
int high)
- subarray of another array - inclusive; if low > high or other silly
indices, creates default array
ObjectArray
public ObjectArray(ObjectArray m)
- copy constructor
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')
isHomogeneous
public boolean isHomogeneous()
getObjectType
public int getObjectType()
- get the type of the Objects as INT, etc
shallowCopy
public void shallowCopy(ObjectArray m)
- shallowCopy
elementAt
public Object elementAt(int elem) throws ArrayIndexOutOfBoundsException
- extracts a given element from the array
- Throws: ArrayIndexOutOfBoundsException
- elem >= size of this
size
public int size()
- get actual number of elements
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.
getRealArray
public RealArray getRealArray()
- return contents as a RealArray if REAL , else null
getIntArray
public IntArray getIntArray()
- return contents as a IntArray if INT, else null
clearArray
public void clearArray()
- clear all elements of array to null (or 0 or 0.0)
getReverseArray
public Object[] getReverseArray()
- return the elements in reverse order as Object[]
setMaxIndex
public void setMaxIndex(int max)
- reset the maximum index (for when poking elements) (no other effect)
equals
public boolean equals(ObjectArray f) throws UnequalLengthArraysException
- are two arrays equal in all elements?
- Throws: UnequalLengthArraysException
- f is different size from this
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
getSubArray
public ObjectArray getSubArray(int start,
int end)
- RHS: get a subObjectArray from element start to end
setElements
public void setElements(int start,
Object a[])
- copy a smaller array into the array statrting at start
deleteElement
public void deleteElement(int elem)
- delete element and close up; if outside range, take no action
deleteElements
public void deleteElements(int low,
int high)
- delete elements and close up; if outside range take no action
insertElementAt
public void insertElementAt(int elem,
Object f)
- insert element and expand; if outside range, take no action
insertArray
public void insertArray(int elem,
ObjectArray f)
- insert a ObjectArray at position elem and expand
addElement
public void addElement(Object f)
- append element
addArray
public void addArray(ObjectArray f)
- append elements
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
getStringValues
public String[] getStringValues()
- returns values as strings
toString
public String toString()
- concatenates values with spaces
- Overrides:
- toString in class Object
copy
public static Object[] copy(Object f[])
- copy a Object[] into a new one
All Packages Class Hierarchy This Package Previous Next Index