public class MultiDimensionalFloatArray extends AbstractBasicMultiDimensionalArray<java.lang.Float>
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(float, int...)
because they avoid unnecessary boxing.
indexLinearizer
Constructor and Description |
---|
MultiDimensionalFloatArray(int... sizes)
Constructor.
|
MultiDimensionalFloatArray(MultiDimensionalFloatArray baseArray,
Function1<int[],int[]> indexConverter,
int... sizes)
Sub array constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Float |
change(java.util.function.Function<? super java.lang.Float,? extends java.lang.Float> operator,
int... indexes)
Change the value located at the given indexes.
|
float |
changeValue(FloatOperator1 operator,
int... indexes)
Change the element at the given index combination.
|
boolean |
equals(java.lang.Object o) |
MultiDimensionalFloatArray |
getCopy()
Get an independent copy.
|
java.lang.Float |
getElement(int... indexes)
Get the element located at the given indexes.
|
float |
getValue(int... indexes)
Get the element at the given index combination.
|
int |
hashCode() |
void |
setElement(java.lang.Float value,
int... indexes)
Set the element located at the given indexes.
|
void |
setValue(float elem,
int... indexes)
Set the element at the given index combination.
|
void |
setValuesFrom(float... values)
Set the elements of this array from the given values.
|
void |
setValuesFrom(MultiIndexLinearizer.Sequencer sequencer,
float... values)
Set the elements of this array from the given values
using the defined order.
|
MultiDimensionalFloatArray |
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 MultiDimensionalFloatArray(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 MultiDimensionalFloatArray(@NotNull MultiDimensionalFloatArray 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.Float getElement(int... indexes)
MultiDimensionalReadAccess
indexes
- MultiDimensional.getNumDimensions()
indexes inside the bounds
defined by MultiDimensional.getSizes()
public void setElement(@NotNull java.lang.Float 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.Float change(@NotNull java.util.function.Function<? super java.lang.Float,? extends java.lang.Float> 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 void setValuesFrom(@NotNull float... 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 float... values)
sequencer
- sequencer defining the ordervalues
- values, at leastpublic float getValue(int... indexes)
indexes
- indexes of the elementpublic void setValue(float elem, int... indexes)
elem
- element to setindexes
- indexes of the elementpublic float changeValue(@NotNull FloatOperator1 operator, int... indexes)
operator
- operator to applyindexes
- indexes of the element@NotNull public MultiDimensionalFloatArray 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 MultiDimensionalFloatArray getCopy()