de.caff.generics.mda

## Class SmallTwoDimensionalShortArray

- java.lang.Object
- - de.caff.generics.mda.TwoDimensionalReadAccess.Base<java.lang.Short>
  - - de.caff.generics.mda.TwoDimensionalShortReadAccess.Base
    - - de.caff.generics.mda.SmallTwoDimensionalShortArray

- All Implemented Interfaces:
    MultiDimensional, MultiDimensionalAccess<java.lang.Short>, MultiDimensionalReadAccess<java.lang.Short>, TwoDimensionalAccess<java.lang.Short>, TwoDimensionalReadAccess<java.lang.Short>, TwoDimensionalShortAccess, TwoDimensionalShortReadAccess

      public class SmallTwoDimensionalShortArray
      extends TwoDimensionalShortReadAccess.Base
      implements TwoDimensionalShortAccess

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

  This internally maps to a one-dimensional short 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 multiplication of its X and Y size) is less than `Integer.MAX_VALUE`. Use `TwoDimensionalShortArray` if you are not sure to always obey this restriction.

  Since:
    November 11, 2019
  Author:
    Rammi

- - ### Nested Class Summary

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

      `TwoDimensionalShortReadAccess.Base`

  - ### Field Summary

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

      `EMPTY`

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

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SmallTwoDimensionalShortArray(int xSize, int ySize)` Constructor.
    `SmallTwoDimensionalShortArray(int xSize, int ySize, IntToShortFunction2 filler)` Initializing constructor.
    `SmallTwoDimensionalShortArray(int ySize, short... values)` Constructor.
    `SmallTwoDimensionalShortArray(TwoDimensionalShortReadAccess array)` Copy constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `SmallTwoDimensionalShortArray` | `copy()` Get a copy of this array.
    `short` | `getValueAt(int ix, int iy)` Get the value at the given indexes.
    `void` | `invertX()` Invert the row order in X direction.
    `void` | `invertY()` Invert the row order in Y direction.
    `void` | `setValueAt(short value, int ix, int iy)` Set the value 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.TwoDimensionalShortReadAccess.Base

      `asBase`

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

      `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.TwoDimensionalShortAccess

      `changeAllValues, changeValueAt, fillValuesByIndex, setElementAt, subAtX, subAtY, transposed`

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

      `asBase, getElementAt, singleton`

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

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

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

      `equal, getElement, getNumDimensions, getNumElements, getSize, getSizes, hash, 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

    - #### SmallTwoDimensionalShortArray

          public SmallTwoDimensionalShortArray(int xSize,
                                               int ySize)

      Constructor. This fills all elements with `0.0` values.
      Parameters:
        `xSize` - X size of array
        `ySize` - Y size of array
      Throws:
        `java.lang.IllegalArgumentException` - on negative sizes or if linearized size becoms too large
      See Also:
        `SmallTwoDimensionalShortArray(int, int, IntToShortFunction2)`

    - #### SmallTwoDimensionalShortArray

          public SmallTwoDimensionalShortArray(int xSize,
                                               int ySize,
                                               @NotNull
                                               IntToShortFunction2 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
      Throws:
        `java.lang.IllegalArgumentException` - on negative sizes or if linearized size becoms too large
      See Also:
        `TwoDimensionalShortAccess.fillValuesByIndex(IntToShortFunction2)`

    - #### SmallTwoDimensionalShortArray

          public SmallTwoDimensionalShortArray(int ySize,
                                               short... 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.

    - #### SmallTwoDimensionalShortArray

          public SmallTwoDimensionalShortArray(@NotNull
                                               TwoDimensionalShortReadAccess array)

      Copy constructor.
      Parameters:
        `array` - array to copy
      Throws:
        `java.lang.IllegalArgumentException` - on negative sizes or if linearized size becoms too large

  - ### Method Detail

    - #### invertX

          public void invertX()

      Invert the row order in X direction.

    - #### invertY

          public void invertY()

      Invert the row order in Y direction.

    - #### setValueAt

          public void setValueAt(short value,
                                 int ix,
                                 int iy)

      Set the value at the given indexes.
      Specified by:
        `setValueAt` in interface `TwoDimensionalShortAccess`
      Parameters:
        `value` - value to set
        `ix` - X index
        `iy` - Y index

    - #### getValueAt

          public short getValueAt(int ix,
                                  int iy)

      Get the value at the given indexes.
      Specified by:
        `getValueAt` in interface `TwoDimensionalShortReadAccess`
      Parameters:
        `ix` - X index
        `iy` - Y index
      Returns:
        value at given index

    - #### sizeX

          public int sizeX()

      Description copied from interface: `TwoDimensionalReadAccess`
      Get the number of elements in X direction.
      Specified by:
        `sizeX` in interface `TwoDimensionalReadAccess<java.lang.Short>`
      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<java.lang.Short>`
      Returns:
        number of elements in Y direction

    - #### copy

          @NotNull
          public SmallTwoDimensionalShortArray copy()

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