MutableIntMatrix

Interface representing a specialised mutable matrix type for storing integers.

Inheritors

Types

Link copied to clipboard
object Companion : MutableMatrixCompanion<Int>

The companion object contains factory functions to create new instances with initialization.

Properties

Link copied to clipboard

The indices of all columns in the matrix

Link copied to clipboard
open val height: Int

The height of the matrix. This is effectively the same as maxWidth.

Link copied to clipboard
open override val indices: Iterable<Coordinate>

Specialised version of indices that doesn't check validity.

Link copied to clipboard
abstract val maxHeight: Int

The maximum x coordinate that is valid

Link copied to clipboard
abstract val maxWidth: Int

The maximum x coordinate that is valid which can be stored.

Link copied to clipboard

The indices of all rows in the matrix

Link copied to clipboard
open override val validator: (Int, Int) -> Boolean

For copying allow retrieving the/a validator function

Link copied to clipboard
open val width: Int

The width of the matrix. This is effectively the same as maxWidth.

Functions

Link copied to clipboard
open fun asSequence(): Sequence<Int>

Get all elements in the matrix as sequence.

Link copied to clipboard
open fun contentEquals(other: Matrix<*>): Boolean

Determine whether the content of this matrix is the same as the other by checking equality on the cell values. Sparse matrices with different dimensions, but the same valid indices can be equal.

open override fun contentEquals(other: SparseMatrix<*>): Boolean
abstract fun contentEquals(other: IntMatrix): Boolean
abstract fun contentEquals(other: SparseIntMatrix): Boolean
Link copied to clipboard
abstract override fun copyOf(): MutableIntMatrix

Creates a copy of the matrix of an appropriate type with the same content.

Link copied to clipboard
operator fun IntMatrix.div(other: Int): IntMatrix

Element-wise division of two matrices. It requires the other matrix to be strictly larger than the left side matrix. The result is a matrix of the size of the receiver.

Link copied to clipboard
operator fun MutableIntMatrix.divAssign(other: Int)

Element-wise division of two matrices into the receiver. It requires the other matrix to be strictly larger than the left side matrix.

Link copied to clipboard
open fun fill(value: Int)

Helper function to set values

Link copied to clipboard
inline fun <T> MutableSparseMatrix<T>.fill(setter: (Int, Int) -> T)

Helper function to set values into a MutableSparseMatrix.

inline fun MutableSparseIntMatrix.fill(setter: (Int, Int) -> Int)

Helper function to set values into a MutableSparseIntMatrix.

Link copied to clipboard
open fun forEach(p0: Consumer<in Int>)
Link copied to clipboard
inline fun <T> Matrix<T>.forEach(action: (T) -> Unit)

Perform the action for each value in the matrix. This version uses the non-sparse nature of the matrix.

inline fun <T> SparseMatrix<T>.forEach(action: (T) -> Unit)

Perform the action for each value in the (sparse) matrix.

Link copied to clipboard
inline fun Matrix<*>.forEachIndex(action: (Int, Int) -> Unit)

Perform the action for each index in the matrix. This version uses the non-sparse nature of the matrix.

inline fun SparseMatrix<*>.forEachIndex(action: (Int, Int) -> Unit)

Perform the action for each index in the (sparse) matrix. This skips sparse indices.

Link copied to clipboard
open operator fun get(pos: Coordinate): Int
abstract operator fun get(x: Int, y: Int): Int

Whatever the actual type, allow them to be read to read any value. Implementations are expected to use more precise return types.

Link copied to clipboard
open override fun isValid(x: Int, y: Int): Boolean

This implementation will just check that the coordinates are in range. There should be no reason to no use this default implementation.

open fun isValid(pos: Coordinate): Boolean

This function can be used to determine whether the given coordinates are valid. Returns true if valid. This function works on any value for the coordinates and should return false for all values out of range (x<0 || x>=[maxWidth]), (y<0 || y>=[maxHeight]).

Link copied to clipboard
open operator override fun iterator(): Iterator<Int>

Get an iterator over all elements in the (sparse) matrix.

Link copied to clipboard
inline fun <T, R> Matrix<T>.map(transform: (T) -> R): Matrix<R>

A map function that creates a new matrix with each cell mapped by transform.

inline fun <T, R> SparseMatrix<T>.map(transform: (T) -> R): SparseMatrix<R>

A map function that creates a new (sparse) matrix with each cell mapped by transform.

Link copied to clipboard
inline fun <T> Matrix<T>.mapBoolean(transform: (T) -> Boolean): BooleanMatrix

A map implementation that creates a boolean matrix based upon the receiver and the transformation function.

inline fun <T> SparseMatrix<T>.mapBoolean(transform: (T) -> Boolean): SparseBooleanMatrix

A map implementation that creates a boolean sparse matrix based upon the receiver and the transformation function.

Link copied to clipboard
inline fun <T> Matrix<T>.mapInt(transform: (T) -> Int): IntMatrix
inline fun IntMatrix.mapInt(transform: (Int) -> Int): IntMatrix

Create a new IntMatrix with the dimensions of the original where the value of each cell is the result of applying the transform to the value of the cell in the original.

inline fun <T> SparseMatrix<T>.mapInt(transform: (T) -> Int): SparseIntMatrix

Create a new SparseIntMatrix with the dimensions of the original where the value of each cell is the result of applying the transform to the value of the cell in the original.

inline fun <R> IntMatrix.mapInt(transform: (Int) -> R): Matrix<R>

Create a new Matrix with the dimensions of the original where the value of each cell is the result of applying the transform to the value of the cell in the original.

Link copied to clipboard
operator fun IntMatrix.minus(other: Int): IntMatrix

Element-wise subtraction of two matrices. It requires the other matrix to be strictly larger than the left side matrix. The result is a matrix of the size of the receiver.

Link copied to clipboard
operator fun MutableIntMatrix.minusAssign(other: Int)

Element-wise subtraction of two matrices into the receiver. It requires the other matrix to be strictly larger than the left side matrix.

Link copied to clipboard
operator fun IntMatrix.plus(other: Int): IntMatrix

Element-wise addition of two matrices. It requires the other matrix to be strictly larger than the left side matrix. The result is a matrix of the size of the receiver.

Link copied to clipboard
operator fun MutableIntMatrix.plusAssign(other: Int)

Element-wise addition of two matrices into the receiver. It requires the other matrix to be strictly larger than the left side matrix.

Link copied to clipboard
operator fun IntMatrix.rem(other: Int): IntMatrix

Element-wise remainder of two matrices. It requires the other matrix to be strictly larger than the left side matrix. The result is a matrix of the size of the receiver.

Link copied to clipboard
operator fun MutableIntMatrix.remAssign(other: Int)

Element-wise remainder of two matrices into the receiver. It requires the other matrix to be strictly larger than the left side matrix.

Link copied to clipboard
open operator fun set(pos: Coordinate, value: Int)
abstract operator override fun set(x: Int, y: Int, value: Int)

Set a specific value in the matrix

Link copied to clipboard
Link copied to clipboard
open override fun sum(): Int

Calculate the sum of all values.

Link copied to clipboard
operator fun IntMatrix.times(other: IntMatrix): IntMatrix

Multiply the two matrices (using matrix multiplication). This requires the width of the left matrix to be equal to the height of the right matrix.

Link copied to clipboard
abstract fun toFlatArray(): IntArray