|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.uima.internal.util.IntVector
public class IntVector
Like java.util.Vector
, but elements are int
s. This is a
bare-bones implementation. May add features as I need them.
Field Summary | |
---|---|
protected int[] |
array
|
protected int |
pos
|
Constructor Summary | |
---|---|
IntVector()
Default constructor. |
|
IntVector(int capacity)
Specify the initial capacity of this vector. |
|
IntVector(int[] array)
Construct an IntVector from an array. |
|
IntVector(int capacity,
int growth_factor,
int multiplication_limit)
Specify the initial capacity, growth factor and multiplication limit of this vector. |
Method Summary | |
---|---|
void |
add(int element)
Add an element at the end of vector. |
void |
add(int index,
int element)
Add an element at a certain position in the vector. |
boolean |
contains(int elem)
Tests if the specified int is a component of this IntVector . |
IntVector |
copy()
|
void |
ensure_size(int req)
|
boolean |
equals(java.lang.Object o)
Compares the specified Object with this IntVector for equality. |
void |
fill(int value)
Set every element of the vector to some value. |
int |
get(int index)
Retrieve the element at index. |
int[] |
getArray()
Return the internal array. |
int |
hashCode()
|
int |
indexOf(int element)
Returns the index of the first occurence of the element specified in this vector. |
int |
position(int elem)
Return the position of the first occurence of elem in the IntVector, if it
exists. |
void |
put(int index,
int element)
Set an element at a certain position in the vector. |
int |
remove(int index)
Remove the element at a certain index. |
void |
removeAllElements()
Remove all elements and set size to 0. |
void |
set(int index,
int element)
Set an element at a certain position in the vector. |
void |
setSize(int size)
|
int |
size()
|
int[] |
toArray()
Return the underlying int array, where the length of the returned array is equal to the vector's size. |
int[] |
toArrayCopy()
Return a copy of the underlying array. |
java.lang.String |
toString()
|
void |
trimToSize()
Reduce the size of the internal array to the number of current elements. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int pos
protected int[] array
Constructor Detail |
---|
public IntVector()
public IntVector(int[] array)
array
- The array the IntVector is initialized from.public IntVector(int capacity)
capacity
- Initial capacity of vector.public IntVector(int capacity, int growth_factor, int multiplication_limit)
capacity
- Initial capacity of vector.growth_factor
- Growth factor.multiplication_limit
- Multiplication limit.Method Detail |
---|
public void setSize(int size)
public void add(int element)
Vector
.
public void add(int index, int element)
0
-valued
elements are added.
public void set(int index, int element)
public void put(int index, int element)
public int get(int index)
index
.
java.lang.ArrayIndexOutOfBoundsException
- If index
is not a valid index.public int remove(int index)
index
- The index of the element to be removed.
index
.
java.lang.ArrayIndexOutOfBoundsException
- If index
is not a valid index.public void removeAllElements()
public boolean equals(java.lang.Object o)
Object
with this IntVector
for equality.
Two IntVector
s are equal if and only if the object passed in o
is of type IntVector
, this.size() == o.size()
, and the n-th
element in this IntVector
is equal to the n-th element in o
for all n < this.size()
.
equals
in class java.lang.Object
true
if the IntVector
s are equal, false
otherwise.public int size()
public boolean contains(int elem)
int
is a component of this IntVector
.
true
if and only if the int
is an element of this
IntVector
, false
otherwise.public int position(int elem)
elem
in the IntVector, if it
exists.
elem
- The element we're looking for.
-1
if it doesn't exist.public void fill(int value)
value
- The fill value.public int[] toArray()
public int[] toArrayCopy()
public int[] getArray()
public int indexOf(int element)
-1
if the element was not found.public void trimToSize()
public IntVector copy()
public java.lang.String toString()
toString
in class java.lang.Object
public void ensure_size(int req)
public int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |