Package de.gsi.dataset.spi.utils
Class MultiArrayObject<U>
- java.lang.Object
-
- de.gsi.dataset.spi.utils.MultiArray<U[]>
-
- de.gsi.dataset.spi.utils.MultiArrayObject<U>
-
- Direct Known Subclasses:
MultiArrayObject.MultiArray1DObject,MultiArrayObject.MultiArray2DObject
public class MultiArrayObject<U> extends MultiArray<U[]>
Implementation of MultiArray for U values. Also contains subtypes for 1D and 2D Arrays which allow more convenient and more efficient access.The data is stored in row-major in a flat U array.
- Author:
- Alexander Krimm
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMultiArrayObject.MultiArray1DObject<U>Specialisation for the 1D case to allow for easier and more efficient usagestatic classMultiArrayObject.MultiArray2DObject<U>Specialisation for the 2D case to allow for easier and more efficient usage
-
Field Summary
-
Fields inherited from class de.gsi.dataset.spi.utils.MultiArray
dimensions, elements, offset, strides
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMultiArrayObject(U[] elements, int[] dimensions, int offset)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> MultiArrayObjectallocate(int[] dimensions, java.lang.Class<T[]> clazz)booleanequals(java.lang.Object o)Uget(int[] indices)Get a value in the MultiArray.UgetStrided(int index)Get a value in the backing array using linear indexing.inthashCode()voidset(int[] indices, U value)Set a value in the MultiArray for given indicesvoidsetStrided(int index, U value)Set a value in the backing array using linear indexing.static <T> MultiArrayObjectwrap(T[] elements)static <T> MultiArrayObjectwrap(T[] elements, int[] dimensions)static <T> MultiArrayObjectwrap(T[] elements, int offset, int length)static <T> MultiArrayObjectwrap(T[] elements, int offset, int[] dimensions)-
Methods inherited from class de.gsi.dataset.spi.utils.MultiArray
elements, getDimensions, getElementsCount, getIndex, getIndices, getOffset, toString, wrap, wrap, wrap, wrap
-
-
-
-
Constructor Detail
-
MultiArrayObject
protected MultiArrayObject(U[] elements, int[] dimensions, int offset)
-
-
Method Detail
-
wrap
public static <T> MultiArrayObject wrap(T[] elements)
- Parameters:
elements- Elements for the new MultiArray- Returns:
- A MultiArrayU1D with the supplied elements
-
wrap
public static <T> MultiArrayObject wrap(T[] elements, int offset, int length)
- Parameters:
elements- Elements for the new MultiArrayoffset- where in the backing array the element data startslength- number of elements to use from the elements array- Returns:
- A MultiArrayU1D with the supplied elements
-
wrap
public static <T> MultiArrayObject wrap(T[] elements, int[] dimensions)
- Parameters:
dimensions- The size of the new MultiArrayUelements- The element data of the MultiArrayU in row-major storage- Returns:
- A MultiArrayU or specialisation of it for the 1D and 2D case
-
wrap
public static <T> MultiArrayObject wrap(T[] elements, int offset, int[] dimensions)
- Parameters:
elements- The element data of the MultiArrayU in row-major storageoffset- where in the backing array the element data startsdimensions- The size of the new MultiArrayU- Returns:
- A MultiArrayU or specialisation of it for the 1D and 2D case
-
allocate
public static <T> MultiArrayObject allocate(int[] dimensions, java.lang.Class<T[]> clazz)
- Parameters:
dimensions- Dimensions for the new MultiArray- Returns:
- A new MultiArrayU with a new empty backing array
-
setStrided
public void setStrided(int index, U value)Set a value in the backing array using linear indexing.- Parameters:
value- the new value for the elementindex- the index of the element to set
-
set
public void set(int[] indices, U value)Set a value in the MultiArray for given indices- Parameters:
value- The new value for the elementindices- Indices for every dimension of the MultiArray
-
getStrided
public U getStrided(int index)
Get a value in the backing array using linear indexing.- Parameters:
index- the index of the element to set- Returns:
- The element value
-
get
public U get(int[] indices)
Get a value in the MultiArray.- Parameters:
indices- the indices of the element to set- Returns:
- The element value
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-