public class ArrayAccessor<T> extends java.lang.Object implements IArrayAccessor<T>
Constructor and Description |
---|
ArrayAccessor(int[] dimensions,
T[] array)
Construct this from a dimensions array and a data array.
|
ArrayAccessor(int[] dimensions,
T[] array,
boolean rightIndicesFaster)
Construct this from a dimensions array, a data array, and a boolean.
|
Modifier and Type | Method and Description |
---|---|
T[] |
getArray() |
int[] |
getDimensions() |
T |
getElementAt(int[] coordinates) |
int |
getIndexAt(int[] coordinates)
Calculates the index at the given coordinates.
|
java.util.List<Slice<T>> |
getSlices(int dimR,
int dimC)
Get the list of 2-D slices of the multi-dimensional array along the given
dimensions.
|
SubspaceSlice<T> |
getSubspaceSliceAt(int[] coordinates,
int... subDims) |
java.util.List<SubspaceSlice<T>> |
getSubspaceSlices(int... dims)
Get all the subspace slices of the multi-dimensional array.
|
public ArrayAccessor(int[] dimensions, T[] array)
ArrayAccessor
with rightIndicesFaster
= true
.dimensions
- An integer array. Should not be null or empty.array
- A data array whose size should be the product of the values in
dimensions.java.lang.IllegalArgumentException
- if dimensions is null, or empty or the size of array does not
equal the product of the elements in dimensions.public ArrayAccessor(int[] dimensions, T[] array, boolean rightIndicesFaster)
dimensions
- An integer array. Should not be null or empty.array
- A data array whose size should be the product of the values in
dimensions.rightIndicesFaster
- A boolean. If this is true
, the array is row major ordered
(that is, rightmost index fastest). If this is false, the array is
column major ordered (that is, leftmost index fastest).java.lang.IllegalArgumentException
- if dimensions is null, or empty or the size of array does not
equal the product of the elements in dimensions.public T[] getArray()
getArray
in interface IArrayAccessor<T>
public int[] getDimensions()
getDimensions
in interface IArrayAccessor<T>
public T getElementAt(int[] coordinates)
getElementAt
in interface IArrayAccessor<T>
coordinates
- The coordinates of the element to retrieve.public int getIndexAt(int[] coordinates)
getIndexAt
in interface IArrayAccessor<T>
coordinates
- The coordinates at all dimensions. Must be the same length as
the length of dimensions.public java.util.List<Slice<T>> getSlices(int dimR, int dimC)
IArrayAccessor
getSlices
in interface IArrayAccessor<T>
dimR
- The first dimension of the slices.dimC
- The second dimension of the slices.List
of Slice
s.public SubspaceSlice<T> getSubspaceSliceAt(int[] coordinates, int... subDims)
getSubspaceSliceAt
in interface IArrayAccessor<T>
coordinates
- The coordinates where the subspace is located.subDims
- The indices for the dimensions of the subspace.public java.util.List<SubspaceSlice<T>> getSubspaceSlices(int... dims)
IArrayAccessor
getSubspaceSlices
in interface IArrayAccessor<T>
List
of SubspaceSlice
s.