public class CompactSparseIntegerVector extends AbstractIntegerVector implements SparseIntegerVector, Serializable, Iterable<IntegerEntry>
IntegerVector class whose data is back by a compact sparse
array. Access to the elements of this vector is O(log(n)).| Constructor and Description |
|---|
CompactSparseIntegerVector(int length)
Creates a new vector of the specified length
|
CompactSparseIntegerVector(int[] values)
Creates a new vector using the non-zero values of the specified array.
|
CompactSparseIntegerVector(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[] |
getNonZeroIndices()
Returns all the indices whose values are non-zero
|
Iterator<IntegerEntry> |
iterator()
Returns an iterator over all the non-zero indices and values in this
vector.
|
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, toStringaddclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetValue, toArraypublic CompactSparseIntegerVector(int length)
length - the length of this vectorpublic CompactSparseIntegerVector(IntegerVector v)
v - the intial values for this vector to havepublic CompactSparseIntegerVector(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 IntegerVectoradd in class AbstractIntegerVectorindex - index to change.delta - the amount to change by.public int get(int index)
get in interface IntegerVectorindex - index to retrieve.public int[] getNonZeroIndices()
getNonZeroIndices in interface SparseVector<Integer>public Iterator<IntegerEntry> iterator()
iterator in interface Iterable<IntegerEntry>public int length()
Vector.public double magnitude()
magnitude in interface Vector<Integer>magnitude in class AbstractIntegerVectorpublic void set(int index,
int value)
UnsupportedOperationException if called (vector is
unmodifiable).set in interface IntegerVectorset in class AbstractIntegerVectorindex - index to set.value - value to set in the vector.Copyright © 2012. All Rights Reserved.