kcl.waterloo.graphics.data
Class PrimitiveDoubleBuffer
- java.lang.Object
-
- kcl.waterloo.graphics.data.PrimitiveDoubleBuffer
-
public class PrimitiveDoubleBuffer extends java.lang.ObjectWrapper class for a double[]. This class permits double arrays contained as a property in the wrapper to be passed by reference - useful in environments that support that for Java objects but not for primitive data types e.g. MATLAB
-
-
Constructor Summary
Constructors Constructor and Description PrimitiveDoubleBuffer()Constructs a new instance with a zero length vector.PrimitiveDoubleBuffer(double[] arr)Constructs a new instance copying the input.PrimitiveDoubleBuffer(double[] arr, boolean copyFlag)Constructs a new instance.PrimitiveDoubleBuffer(int sz)Constructs a new instance with a vector of length sz.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description double[]getData()Returns a copy of the wrapped double[] vectordouble[]getDataRef()Returns a reference to the wrapped data vector.intgetDimension()Returns the length of the wrapped double[]doublegetEntry(int index)Returns the entry at specified indexvoidsetData(double[] arr)Replaces the current wrapped double[] with a copy of the input.voidsetDataRef(double[] arr)Replaces the current wrapped double[] with a reference to the input.voidsetEntry(int index, double val)Sets the entry at the specified index
-
-
-
Constructor Detail
-
PrimitiveDoubleBuffer
public PrimitiveDoubleBuffer()
Constructs a new instance with a zero length vector.
-
PrimitiveDoubleBuffer
public PrimitiveDoubleBuffer(int sz)
Constructs a new instance with a vector of length sz.- Parameters:
sz-
-
PrimitiveDoubleBuffer
public PrimitiveDoubleBuffer(double[] arr)
Constructs a new instance copying the input.- Parameters:
arr-
-
PrimitiveDoubleBuffer
public PrimitiveDoubleBuffer(double[] arr, boolean copyFlag)Constructs a new instance. If copyFlag is true the input is copied, if false is is referenced in the wrapper.- Parameters:
arr-copyFlag-
-
-
Method Detail
-
getData
public double[] getData()
Returns a copy of the wrapped double[] vector- Returns:
- the data
-
getDataRef
public final double[] getDataRef()
Returns a reference to the wrapped data vector. Note: This exposes a reference to the data vector to external code.- Returns:
- a reference to the data vector.
-
setData
public final void setData(double[] arr)
Replaces the current wrapped double[] with a copy of the input.- Parameters:
arr-
-
setDataRef
public final void setDataRef(double[] arr)
Replaces the current wrapped double[] with a reference to the input. NOTE: As the reference is external, this exposesdataas an external mutable array.- Parameters:
arr-
-
getEntry
public double getEntry(int index)
Returns the entry at specified index- Parameters:
index-- Returns:
- a double
-
setEntry
public void setEntry(int index, double val)Sets the entry at the specified index- Parameters:
index-val-
-
getDimension
public int getDimension()
Returns the length of the wrapped double[]- Returns:
- an int
-
-
DMelt 3.0 © DataMelt by jWork.ORG