invoke

Create a new mutable matrix initialized from the source.


open operator override fun <T : Int> invoke(maxWidth: Int, maxHeight: Int, init: SparseMatrix.SparseInit<T>.(Int, Int) -> SparseMatrix.SparseValue<T>): MutableSparseMatrix<T>

Factory function that creates and initializes a (readonly) MutableSparseIntMatrix. maxWidth and maxHeight are used for the underlying array dimensions. This variant uses a sealed return type to determine whether a value is sparse or not.

Parameters

maxWidth

The maximum width allowed in the matrix

maxHeight

The maximum height allowed in the matrix

init

Function that determines the initial value for a location.


inline operator fun invoke(maxWidth: Int, maxHeight: Int, init: SparseMatrix.SparseInit<Int>.(Int, Int) -> SparseMatrix.SparseValue<Int>): MutableSparseIntMatrix

Create a SparseIntMatrix initialized with the given value

Parameters

maxWidth

Width of the matrix

maxHeight

Height of the matrix

init

The function initializing the matrix


open operator override fun <T : Int> invoke(maxWidth: Int, maxHeight: Int, initValue: T, validator: (Int, Int) -> Boolean): MutableSparseMatrix<T>

Create a new SparseMatrix with the given size and intialization function. It also requires a validate function

Parameters

maxWidth

The width of the matrix

maxHeight

The height of the matrix

initValue

An value for the non-sparse elements of the matrix

validator

A function that is used to determine whether a particular coordinate is contained in the matrix.


operator fun invoke(maxWidth: Int, maxHeight: Int, validator: (Int, Int) -> Boolean): MutableSparseIntMatrix

Create a MutableIntMatrix initialized with the default value of the Int type (0)

Parameters

maxWidth

Width of the matrix

maxHeight

Height of the matrix

validator

Function that determines which cells are part of the matrix


operator fun invoke(maxWidth: Int, maxHeight: Int, initValue: Int, validator: (Int, Int) -> Boolean): MutableSparseIntMatrix

Create a MutableSparseIntMatrix initialized with the given value

Parameters

maxWidth

Width of the matrix

maxHeight

Height of the matrix

initValue

The initial value for the elements

validator

The function that determines whether a given cell is valid.


open inline operator override fun <T : Int> invoke(maxWidth: Int, maxHeight: Int, noinline validator: (Int, Int) -> Boolean, init: (Int, Int) -> T): MutableSparseMatrix<T>

Create a new SparseMatrix subclass instance with the given size and intialization function. It also requires a validate function

Parameters

maxWidth

The width of the matrix

maxHeight

The height of the matrix

validator

A function that is used to determine whether a particular coordinate is contained in the matrix.

init

An initialization function that sets the values for the matrix.


inline operator fun invoke(maxWidth: Int, maxHeight: Int, noinline validator: (Int, Int) -> Boolean, init: (Int, Int) -> Int): MutableSparseIntMatrix

Create a MutableSparseIntMatrix initialized with the given value

Parameters

maxWidth

Width of the matrix

maxHeight

Height of the matrix

init

The function initializing the matrix

validator

The function that determines whether a given cell is valid.