Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RepArrayRegionSet<L>

An implementation of RegionSet.

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

Type parameters

  • L

Hierarchy

  • RepArrayRegionSet

Implements

Index

Constructors

Properties

Methods

Constructors

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

    Type parameters

    • L

    Parameters

    • gridSize: number

      dimension of grid, must be nonnegative integer

    Returns RepArrayRegionSet<L>

Properties

gridSize: number

Methods

  • add(label: L, 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: L

      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(label: L): undefined | Rect
  • Get the bounding box of a labeled region.

    Parameters

    • label: L

      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(rect: Rect): Set<L>
  • 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<L>

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

Generated using TypeDoc