public class AtomicVector extends Object implements DoubleVector, 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 |
|---|
AtomicVector(DoubleVector v)
Creates a new
AtomicVector 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) |
Double |
getValue(int index)
Returns the value of the vector at the given index as a
Double. |
DoubleVector |
getVector()
Returns the
DoubleVector 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 AtomicVector(DoubleVector v)
AtomicVector 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 Double getValue(int index)
Double.getValue in interface DoubleVectorgetValue in interface Vector<Double>index - index to retrieve.public DoubleVector getVector()
DoubleVector 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.