|
|||||||||
| 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 | |
protected int |
count
|
static int |
INVALID
|
int[] |
items
|
| Constructor Summary | |
IntVector()
Constructs an empty vector. |
|
IntVector(DataStream in)
Deprecated. This constructor will be removed in the future. Grab the code and put it in your program. |
|
IntVector(int size)
Constructs an empty vector with a given initial size. |
|
IntVector(int[] items)
Constructs a vector by directly assigning the given int array. |
|
| Method Summary | |
void |
add(int obj)
Deprecated. Use addElement instead. |
void |
addElement(int obj)
Adds an int to the end of the vector. |
void |
clear()
Deprecated. Use removeAllElements instead. |
void |
del(int index)
Deprecated. Use removeElementAt method instead. |
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)
Deprecated. Use indexOf method instead. |
int |
find(int obj,
int startIndex)
Deprecated. Use indexOf method instead. |
int |
getCount()
Deprecated. Use size method instead. |
int |
indexOf(int elem)
Finds the index of the given int. |
int |
indexOf(int elem,
int index)
Finds the index of the given int. |
void |
insert(int index,
int obj)
Deprecated. Use insertElementAt method instead. CAUTION: insertElementAt has the parameters in inverted order! |
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 |
pop(int howMany)
Pops the given number of elements from this vector. |
void |
push(int obj)
pushes a int. simply calls add. |
void |
qsort()
Do a quick sort in the elements of this IntVector |
void |
removeAllElements()
Sets all elements in this vector to 0 and its size to 0. |
void |
removeElement(int obj)
Deletes the int reference. |
void |
removeElementAt(int index)
Deletes the int reference at the given 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 |
int |
size()
Returns the number of ints in the vector. |
int[] |
toIntArray()
Returns a new array with just the added elements |
void |
writeTo(DataStream out)
Deprecated. This method will be removed in the future. Grab the code and put it in your program. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final int INVALID
public int[] items
protected int count
| Constructor Detail |
public IntVector()
public IntVector(DataStream in)
public IntVector(int size)
public IntVector(int[] items)
| 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 clear()
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 void pop(int howMany)
public int pop()
throws ElementNotFoundError
public int peek()
throws ElementNotFoundError
public int size()
public int indexOf(int elem)
public int indexOf(int elem,
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 removeAllElements()
public void qsort()
public int[] toIntArray()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||