|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmr3d.collections.DynamicIntArray
The class DynamicIntArray is a wrapper for
java.lang.Vector providing an easy way to handle
a dynamic array of int values.
The following short example demontrates the usage of
the dynamic int array wrapper.
DynamicIntArray myDynArray = new DynamicIntArray();
myDynArray.add(100);
System.out.println(myDynArray.get(0)); // 100
myDynArray.replaceAt(0,200);
System.out.println(myDynArray.get(0)); // 200
myDynArray.add(300);
System.out.println(myDynArray.size()); // 2
| Field Summary | |
private java.util.Vector |
elements
Vector containing the array data. |
| Fields inherited from interface mr3d.debug.Debugable |
ERROR_INT, ERROR_STRING |
| Constructor Summary | |
DynamicIntArray()
Creates a new dynamic int array. |
|
| Method Summary | |
void |
add(int newValue)
Adds a new Integer object with the specified
value to the array. |
void |
clear()
Deletes all elements of the array |
boolean |
contains(int nr)
Returns "true" if the specified int-value is already in the array. |
int |
get(int index)
Returns the int value of the Integer
object at the specified index.
|
int |
indexOf(int compareInt)
Returns the index of the first occurence of the specified int value. |
void |
insertAt(int newValue,
int index)
Inserts the int value at the specified
position. |
void |
removeAt(int index)
Removes the Integer object at the specified position. |
void |
replaceAt(int index,
int newValue)
Replaces the int value at the specified
position with a new value. |
int |
size()
Returns the the number of elements stored in the elements vector. |
void |
toConsole()
Prints the contents of the object to the Java console. |
void |
toConsole(java.lang.String msgString)
Prints the contents of the object to the Java console together with an information string. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private java.util.Vector elements
Vector containing the array data.
| Constructor Detail |
public DynamicIntArray()
int array.
| Method Detail |
public void add(int newValue)
Integer object with the specified
value to the array.
newValue - value to be added to the arraypublic void clear()
public boolean contains(int nr)
nr - number to be checked for
public int get(int index)
int value of the Integer
object at the specified index.
If the specified index is invalid the method returns
ERRORVAL.
index - index of the value
Integer at the specified
indexpublic int indexOf(int compareInt)
int value.
compareInt - the int value of which the
index is to be returned
int
public void insertAt(int newValue,
int index)
int value at the specified
position.
index - position of the int
value in the arraynewValue - value to be inserted
at the specified positionpublic void removeAt(int index)
Integer object at the specified position.
index - position of the Integer object
to be removed
public void replaceAt(int index,
int newValue)
int value at the specified
position with a new value.
index - position of the int
value in the arraynewValue - replacement value for the value
on the specified positionpublic int size()
elements vector.
public void toConsole()
Debugable
toConsole in interface Debugablepublic void toConsole(java.lang.String msgString)
Debugable
toConsole in interface Debugable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||