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