Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RepMapRegionSet

An implementation of RegionSet.

PS2 instructions: you must use the provided rep. You may not change the spec of the constructor.

Hierarchy

  • RepMapRegionSet

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

  • Create an empty region set for a gridSize x gridSize grid.

    Parameters

    • gridSize: number

      dimension of grid, must be nonnegative integer

    Returns RepMapRegionSet

Properties

Readonly gridSize

gridSize: number

Methods

add

  • add(label: string, rect: Rect): void
  • 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.

    Parameters

    • label: string

      label of region

    • rect: Rect

      rectangle to add to labeled region. Required to have nonzero area and integer coordinates drawn from {0...gridSize}.

    Returns void

bounds

  • bounds(label: string): undefined | Rect
  • Get the bounding box of a labeled region.

    Parameters

    • label: string

      label of region

    Returns undefined | Rect

    the smallest rectangle that contains all the grid cells in the labeled region, or undefined if no region with that label exists.

owners

  • owners(rect: Rect): Set<string>
  • Get the labels of regions that intersect the given rectangle (where the intersection contains at least one full grid cell).

    Parameters

    • rect: Rect

      rectangle to query. Its coordinates must be integers in {0...gridSize}.

    Returns Set<string>

    the labels of regions in this set whose intersection with rect contains at least one grid cell

Generated using TypeDoc