Skip to content
FutureBlitz

    Install

    Import std.collections.grid

    Grid3

    std.collections.grid

    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].

    Examples

    Local voxels = Grid3<Bool>(4, 4, 4, False)
    voxels[1, 2, 3] = True
    Expect(voxels[1, 2, 3] && !voxels[0, 0, 0])
    Expect(voxels.Neighbors6(0, 0, 0).Count == 3)

    std/collections/grid.fb, line 173

    • @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.

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