de.caff.generics.mda

## Interface TwoDimensionalAccess<T>

- All Superinterfaces:
    MultiDimensional, MultiDimensionalAccess<T>, MultiDimensionalReadAccess<T>, TwoDimensionalReadAccess<T>
  All Known Subinterfaces:
    TwoDimensionalBooleanAccess, TwoDimensionalByteAccess, TwoDimensionalCharAccess, TwoDimensionalDoubleAccess, TwoDimensionalFloatAccess, TwoDimensionalIntAccess, TwoDimensionalLongAccess, TwoDimensionalShortAccess
  All Known Implementing Classes:
    SmallTwoDimensionalArray, SmallTwoDimensionalBitArray, SmallTwoDimensionalBooleanArray, SmallTwoDimensionalByteArray, SmallTwoDimensionalCharArray, SmallTwoDimensionalDoubleArray, SmallTwoDimensionalFloatArray, SmallTwoDimensionalIntArray, SmallTwoDimensionalLongArray, SmallTwoDimensionalShortArray, TwoDimensionalArray, TwoDimensionalBooleanArray, TwoDimensionalByteArray, TwoDimensionalCharArray, TwoDimensionalDoubleArray, TwoDimensionalFloatArray, TwoDimensionalIntArray, TwoDimensionalLongArray, TwoDimensionalShortArray

      public interface TwoDimensionalAccess<T>
      extends TwoDimensionalReadAccess<T>, MultiDimensionalAccess<T>

  A two-dimensional rectangular array of items.
  Since:
    November 11, 2019
  Author:
    Rammi

- - ### Nested Class Summary

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

      `TwoDimensionalReadAccess.Base<TT>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static TwoDimensionalAccess<java.lang.Object>` | `EMPTY` Empty 2dim array.

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

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

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default void` | `changeAll(java.util.function.BiFunction<? super T,int[],? extends T> operator)` Change all elements in this multi-dimensional array.
    `default void` | `changeAll(java.util.function.Function<? super T,? extends T> operator)` Change all elements in this multi-dimensional array.
    `static <E> TwoDimensionalAccess<E>` | `createConstant(E constant, int sizeX, int sizeY)` Create a 2dimensional array with the given sizes with elements initialized to a given constant.
    `static <E> TwoDimensionalAccess<E>` | `createIndexed(java.util.function.BiFunction<java.lang.Integer,java.lang.Integer,? extends E> supplier, int sizeX, int sizeY)` Create a 2dimensional array with the given sizes with elements initialized by their indices.
    `static <E> TwoDimensionalAccess<E>` | `createNulled(int sizeX, int sizeY)` Create a 2dimensional array with the given sizes with elements initialized to null.
    `static <E> TwoDimensionalAccess<E>` | `createSupplied(java.util.function.Supplier<? extends E> supplier, int sizeX, int sizeY)` Create a 2dimensional array with the given sizes with elements initialized by a supplier.
    `static <E> TwoDimensionalAccess<E>` | `empty()` Get an empty 2dimensional access.
    `default void` | `fillByIndex(IntFunction2<? extends T> setter)` Set all values depending on their indexes.
    `default void` | `setElement(T value, int... indexes)` Set the element located at the given indexes.
    `void` | `setElementAt(T element, int ix, int iy)` Set the element at the given indexes.
    `default OneDimensionalAccess<T>` | `subAtX(int ix)` Get a 1-dimensional view of the row at the given X index.
    `default OneDimensionalAccess<T>` | `subAtY(int iy)` Get a 1-dimensional view of the column at the given X index.
    `default TwoDimensionalAccess<T>` | `transposed()` Get a transposed view of this 2-dimensional read access.
    `static <E> TwoDimensionalAccess<E>` | `zeroX(int numY)` Get e 2dimensional access with zero elements in X direction.
    `static <E> TwoDimensionalAccess<E>` | `zeroY(int numX)` Get e 2dimensional access with zero elements in Y direction.

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

      `asBase, equal, getElement, getElementAt, getNumDimensions, getNumElements, getSize, getSizes, hash, singleton, sizeX, sizeY, 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`

- - ### Field Detail

    - #### EMPTY

          static final TwoDimensionalAccess<java.lang.Object> EMPTY

      Empty 2dim array. Use `empty()` instead.

  - ### Method Detail

    - #### setElementAt

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

      Set the element at the given indexes.
      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)

    - #### setElement

          default void setElement(T value,
                                  int... indexes)

      Description copied from interface: `MultiDimensionalAccess`
      Set the element located at the given indexes.
      Specified by:
        `setElement` in interface `MultiDimensionalAccess<T>`
      Parameters:
        `value` - value to set at the location defined by the given indexes
        `indexes` - `MultiDimensional.getNumDimensions()` indexes inside the bounds defined by `MultiDimensional.getSizes()`

    - #### subAtX

          @NotNull
          default OneDimensionalAccess<T> subAtX(int ix)

      Get a 1-dimensional view of the row at the given X index. This is a view, so setting elements will change values in this array.
      Specified by:
        `subAtX` in interface `TwoDimensionalReadAccess<T>`
      Parameters:
        `ix` - X index
      Returns:
        1-dimensional array at `ix`

    - #### subAtY

          @NotNull
          default OneDimensionalAccess<T> subAtY(int iy)

      Get a 1-dimensional view of the column at the given X index. This is a view, so setting elements will change values in this array.
      Specified by:
        `subAtY` in interface `TwoDimensionalReadAccess<T>`
      Parameters:
        `iy` - Y index
      Returns:
        1-dimensional array at `iy`

    - #### transposed

          @NotNull
          default TwoDimensionalAccess<T> transposed()

      Description copied from interface: `TwoDimensionalReadAccess`
      Get a transposed view of this 2-dimensional read access.
      Specified by:
        `transposed` in interface `TwoDimensionalReadAccess<T>`
      Returns:
        transposed view where X and Y are interchanged

    - #### changeAll

          default void changeAll(@NotNull
                                 java.util.function.BiFunction<? super T,int[],? extends T> operator)

      Description copied from interface: `MultiDimensionalAccess`
      Change all elements in this multi-dimensional array. This will run over all elements and call the operator on each.
      Specified by:
        `changeAll` in interface `MultiDimensionalAccess<T>`
      Parameters:
        `operator` - operator to change the value, with the current value as first argument and the indexes as second, returns the new value

    - #### changeAll

          default void changeAll(@NotNull
                                 java.util.function.Function<? super T,? extends T> operator)

      Description copied from interface: `MultiDimensionalAccess`
      Change all elements in this multi-dimensional array. This will run over all elements and call the operator on each.
      Specified by:
        `changeAll` in interface `MultiDimensionalAccess<T>`
      Parameters:
        `operator` - operator to change the value, with the current value as argument

    - #### fillByIndex

          default void fillByIndex(@NotNull
                                   IntFunction2<? extends T> setter)

      Set all values depending on their indexes. This will call the setter for all indexes (x,y) and set the value at the given indexes from its result.
      Parameters:
        `setter` - setter which provides the value to set for each index combination

    - #### empty

          @NotNull
          static <E> TwoDimensionalAccess<E> empty()

      Get an empty 2dimensional access.
      Specified by:
        `empty` in interface `TwoDimensionalReadAccess<T>`
      Type Parameters:
        `E` - element type
      Returns:
        empty access with size 0 in both X and Y

    - #### zeroX

          @NotNull
          static <E> TwoDimensionalAccess<E> zeroX(int numY)

      Get e 2dimensional access with zero elements in X direction.
      Type Parameters:
        `E` - element type
      Parameters:
        `numY` - number of elements in Y direction
      Returns:
        access with no size in X

    - #### zeroY

          @NotNull
          static <E> TwoDimensionalAccess<E> zeroY(int numX)

      Get e 2dimensional access with zero elements in Y direction.
      Type Parameters:
        `E` - element type
      Parameters:
        `numX` - number of elements in X direction
      Returns:
        access with no size in Y

    - #### createNulled

          @NotNull
          static <E> TwoDimensionalAccess<E> createNulled(int sizeX,
                                                                   int sizeY)

      Create a 2dimensional array with the given sizes with elements initialized to null.
      Type Parameters:
        `E` - element type
      Parameters:
        `sizeX` - size in X direction
        `sizeY` - size in Y direction
      Returns:
        2dimensional array with the given size

    - #### createConstant

          @NotNull
          static <E> TwoDimensionalAccess<E> createConstant(@Nullable
                                                                     E constant,
                                                                     int sizeX,
                                                                     int sizeY)

      Create a 2dimensional array with the given sizes with elements initialized to a given constant.
      Type Parameters:
        `E` - element type
      Parameters:
        `constant` - constant to which all elements will be initialized
        `sizeX` - size in X direction
        `sizeY` - size in Y direction
      Returns:
        2dimensional array with the given size

    - #### createSupplied

          @NotNull
          static <E> TwoDimensionalAccess<E> createSupplied(@NotNull
                                                                     java.util.function.Supplier<? extends E> supplier,
                                                                     int sizeX,
                                                                     int sizeY)

      Create a 2dimensional array with the given sizes with elements initialized by a supplier.
      Type Parameters:
        `E` - element type
      Parameters:
        `supplier` - supplier for the initial elements
        `sizeX` - size in X direction
        `sizeY` - size in Y direction
      Returns:
        2dimensional array with the given size

    - #### createIndexed

          @NotNull
          static <E> TwoDimensionalAccess<E> createIndexed(@NotNull
                                                                    java.util.function.BiFunction<java.lang.Integer,java.lang.Integer,? extends E> supplier,
                                                                    int sizeX,
                                                                    int sizeY)

      Create a 2dimensional array with the given sizes with elements initialized by their indices.
      Type Parameters:
        `E` - element type
      Parameters:
        `supplier` - supplier for the initial elements, gets both X and Y index as arguments
        `sizeX` - size in X direction
        `sizeY` - size in Y direction
      Returns:
        2dimensional array with the given size