Class MultiArrayChar

  • Direct Known Subclasses:
    MultiArrayChar.MultiArray1DChar, MultiArrayChar.MultiArray2DChar

    public class MultiArrayChar
    extends MultiArray<char[]>
    Implementation of MultiArray for char 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 char array.

    Author:
    Alexander Krimm
    • Constructor Detail

      • MultiArrayChar

        protected MultiArrayChar​(char[] elements,
                                 int[] dimensions,
                                 int offset)
    • Method Detail

      • wrap

        public static MultiArrayChar wrap​(char[] elements)
        Parameters:
        elements - Elements for the new MultiArray
        Returns:
        A MultiArrayChar1D with the supplied elements
      • wrap

        public static MultiArrayChar wrap​(char[] elements,
                                          int offset,
                                          int length)
        Parameters:
        elements - Elements for the new MultiArray
        offset - where in the backing array the element data starts
        length - number of elements to use from the elements array
        Returns:
        A MultiArrayChar1D with the supplied elements
      • wrap

        public static MultiArrayChar wrap​(char[] elements,
                                          int[] dimensions)
        Parameters:
        dimensions - The size of the new MultiArrayChar
        elements - The element data of the MultiArrayChar in row-major storage
        Returns:
        A MultiArrayChar or specialisation of it for the 1D and 2D case
      • wrap

        public static MultiArrayChar wrap​(char[] elements,
                                          int offset,
                                          int[] dimensions)
        Parameters:
        elements - The element data of the MultiArrayChar in row-major storage
        offset - where in the backing array the element data starts
        dimensions - The size of the new MultiArrayChar
        Returns:
        A MultiArrayChar or specialisation of it for the 1D and 2D case
      • allocate

        public static MultiArrayChar allocate​(int[] dimensions)
        Parameters:
        dimensions - Dimensions for the new MultiArray
        Returns:
        A new MultiArrayChar with a new empty backing array
      • setStrided

        public void setStrided​(int index,
                               char value)
        Set a value in the backing array using linear indexing.
        Parameters:
        value - the new value for the element
        index - the index of the element to set
      • set

        public void set​(int[] indices,
                        char value)
        Set a value in the MultiArray for given indices
        Parameters:
        value - The new value for the element
        indices - Indices for every dimension of the MultiArray
      • getStrided

        public char 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 char 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:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object