Logo Mibo

Occupancy Module

Functions and values

Function or value Description

describe span

Full Usage: describe span

Parameters:
Returns: string

How a span reads in a message: `6x4`, `radius 2`, or `one cell`.

span : InstanceSpan
Returns: string

identity grid

Full Usage: identity grid

Parameters:
Returns: Occupancy
Type parameters: 'T

An occupancy where every populated cell owns itself, built without consulting a span. For a map whose words never span.

grid : CellGrid2D<'T>
Returns: Occupancy

isIdentity span

Full Usage: isIdentity span

Parameters:
Returns: bool

The identity spans: `One`, `Span(1, 1)`, and `Radius 0` all cover one cell. A word that declares one of them places a single cell, and needs no expansion or geometry check.

span : InstanceSpan
Returns: bool

iterInWindow left top right bottom action occupancy

Full Usage: iterInWindow left top right bottom action occupancy

Parameters:
Modifiers: inline

Calls `action` with the cell and the rectangle of every anchor whose rectangle intersects the cell-space box. `left`, `top`, `right`, and `bottom` are inclusive cell coordinates, so an anchor that covers a window cell from outside it is still reported. The walk reads every anchor, so prefer it for maps up to a few thousand instances and hoist it out of a hot loop otherwise.

left : int
top : int
right : int
bottom : int
action : CellPoint -> CellRect -> unit
occupancy : Occupancy

owner x y occupancy

Full Usage: owner x y occupancy

Parameters:
Returns: CellPoint voption

The anchor that owns a cell: the cell itself when it is populated and plain, the covering anchor when a span covers it, `ValueNone` when the cell is empty or out of range. This is the query every consumer reads.

x : int
y : int
occupancy : Occupancy
Returns: CellPoint voption

rectOf at occupancy

Full Usage: rectOf at occupancy

Parameters:
Returns: CellRect voption

The bounding rectangle of the anchor that owns a cell, in offset space.

at : CellPoint
occupancy : Occupancy
Returns: CellRect voption

scan spanOf grid

Full Usage: scan spanOf grid

Parameters:
Returns: Result<Occupancy, string>
Type parameters: 'T

Expands every populated cell through `spanOf`, validates the result, and answers which instance owns each cell. A span claims the cells it covers: a plain cell inside a span's rectangle is covered rather than reported as a second instance. Fails with a cell-named reason when a span leaves the grid, when two spans overlap, when a span covers nothing, or when the span shape and the grid geometry disagree.

spanOf : 'T -> InstanceSpan
grid : CellGrid2D<'T>
Returns: Result<Occupancy, string>

Type something to start searching.