MutableGrid

The mutable version of the library's Grid structure.

MutableGrid allows its Grid.States to be changed out, though the Grid's basic shape is actually immutable. That shape is defined by its row and column counts, the lines which are inset, and whether edge lines are enabled.

Constructors

Link copied to clipboard
constructor(rowCount: Int, columnCount: Int, insetEvenLines: Boolean = false, enableEdgeLines: Boolean = false, initial: Map<Grid.Address, Grid.State>? = null)

Properties

Link copied to clipboard
open override val columnCount: Int

The number of linear columns in the Grid.

Link copied to clipboard
open override val enableEdgeLines: Boolean

Whether edge lines are enabled.

Link copied to clipboard
open override val insetEvenLines: Boolean

Whether the even rows and columns are inset, or the odd ones.

Link copied to clipboard
open override val rowCount: Int

The number of linear rows in the Grid.

Link copied to clipboard
open override val size: Int

The total cell count, named size for consistency with other collections.

Functions

Link copied to clipboard
fun MutableGrid.change(address: Grid.Address, isVisible: Boolean = this[address].isVisible, isSelected: Boolean = this[address].isSelected)

Updates the Grid.State at the given Grid.Address.

Link copied to clipboard
open override fun copy(changes: Map<Grid.Address, Grid.State>): MutableGrid

Returns a new, modified instance of this Grid if changes actually causes any changes.

open override fun copy(address: Grid.Address, change: Grid.State): MutableGrid

Returns a modified copy of this Grid if change actually causes a change.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun findAddress(row: Int, column: Int): Grid.Address?

Returns the appropriate Grid.Address if row and column are valid coordinates.

Link copied to clipboard
open override fun forEach(action: (Grid.Address, Grid.State) -> Unit)

Iterator function for Grid.

Link copied to clipboard
open operator override fun get(address: Grid.Address): Grid.State

The Address-indexed get operator for Grid.

open operator override fun get(row: Int, column: Int): Grid.State

The Int-indexed get operator for Grid.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun isLineInset(index: Int): Boolean

Returns whether the given line – row or column – is inset, per the insetEvenLines property.

Link copied to clipboard
open override fun isValidAddress(row: Int, column: Int): Boolean

Returns true if row and column are valid coordinates for the current grid specifications.

Link copied to clipboard
operator fun set(address: Grid.Address, state: Grid.State)

The Address-indexed set operator for MutableGrid.

operator fun set(row: Int, column: Int, state: Grid.State)

The Int-indexed set operator for MutableGrid.

Link copied to clipboard

Toggles the Grid.State.isSelected value at the given Grid.Address.

Link copied to clipboard
open override fun toString(): String