Skip to content
FutureBlitz

    Install

    Import std.collections.grid

    std.collections.grid

    Grid<T> and Grid3<T>: a fixed number of values in columns and rows, and in layers too, read and set by position, like a map's tiles or a volume's voxels. A position is (x, y), or (x, y, z), each from 0, and one outside the Grid panics where it's used. The cells are in one array, row by row, and layer by layer.

    std/collections/grid.fb

    Types

    Grid class

    Public Class Grid<T> Implements Iterable<T>, Cloneable

    A rectangle of cells, Width by Height, each a T, indexed as grid[x, y].

    std/collections/grid.fb, line 10

    • @PanicsAtCaller Public New(width: Int, height: Int, fill: T) constructor #

      A Grid width cells across and height down, each holding fill. A negative size panics, and so does one with more cells than an Int counts.

    • Public Property Width: Int property #

      How many cells wide it is.

    • Public Property Height: Int property #

      How many cells high it is.

    • Public Property Count: Int property #

      How many cells it has, Width times Height.

    • Public Method InBounds(x: Int, y: Int): Bool method #

      Whether (x, y) is one of the Grid's cells.

    • @PanicsAtCaller Operator [](x: Int, y: Int): T operator #

      The value at (x, y). One outside the Grid panics.

    • @PanicsAtCaller Operator []=(x: Int, y: Int, value: T) operator #

      Sets the value at (x, y) to value. One outside the Grid panics.

    • @PanicsAtCaller Public Method Neighbors4(x: Int, y: Int): (Int, Int)[] method #

      The positions beside (x, y) that are in the Grid: above, left, right, and below it.

    • @PanicsAtCaller Public Method Neighbors8(x: Int, y: Int): (Int, Int)[] method #

      The positions around (x, y) that are in the Grid, its corners too, row by row.

    • Public Method Fill(value: T) method #

      Gives every cell the value.

    • Public Method ToArray(): T[] method #

      The values, row by row, in a new array.

    • Public Method Clone(): Grid<T> method #

      A new Grid with the same size and values.

    • Public Method Iterate(): GridIterator<T> method #

      The values, row by row.

    GridIterator struct

    Public Struct GridIterator<T> Implements Iterator<T>

    Goes over a Grid's or a Grid3's cells, which never change in number.

    std/collections/grid.fb, line 112

    Grid3 class

    Public Class Grid3<T> Implements Iterable<T>, Cloneable

    A box of cells, Width by Height by Depth, each a T, indexed as grid[x, y, z].

    std/collections/grid.fb, line 146

    • @PanicsAtCaller Public New(width: Int, height: Int, depth: Int, fill: T) constructor #

      A Grid3 width cells across, height down, and depth deep, each holding fill. A negative size panics, and so does one with more cells than an Int counts.

    • Public Property Width: Int property #

      How many cells wide it is.

    • Public Property Height: Int property #

      How many cells high it is.

    • Public Property Depth: Int property #

      How many cells deep it is.

    • Public Property Count: Int property #

      How many cells it has, Width times Height times Depth.

    • Public Method InBounds(x: Int, y: Int, z: Int): Bool method #

      Whether (x, y, z) is one of the Grid3's cells.

    • @PanicsAtCaller Operator [](x: Int, y: Int, z: Int): T operator #

      The value at (x, y, z). One outside the Grid3 panics.

    • @PanicsAtCaller Operator []=(x: Int, y: Int, z: Int, value: T) operator #

      Sets the value at (x, y, z) to value. One outside the Grid3 panics.

    • @PanicsAtCaller Public Method Neighbors6(x: Int, y: Int, z: Int): (Int, Int, Int)[] method #

      The positions that share a face with (x, y, z) and are in the Grid3: the layer before, then above, left, right, and below, then the layer after.

    • @PanicsAtCaller Public Method Neighbors26(x: Int, y: Int, z: Int): (Int, Int, Int)[] method #

      The positions around (x, y, z) that are in the Grid3, its edges and corners too, layer by layer and row by row.

    • Public Method Fill(value: T) method #

      Gives every cell the value.

    • Public Method ToArray(): T[] method #

      The values, layer by layer and row by row, in a new array.

    • Public Method Clone(): Grid3<T> method #

      A new Grid3 with the same size and values.

    • Public Method Iterate(): GridIterator<T> method #

      The values, layer by layer and row by row.

    Extends

    Grid extend

    Extend Grid<T> Implements Equatable

    No doc comment.

    std/collections/grid.fb, line 124

    Grid extend

    Extend Grid<T> Implements Printable

    No doc comment.

    std/collections/grid.fb, line 133

    Grid3 extend

    Extend Grid3<T> Implements Equatable

    No doc comment.

    std/collections/grid.fb, line 281

    Grid3 extend

    Extend Grid3<T> Implements Printable

    No doc comment.

    std/collections/grid.fb, line 292

    Report an issue with this page or with FutureBlitz on GitHub.