public class IntVector extends java.lang.Object implements java.lang.Cloneable, RevisionHandler
| Constructor and Description |
|---|
IntVector()
Constructs a null vector.
|
IntVector(int n)
Constructs an n-vector of zeros.
|
IntVector(int[] v)
Constructs a vector given an int array
|
IntVector(int n,
int s)
Constructs an n-vector of a constant
|
| Modifier and Type | Method and Description |
|---|---|
int |
capacity()
Returns the capacity of the vector
|
java.lang.Object |
clone()
Clones the IntVector object.
|
IntVector |
copy()
Makes a deep copy of the vector
|
int |
get(int i)
Gets the value of an element.
|
int[] |
getArray()
Access the internal one-dimensional array.
|
int[] |
getArrayCopy()
Returns a copy of the internal one-dimensional array.
|
java.lang.String |
getRevision()
Returns the revision string.
|
boolean |
isEmpty()
Returns true if the vector is empty
|
static void |
main(java.lang.String[] args)
Tests the IntVector class
|
static IntVector |
seq(int i0,
int i1)
Generates an IntVector that stores all integers inclusively between
two integers.
|
void |
set(int s)
Sets the value of an element.
|
void |
set(int i,
int s)
Sets a single element.
|
void |
set(int i0,
int i1,
int[] v,
int j0)
Sets the values of elements from an int array.
|
void |
set(int i0,
int i1,
IntVector v,
int j0)
Sets the values of elements from another IntVector.
|
void |
set(IntVector v)
Sets the values of elements from another IntVector.
|
void |
setCapacity(int capacity)
Sets the capacity of the vector
|
void |
setSize(int size)
Sets the size of the vector.
|
void |
shift(int i,
int j)
Shifts an element to another position.
|
void |
shiftToEnd(int j)
Shifts an element to the end of the vector.
|
int |
size()
Gets the size of the vector.
|
void |
sort()
Sorts the elements in place
|
IntVector |
subvector(int i0,
int i1)
Returns a subvector.
|
IntVector |
subvector(IntVector index)
Returns a subvector as indexed by an IntVector.
|
void |
swap(int i,
int j)
Swaps the values stored at i and j
|
java.lang.String |
toString()
Converts the IntVecor to a string
|
java.lang.String |
toString(int digits,
boolean trailing)
Convert the IntVecor to a string
|
public IntVector()
public IntVector(int n)
n - Length.public IntVector(int n,
int s)
n - Length.public IntVector(int[] v)
v - the int arraypublic int size()
public void setSize(int size)
size - the new Size.public void set(int s)
s - the value for the elementpublic void set(int i0,
int i1,
int[] v,
int j0)
i0 - the index of the first elementi1 - the index of the last elementv - the int array that stores the valuesj0 - the index of the first element in the int arraypublic void set(int i0,
int i1,
IntVector v,
int j0)
i0 - the index of the first elementi1 - the index of the last elementv - the IntVector that stores the valuesj0 - the index of the first element in the IntVectorpublic void set(IntVector v)
v - the IntVector that stores the valuespublic static IntVector seq(int i0, int i1)
i0 - the first integeri1 - the second integerpublic int[] getArray()
public void sort()
public int[] getArrayCopy()
public int capacity()
public void setCapacity(int capacity)
capacity - the new capacity of the vectorpublic void set(int i,
int s)
i - the index of the elements - the new valuepublic int get(int i)
i - the index of the elementpublic IntVector copy()
public java.lang.Object clone()
clone in class java.lang.Objectpublic IntVector subvector(int i0, int i1)
i0 - the index of the first elementi1 - the index of the last elementpublic IntVector subvector(IntVector index)
index - the indexpublic void swap(int i,
int j)
i - the index ij - the index jpublic void shift(int i,
int j)
i - the index of the elementj - the index of the new positionpublic void shiftToEnd(int j)
j - the index of the elementpublic boolean isEmpty()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(int digits,
boolean trailing)
digits - number of digits to be showntrailing - true if trailing zeros are to be shownpublic java.lang.String getRevision()
getRevision in interface RevisionHandlerpublic static void main(java.lang.String[] args)