Class UintRangeArray<T>

Type Parameters

Hierarchy

Constructors

  • Type Parameters

    Parameters

    • arrayLength: number

    Returns UintRangeArray<T>

  • Type Parameters

    Parameters

    Returns UintRangeArray<T>

Methods

  • Asserts two UintRanges[] do not overlap at all with each other. For example, if we have a list of permitted and forbidden times, we want to make sure that the forbidden times do not overlap with the permitted times.

    Parameters

    Returns void

  • Checks if any of the array's elements overlap with each other.

    Returns boolean

    Remarks

    Overlap here is considered inclusive, so [1, 10] and [10, 20] would be considered overlapping. [1, 10] and [11, 20] would not be considered overlapping.

  • Checks if the provided id ranges are full (i.e. they cover all possible IDs from 1 to max uint64).

    Returns boolean

  • Search ID ranges for a specific ID. Return [idx, found], where idx is the index of the range that contains the ID, and found is true if the ID was found.

    If you just want one or the other, use searchIndex() or searchIfExists().

    Parameters

    Returns [bigint, boolean]

  • Gets the total number of IDs covered by a list of UintRanges. for example, [{start: 1, end: 3}, {start: 5, end: 7}] would return 6.

    Returns T

  • Sorts and merges a list of UintRanges. If ranges overlap, they are merged.

    Returns UintRangeArray<T>

    Example

    [{start: 1, end: 3}, {start: 2, end: 4}] => [{start: 1, end: 4}]
    

    Remarks

    Does not return a new list. Modifies the list in place. To get a new list, use clone().sortAndMerge().