de.caff.generics.mda

## Class SmallTwoDimensionalIntArray

- java.lang.Object
- - de.caff.generics.mda.TwoDimensionalReadAccess.Base<java.lang.Integer>
  - - de.caff.generics.mda.TwoDimensionalIntReadAccess.Base
    - - de.caff.generics.mda.SmallTwoDimensionalIntArray

- All Implemented Interfaces:
    MultiDimensional, MultiDimensionalAccess<java.lang.Integer>, MultiDimensionalReadAccess<java.lang.Integer>, TwoDimensionalAccess<java.lang.Integer>, TwoDimensionalIntAccess, TwoDimensionalIntReadAccess, TwoDimensionalReadAccess<java.lang.Integer>

      public class SmallTwoDimensionalIntArray
      extends TwoDimensionalIntReadAccess.Base
      implements TwoDimensionalIntAccess

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

  This internally maps to a one-dimensional int 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 `TwoDimensionalIntArray` 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.TwoDimensionalIntReadAccess

      `TwoDimensionalIntReadAccess.Base`

  - ### Field Summary

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

      `EMPTY`

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

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SmallTwoDimensionalIntArray(int ySize, int... values)` Constructor.
    `SmallTwoDimensionalIntArray(int xSize, int ySize)` Constructor.
    `SmallTwoDimensionalIntArray(int xSize, int ySize, java.util.function.IntBinaryOperator filler)` Initializing constructor.
    `SmallTwoDimensionalIntArray(TwoDimensionalIntReadAccess array)` Copy constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `SmallTwoDimensionalIntArray` | `copy()` Get a copy of this array.
    `int` | `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(int 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.TwoDimensionalIntReadAccess.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.TwoDimensionalIntAccess

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

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

      `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

    - #### SmallTwoDimensionalIntArray

          public SmallTwoDimensionalIntArray(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:
        `SmallTwoDimensionalIntArray(int, int, IntBinaryOperator)`

    - #### SmallTwoDimensionalIntArray

          public SmallTwoDimensionalIntArray(int xSize,
                                             int ySize,
                                             @NotNull
                                             java.util.function.IntBinaryOperator 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:
        `TwoDimensionalIntAccess.fillValuesByIndex(IntBinaryOperator)`

    - #### SmallTwoDimensionalIntArray

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

    - #### SmallTwoDimensionalIntArray

          public SmallTwoDimensionalIntArray(@NotNull
                                             TwoDimensionalIntReadAccess 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(int value,
                                 int ix,
                                 int iy)

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

    - #### getValueAt

          public int getValueAt(int ix,
                                int iy)

      Get the value at the given indexes.
      Specified by:
        `getValueAt` in interface `TwoDimensionalIntReadAccess`
      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.Integer>`
      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.Integer>`
      Returns:
        number of elements in Y direction

    - #### copy

          @NotNull
          public SmallTwoDimensionalIntArray copy()

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