public class MultiDimensionalDoubleArray extends AbstractBasicMultiDimensionalArray<java.lang.Double>
There is no enforced limit to the number of dimensions, but internally this is mapped to a standard Java array, which can only hold a limited number of elements.
Please note that although this implements
MultiDimensionalReadAccess.getElement(int...)
and
MultiDimensionalAccess.setElement(Object, int...)
to be used in generic circumstances the recommended methods
for getting and setting are
getValue(int...)
and
setValue(double, int...)
because they avoid unnecessary boxing.
indexLinearizer
Constructor and Description |
---|
MultiDimensionalDoubleArray(int... sizes)
Constructor.
|
MultiDimensionalDoubleArray(MultiDimensionalDoubleArray baseArray,
Function1<int[],int[]> indexConverter,
int... sizes)
Sub array constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Double |
change(java.util.function.Function<? super java.lang.Double,? extends java.lang.Double> operator,
int... indexes)
Change the value located at the given indexes.
|
double |
changeValue(java.util.function.DoubleUnaryOperator operator,
int... indexes)
Change the element at the given index combination.
|
boolean |
equals(java.lang.Object o) |
MultiDimensionalDoubleArray |
getCopy()
Get an independent copy.
|
java.lang.Double |
getElement(int... indexes)
Get the element located at the given indexes.
|
double |
getValue(int... indexes)
Get the element at the given index combination.
|
int |
hashCode() |
void |
setElement(java.lang.Double value,
int... indexes)
Set the element located at the given indexes.
|
void |
setValue(double elem,
int... indexes)
Set the element at the given index combination.
|
void |
setValuesFrom(double... values)
Set the elements of this array from the given values.
|
void |
setValuesFrom(MultiIndexLinearizer.Sequencer sequencer,
double... values)
Set the elements of this array from the given values
using the defined order.
|
MultiDimensionalDoubleArray |
sub(int... indexes)
Get access to a multi-dimensional sub array of this array.
|
asLinearArray, asLinearArray, asLinearArray, asLinearArray, getIndexLinearizer, getNumDimensions, getNumElements, getSize, getSizes, iterator, iterator, setFrom, setFrom, setFrom, toLinear, toList, toList, toList, toList
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
changeAll, changeAll, setAll, setFrom, setFrom
empty, linearized, visitAll, visitAll
public MultiDimensionalDoubleArray(int... sizes)
sizes
- of the dimensions of this array,
e.g. (2, 3, 4
} will create
an oblong array with size 2 in the first,
size 3 in the second, and size 4 in the third
dimension, containing 2*3*4 = 24
elementspublic MultiDimensionalDoubleArray(@NotNull MultiDimensionalDoubleArray baseArray, @NotNull Function1<int[],int[]> indexConverter, int... sizes)
This constructs a new read/write access to the given baseArray
allowing you to do nearly everything. As this gives a lot of power
be sure that the indexConverter
does "the right thing",
otherwise runtime exceptions will occur.
baseArray
- basic array to which accesses to this array are mappedindexConverter
- index converter which converts indexes into this array
to indexes into the basic array. Failing to fulfill
the restrictions (parameter length has to be
the same length as the following sizes
, and
fit into their ranges, and the result indexes have
to fit the restrictions of the baseArray
will result in runtime errorssizes
- sizes of the dimensions of this array@NotNull public java.lang.Double getElement(int... indexes)
MultiDimensionalReadAccess
indexes
- MultiDimensional.getNumDimensions()
indexes inside the bounds
defined by MultiDimensional.getSizes()
public void setElement(@NotNull java.lang.Double value, int... indexes)
MultiDimensionalAccess
value
- value to set at the location defined by the given indexesindexes
- MultiDimensional.getNumDimensions()
indexes inside the bounds
defined by MultiDimensional.getSizes()
@NotNull public java.lang.Double change(@NotNull java.util.function.Function<? super java.lang.Double,? extends java.lang.Double> operator, int... indexes)
MultiDimensionalAccess
This default implementation is only slightly more efficient than
a get
and set
sequence,
but implementing classes are encouraged to provide better implementations
(e.g. the index linearization has only to happen once).
operator
- operator to apply to the value at the location defined by the given indexes.
When used on a specialized primitive type array the operator
will never receive null
, and must not return null
.
In other cases this depends on usage.indexes
- MultiDimensional.getNumDimensions()
indexes inside the bounds
defined by MultiDimensional.getSizes()
public double getValue(int... indexes)
indexes
- indexes of the elementpublic void setValue(double elem, int... indexes)
elem
- element to setindexes
- indexes of the elementpublic double changeValue(@NotNull java.util.function.DoubleUnaryOperator operator, int... indexes)
operator
- operator to applyindexes
- indexes of the elementpublic void setValuesFrom(@NotNull double... values)
This uses MultiIndexLinearizer.getHighFastSequencer()
the internal order to copy values.
values
- values, at least AbstractBasicMultiDimensionalArray.getNumElements()
public void setValuesFrom(@NotNull MultiIndexLinearizer.Sequencer sequencer, @NotNull double... values)
sequencer
- sequencer defining the ordervalues
- values, at least@NotNull public MultiDimensionalDoubleArray sub(int... indexes)
indexes
- indexes of sub array, negative for open indexes,
0
or positive for fixed indexes, if
there are not enough indexes the missing ones
are considered openpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
@NotNull public MultiDimensionalDoubleArray getCopy()