class

Collections::DenseGrid(T)

Inherits Enumerable < Reference < Object

A dense, fixed-size 2D grid backed by a flat buffer.

Where Grid is about traversal (neighbours, flood fill, shortest paths), DenseGrid is a mutable numeric canvas: O(1) cell access, rectangle updates, and whole-grid reductions. The right tool for "apply operations to regions, then tally the cells" puzzles.

Follows the same (row, col) convention as Grid. Includes Enumerable(T), so sum, count, min/max, tally, etc. are all available.

Constructors

new(rows : Int32, cols : Int32, fill : T)
Source

Instance methods

[](row : Int32, col : Int32) : T
Source
[]=(row : Int32, col : Int32, value : T) : T
Source
cols
Source
each

Must yield this collection's elements to the block.

Source
each_with_coords

Yield every cell together with its coordinates, in row-major order.

Source
fill_rect(row1 : Int32, col1 : Int32, row2 : Int32, col2 : Int32, value : T) : Nil

Set every cell in the inclusive rectangle to value.

Source
rows
Source
update_rect(row1 : Int32, col1 : Int32, row2 : Int32, col2 : Int32, & : T -> T) : Nil

Apply block to every cell in the inclusive rectangle, replacing each with the block's return value. Corners may be given in any order.

Source