invoke

open operator override fun <T> invoke(original: Matrix<T>): MutableMatrix<T>

Create a new mutable matrix that is initialized from the given matrix. Unlike the Matrix equivalent this version is guaranteed to create a new matrix, and it does not invoke [copyOf].

Return

A new MutableMatrix implementation that contains the same content as the original.

Parameters

original

The matrix to create a copy of


open operator override fun <T> invoke(width: Int, height: Int, initValue: T): MutableMatrix<T>

A simple array-like mutable matrix that contains the given initial value.

Parameters

width

The width of the matrix

height

The height of the matrix

initValue

The inititial value for each cell in the matrix.


open inline operator override fun <T> invoke(width: Int, height: Int, init: (Int, Int) -> T): MutableMatrix<T>

A simple array-like mutable matrix that contains the values given by the function. The values are assigned at construction.

Return

The resulting matrix (storing all values)

Parameters

width

The width of the matrix

height

The height of the matrix

init

Function that allows setting each cell in the matrix. Its parameters are the x and y coordinates.