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 (
(for some nonnegative integer
gridSize, 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: any cell in the region must be reachable from any other cell in the region by a path passing through adjacent cells, where we define adjacent cells as sharing an edge (not just a corner).
Each region is labeled uniquely, and regions must not intersect: no cell may be in more than one 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.
type of labels in this set, compared for equality using ===.
the dimension of the grid, such that this set uses a
Must be nonnegative.
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 intersect with other existing labeled regions.
Error if adding the rectangle would make label's region discontiguous or would intersect with a cell in another labeled region
label of region
rectangle to add to labeled region. Required to have nonzero area and integer coordinates
drawn from [0,
Get the bounding box of a labeled region.
the smallest rectangle that contains all the grid cells in the labeled region, or undefined if no region with that label exists.
label of region
Get the labels of regions that intersect the given rectangle (where the intersection contains at least one full grid cell).
the labels of regions in this set whose intersection with rect contains at least one grid cell
rectangle to query. Its coordinates must be integers in [0,
Generated using TypeDoc