de.caff.generics.mda

## Class SmallTwoDimensionalArray<T>

- java.lang.Object
- - de.caff.generics.mda.TwoDimensionalReadAccess.Base<T>
  - - de.caff.generics.mda.SmallTwoDimensionalArray<T>

- Type Parameters:
    `T` - element type of this array
  All Implemented Interfaces:
    MultiDimensional, MultiDimensionalAccess<T>, MultiDimensionalReadAccess<T>, TwoDimensionalAccess<T>, TwoDimensionalReadAccess<T>

      public class SmallTwoDimensionalArray<T>
      extends TwoDimensionalReadAccess.Base<T>
      implements TwoDimensionalAccess<T>

  Two-dimensional array of objkects values optimized for small sizes.

  This internally maps to a one-dimensional array which is created faster. Because of the mapping the size of the dimensions is restricted in a way that the number of elements in this array (i.e. the product of its X and Y size) is less than or equal to`Integer.MAX_VALUE`. Use `TwoDimensionalArray` if you are not sure to always obey this restriction.

  Since:
    January 26, 2021
  Author:
    Rammi

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface de.caff.generics.mda.TwoDimensionalReadAccess

      `TwoDimensionalReadAccess.Base<TT>`

  - ### Field Summary

    - ### Fields inherited from interface de.caff.generics.mda.TwoDimensionalAccess

      `EMPTY`

    - ### Fields inherited from interface de.caff.generics.mda.MultiDimensionalReadAccess

      `EMPTY0, EMPTY1, EMPTY2, EMPTY3, EMPTY4, EMPTY5, EMPTY6, EMPTY7`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SmallTwoDimensionalArray(int xSize, int ySize)` Constructor.
    `SmallTwoDimensionalArray(int xSize, int ySize, IntFunction2<T> filler)` Initializing constructor.
    `SmallTwoDimensionalArray(int ySize, T... values)` Constructor.
    `SmallTwoDimensionalArray(TwoDimensionalReadAccess<? extends T> array)` Copy constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `SmallTwoDimensionalArray<T>` | `copy()` Get a copy of this array.
    `T` | `getElementAt(int ix, int iy)` Get the element at the given indexes.
    `void` | `invertX()` Invert the row order in X direction.
    `void` | `invertY()` Invert the row order in Y direction.
    `void` | `setElementAt(T element, int ix, int iy)` Set the element at the given indexes.
    `int` | `sizeX()` Get the number of elements in X direction.
    `int` | `sizeY()` Get the number of elements in Y direction

    - ### Methods inherited from class de.caff.generics.mda.TwoDimensionalReadAccess.Base

      `asBase, equals, hashCode, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface de.caff.generics.mda.TwoDimensionalAccess

      `changeAll, changeAll, createConstant, createIndexed, createNulled, createSupplied, empty, fillByIndex, setElement, subAtX, subAtY, transposed, zeroX, zeroY`

    - ### Methods inherited from interface de.caff.generics.mda.TwoDimensionalReadAccess

      `asBase, equal, getElement, getNumDimensions, getNumElements, getSize, getSizes, hash, singleton, toString, view, visitAll, visitAll, xIterable, xIterator, yIterable, yIterator`

    - ### Methods inherited from interface de.caff.generics.mda.MultiDimensionalAccess

      `change, setAll, setFrom, setFrom, setFrom`

    - ### Methods inherited from interface de.caff.generics.mda.MultiDimensionalReadAccess

      `empty, linearized`

- - ### Constructor Detail

    - #### SmallTwoDimensionalArray

          public SmallTwoDimensionalArray(int xSize,
                                          int ySize)

      Constructor. This fills all elements with `0.0` values.
      Parameters:
        `xSize` - X size of array
        `ySize` - Y size of array
      See Also:
        `SmallTwoDimensionalArray(int, int, IntFunction2)`

    - #### SmallTwoDimensionalArray

          public SmallTwoDimensionalArray(int xSize,
                                          int ySize,
                                          @NotNull
                                          IntFunction2<T> filler)

      Initializing constructor.
      Parameters:
        `xSize` - X size of array
        `ySize` - Y size of array
        `filler` - setter function which provides the value to set for each index combination
      See Also:
        `TwoDimensionalAccess.fillByIndex(IntFunction2)`

    - #### SmallTwoDimensionalArray

          @SafeVarargs
          public SmallTwoDimensionalArray(int ySize,
                                                       T... values)

      Constructor.
      Parameters:
        `ySize` - size in y direction
        `values` - values in order, the first `ySize` values will become row 0, the second `ySize` values row 1, and so on. Needs a multiple of ySize values.

    - #### SmallTwoDimensionalArray

          public SmallTwoDimensionalArray(@NotNull
                                          TwoDimensionalReadAccess<? extends T> array)

      Copy constructor.
      Parameters:
        `array` - array to copy

  - ### Method Detail

    - #### invertX

          public void invertX()

      Invert the row order in X direction.

    - #### invertY

          public void invertY()

      Invert the row order in Y direction.

    - #### setElementAt

          public void setElementAt(T element,
                                   int ix,
                                   int iy)

      Description copied from interface: `TwoDimensionalAccess`
      Set the element at the given indexes.
      Specified by:
        `setElementAt` in interface `TwoDimensionalAccess<T>`
      Parameters:
        `element` - element to set
        `ix` - index in X direction from `0` (included) to `TwoDimensionalReadAccess.sizeX()` (excluded)
        `iy` - index in Y direction from `0` (included) to `TwoDimensionalReadAccess.sizeY()` (excluded)

    - #### getElementAt

          public T getElementAt(int ix,
                                int iy)

      Description copied from interface: `TwoDimensionalReadAccess`
      Get the element at the given indexes.
      Specified by:
        `getElementAt` in interface `TwoDimensionalReadAccess<T>`
      Parameters:
        `ix` - index in X direction from `0` (included) to `TwoDimensionalReadAccess.sizeX()` (excluded)
        `iy` - index in Y direction from `0` (included) to `TwoDimensionalReadAccess.sizeY()` (excluded)
      Returns:
        element at the given indexes

    - #### sizeX

          public int sizeX()

      Description copied from interface: `TwoDimensionalReadAccess`
      Get the number of elements in X direction.
      Specified by:
        `sizeX` in interface `TwoDimensionalReadAccess<T>`
      Returns:
        number of elements in X direction

    - #### sizeY

          public int sizeY()

      Description copied from interface: `TwoDimensionalReadAccess`
      Get the number of elements in Y direction
      Specified by:
        `sizeY` in interface `TwoDimensionalReadAccess<T>`
      Returns:
        number of elements in Y direction

    - #### copy

          @NotNull
          public SmallTwoDimensionalArray<T> copy()

      Get a copy of this array.
      Returns:
        copy of this array