invoke
Create a copy of the parameter using the copyOf
member function.
Return
The copy (from copyOf), depending on the type this may be the same object as the original.
Parameters
The matrix to create a copy of
Create a sparse matrix that has the given maximum X and Y values, is initialized with the parameter value, and uses the function to determine whether the cell exists. The returned matrix is immutable, but the validator is not required to always return the same value.
Return
The resulting matrix.
Parameters
The maximum width of the matrix
The maximum height of the matrix
The value for each cell in the matrix.
Function that determines whether the cell at the given coordinates exists.
Create a sparse matrix that has the given maximum X and Y values, has the given validator to determine sparseness and uses the given function to initialize the matrix (values set on construction).
Return
The resulting matrix.
Parameters
The width of the matrix
The height of the matrix
A function that is used to determine whether a particular coordinate is contained in the matrix.
An initialization function that sets the values for the matrix.
Create a sparse matrix with given maximum X and Y that is initialized using the given "constructor" function. This function invokes the initializer on construction only.
Example (creating a matrix with a hole in the middle):
val donut = SparseMatrix(3, 3) { x, y ->
when {
y == 0 -> value(x + 1)
y == 2 -> value(7-x)
x == 0 -> value(8)
x == 2 -> value(4)
else -> sparse
}
}
Return
A matrix initialized according to the init function
Parameters
The width of the matrix
The height of the matrix
The function used to initialize the matrix.