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

  • Determines whether all the members of an array satisfy the specified test.

    Parameters

    • predicate: ((value: UintRange<T>, index: number, array: UintRangeArray<T>) => unknown)

      A function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.

    • OptionalthisArg: any

      An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

    Returns boolean

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

    Returns boolean

    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>

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

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