|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--waba.util.IntVector
An int vector is an array of int's. The vector grows and shrinks dynamically as ints are added and removed.
Here is an example showing a vector being used:
... IntVector vec = new IntVector(); vec.add(int1); vec.add(int22); ... vec.insert(3, int3); vec.del(2); if (vec.getCount() > 5) ...
Field Summary | |
static int |
INVALID
|
int[] |
items
|
Constructor Summary | |
IntVector()
Constructs an empty vector. |
|
IntVector(DataStream in)
Constructs an vector read from the stream |
|
IntVector(int size)
Constructs an empty vector with a given initial size. |
Method Summary | |
void |
add(int obj)
Adds an int to the end of the vector. |
void |
addElement(int obj)
same of add(int) |
void |
clear()
clears all elements in this vector and sets its length to 0 |
void |
del(int index)
Deletes the int reference at the given index. |
int |
elementAt(int index)
same of items[index] |
void |
ensureBit(int index)
Useful method to use when this IntVector will act like a bit vector, through the methods isBitSet and setBit . |
int |
find(int obj)
Finds the index of the given int. |
int |
find(int obj,
int startIndex)
Finds the index of the given int. |
int |
getCount()
Returns the number of ints in the vector. |
int |
indexOf(int elem)
same of find(int) |
int |
indexOf(int elem,
int index)
same of find(int, index) |
void |
insert(int index,
int obj)
Inserts an int at the given index. |
void |
insertElementAt(int obj,
int index)
same of insert(index, int) |
boolean |
isBitSet(int index)
Used to let this int vector act like a bit vector. returns true if the bit specified is set. you must guarantee that the index exists in the vector. guich@102 |
int |
peek()
returns the last int, without removing it. returns INVALID if no more elements. |
int |
pop()
returns the last int, removing it. returns INVALID if no more elements. |
void |
push(int obj)
pushes a int. simply calls add. |
void |
qsort()
Do a quick sort in the elements of this IntVector |
void |
removeElement(int obj)
same of del(int) |
void |
removeElementAt(int index)
same of del(index) |
void |
setBit(int index,
boolean on)
Used to let this int vector act like a bit vector. returns true if the bit specified is set. you must guarantee that the index exists in the vector. guich@102 |
void |
setElementAt(int obj,
int index)
Set the element at the given index. |
int |
size()
same of getCount() |
void |
writeTo(DataStream out)
writes this int vector to the stream |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
toString,
wait,
wait |
Field Detail |
public static final int INVALID
public int[] items
Constructor Detail |
public IntVector()
public IntVector(DataStream in)
public IntVector(int size)
Method Detail |
public void add(int obj)
public void insert(int index, int obj)
public void del(int index)
public int find(int obj)
public int find(int obj, int startIndex)
public int getCount()
public void writeTo(DataStream out)
public void ensureBit(int index)
isBitSet
and setBit
. Just call it
with the maximum bit index what will be used (starting from 0); then
you can safely use the two methods. This must be done because those methods
does not check the bounds of the array.public boolean isBitSet(int index)
public void setBit(int index, boolean on)
public void push(int obj)
public int pop()
public int peek()
public void clear()
public int size()
public int indexOf(int elem)
public int indexOf(int elem, int index)
public int elementAt(int index)
public void setElementAt(int obj, int index)
public void removeElementAt(int index)
public void insertElementAt(int obj, int index)
public void addElement(int obj)
public void removeElement(int obj)
public void qsort()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |