public class DenseIntVector extends AbstractIntegerVector implements Serializable
IntegerVector
class whose data is back by an array.Constructor and Description |
---|
DenseIntVector(int length)
Creates a new vector of the specified length
|
DenseIntVector(int[] values)
Creates a new vector using the values of the specified array.
|
DenseIntVector(IntegerVector v)
Creates a new vector using the values of the specified vector.
|
Modifier and Type | Method and Description |
---|---|
int |
add(int index,
int delta)
Throws an
UnsupportedOperationException if called (vector is
unmodifiable). |
int |
get(int index)
Returns the value of this vector at the given index.
|
int |
length()
Return the size of the
Vector . |
double |
magnitude()
Returns the magnitude of this vector
|
void |
set(int index,
int value)
Throws an
UnsupportedOperationException if called (vector is
unmodifiable). |
equals, getValue, hashCode, set, toArray, toString
add
public DenseIntVector(int length)
length
- the length of this vectorpublic DenseIntVector(IntegerVector v)
v
- the intial values for this vector to havepublic DenseIntVector(int[] values)
values
- the intial values for this vector to havepublic int add(int index, int delta)
UnsupportedOperationException
if called (vector is
unmodifiable).add
in interface IntegerVector
add
in class AbstractIntegerVector
index
- index to change.delta
- the amount to change by.public int get(int index)
get
in interface IntegerVector
index
- index to retrieve.public int length()
Vector
.public double magnitude()
magnitude
in interface Vector<Integer>
magnitude
in class AbstractIntegerVector
public void set(int index, int value)
UnsupportedOperationException
if called (vector is
unmodifiable).set
in interface IntegerVector
set
in class AbstractIntegerVector
index
- index to set.value
- value to set in the vector.Copyright © 2012. All Rights Reserved.