type of labels in this set, compared for equality using ===.
Add a rectangle of grid cells to the region labeled by the given label (or create such a labeled region if it was not already present), if it does not conflict with other existing labeled regions.
Two regions with distinct labels conflict if any of their grid cells share an edge.
label of region
rectangle to add to labeled region. Required to have nonzero area and integer coordinates
drawn from {0...gridSize
}.
Get the bounding box of a labeled region.
label of region
the smallest rectangle that contains all the grid cells in the labeled region, or undefined if no region with that label exists.
Get the labels of regions that intersect the given rectangle (where the intersection contains at least one full grid cell).
rectangle to query. Its coordinates must be integers in {0...gridSize
}.
the labels of regions in this set whose intersection with rect contains at least one grid cell
Generated using TypeDoc
A mutable set of labeled "regions", where each region is a contiguous set of square cells in a 2D grid with origin at (0,0) and extending to (
gridSize
,gridSize
) (for some nonnegative integergridSize
, fixed when the set is created). Coordinates (x,y) are interpreted as points in the 2D plane in the conventional way.A region must be contiguous: adjacent cells share an edge (not just a corner), and any cell in the region must be reachable from any other cell in the region by a path passing through adjacent cells.
Each region is labeled uniquely, and regions must be separated: no cell from one region can share an edge with a cell from another region.
Labels are of arbitrary type
L
and are compared for equality using ===. They may not be null or undefined.PS2 instructions: this is a required ADT interface. You may not change the specifications or add new methods.