public class AtomicSparseVector extends Object implements SparseDoubleVector, Serializable
Vector which provides atomic concurrent access to
another Vector. This allows all reads to be done concurrently, while
limiting to writing to only one thread at a time. This does not provide a
specific implementation of a Vector, allowing any Vector
implementation to be made atomic.| Constructor and Description |
|---|
AtomicSparseVector(SparseDoubleVector v)
Creates a new
AtomicSparseVector decorating an already existing
Vector. |
| Modifier and Type | Method and Description |
|---|---|
double |
add(int index,
double delta)
Changes the value in this vector by a specified amount (optional
operation).
|
double |
addAndGet(int index,
double delta) |
double |
get(int index)
Returns the value of this vector at the given index.
|
double |
getAndAdd(int index,
double delta) |
int[] |
getNonZeroIndices()
Returns all the indices whose values are non-zero
|
Double |
getValue(int index)
Return the value of the vector at the given index as a
Number. |
SparseDoubleVector |
getVector()
Returns the
SparseDoubleVector that backs this instance. |
int |
length()
Return the size of the
Vector. |
double |
magnitude()
Returns the magnitude of this vector
|
void |
set(int index,
double value)
Sets the length in this vector (optional operation).
|
void |
set(int index,
Number value)
Set the value in the vector (optional operation).
|
double[] |
toArray()
Returns a double array representing this vector.
|
public AtomicSparseVector(SparseDoubleVector v)
AtomicSparseVector decorating an already existing
Vector.v - The vector to decorate.public double addAndGet(int index,
double delta)
public double getAndAdd(int index,
double delta)
public double add(int index,
double delta)
add in interface DoubleVectorindex - index to change.delta - the amount to change by.public double get(int index)
get in interface DoubleVectorindex - index to retrieve.public int[] getNonZeroIndices()
getNonZeroIndices in interface SparseVector<Double>public Double getValue(int index)
Number.getValue in interface DoubleVectorgetValue in interface Vector<Double>index - index to retrieve.public SparseDoubleVector getVector()
SparseDoubleVector that backs this instance.public double magnitude()
public void set(int index,
double value)
set in interface DoubleVectorindex - index to set.value - value to set in the vector.public void set(int index,
Number value)
public double[] toArray()
toArray in interface DoubleVectordouble array of this vector.Copyright © 2012. All Rights Reserved.