|
OpMath | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.opmath.util.datastruct.ComparableArray
An object which can serve as a ComparableTable column, implemented using a
Comparable[].
ComparableArray implements the ComparableList interface, thus it provides
a storage structure for columns of a ComparableTable with exactly the access methods
required by the containing class.
ComparableArray is suitable for use where the size of the ComparableTable
column is known in advance, but its contents may change. This particular specialisation has one
useful behaviour: the clear() method nulls out the contents of the ComparableArray,
but leaves the stucture intact.
Copyright: (c) 2002 The Open Math Company Limited
The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.
| Field Summary | |
protected Comparable[] |
a
|
| Constructor Summary | |
ComparableArray(Comparable[] src)
Constructs a ComparableArray. |
|
ComparableArray(int n)
Constructs a ComparableArray of size n. |
|
| Method Summary | |
boolean |
add(Comparable element)
Always thows an UnsupportedOperationException. |
void |
clear()
Sets all of the elements of this ComparableArray to null. |
Enumeration |
elements()
Returns an enumeration of the components of this ComparableArray. |
Object |
get(int i)
Returns the element at the specified position in this ComparableArray. |
int |
indexOf(Object element)
Searches for the first occurence of the given argument, testing for equality using the equals(Object) method. |
Comparable |
set(int i,
Comparable element)
Replaces the element at the specified position in this ComparableVector with the
specified element. |
int |
size()
Returns the number of elements in this list. |
String |
toString()
Returns a new String, detailing the contents of this ComparableArray
instance. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected Comparable[] a
| Constructor Detail |
public ComparableArray(Comparable[] src)
ComparableArray. The data for the new instance is a
System.arraycopy(..) of the given Compararble[].
src - a Compararble[] used to populate the ComparableArray.public ComparableArray(int n)
ComparableArray of size n. The initial value of all
the elements will be null. The elements can be modified
later with set(int, Comparable).
n - an int specifying the size.| Method Detail |
public Enumeration elements()
ComparableArray. The returned
Enumeration object will generate all items in this list.
elements in interface ComparableListpublic void clear()
ComparableArray to null.
Note that clear() does not alter the size of this ComparableArray instance.
clear in interface ComparableList
public boolean add(Comparable element)
throws UnsupportedOperationException
UnsupportedOperationException.
NOTE: Although it is declared as returning a boolean, add(Comparable)
never returns anything.
add in interface ComparableListelement - the Comparable to be added.UnsupportedOperationException - always.
public Comparable set(int i,
Comparable element)
throws ArrayIndexOutOfBoundsException
ComparableVector with the
specified element.
set in interface ComparableListindex - the int index of element to replace.element - the Comparable element to be stored at the specified position.Comparable element previously stored at this location.ArrayIndexOutOfBoundsException - an exception thrown if the index is out of
range (index < 0 || index >= size()).
public Object get(int i)
throws IndexOutOfBoundsException
ComparableArray.
get in interface ComparableListindex - the int index of element.ComparableResultSet.ArrayIndexOutOfBoundsException - an exception thrown if the index is out of
range (index < 0 || index >= size()).public int indexOf(Object element)
equals(Object) method.
indexOf in interface ComparableListindex - the Comparable element.elem.equals(elementData[k]) is true;
returns -1 if the object is not found.public int size()
Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
size in interface ComparableListpublic String toString()
String, detailing the contents of this ComparableArray
instance.
toString in interface ComparableListtoString in class ObjectString.
|
OpMath | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||