Skip to main content
Module

x/structurae/index.ts>BinaryGrid

Data structures for high-performance JavaScript applications.
Latest
class BinaryGrid
extends Uint32Array
import { BinaryGrid } from "https://deno.land/x/structurae@4.0.1/index.ts";

Implements a grid or 2D matrix of bits.

Properties

columns: number

Number of columns in the grid.

readonly
rows: number

Number of rows in the grid.

size: number

Methods

getCoordinates(row: number, column?): [number, number]
getIndex(row: number, column?): number

Returns the index of an item holding the bit at given coordinates.

getValue(row: number, column: number): Bit

Returns the bit at given coordinates.

setValue(
row: number,
column: number,
value?: Bit,
): this

Sets the bit at given coordinates.

toArrays(): Array<Array<Bit>>

Creates an array of arrays representing rows of the grid.

Static Properties

readonly
[Symbol.species]: Uint32ArrayConstructor

Static Methods

create(rows: number, columns?): BinaryGrid

Creates a binary grid of specified dimensions.

fromArrays(arrays: Array<Array<Bit>>): BinaryGrid

Creates a new binary grid from an array of arrays representing rows and item value of the grid.

getLength(rows: number, columns?): number

Returns the length of the underlying TypedArray required to hold a grid of specified dimensions.