Class RepArrayIntervalSet<Label>

An implementation of IntervalSet.

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

Type Parameters

  • Label

Implements

Constructors

Methods

Constructors

Methods

  • Add a labeled interval (if not present) to this set, if it does not conflict with existing intervals.

    Labeled intervals conflict if:

    • they have the same label with different intervals; or
    • they have different labels with overlapping intervals.

    For example, if this set is { "A"=[0,10), "B"=[20,30) },

    • add("A"=[0,10)) has no effect
    • add("B"=[10,20)) throws IntervalConflictError
    • add("C"=[20,30)) throws IntervalConflictError
    • add("D"=[30,40)) adds "D"=[30,40)

    Parameters

    • start: bigint

      low end of the interval, inclusive

    • end: bigint

      high end of the interval, exclusive, must be greater than start

    • label: Label

      label to add

    Returns void

    an IntervalConflictError if label is already in this set and its interval is not [start,end), or if an interval in this set with a different label overlaps [start,end)

  • Get the interval associated with a label in this set, if any.

    Parameters

    Returns undefined | Interval

    the interval associated with label in this set, or undefined if none