Skip to content

isInSortedIntervals

isInSortedIntervals<T>(ranges, value, compare): boolean

Defined in: interval/is-in-sorted-intervals.ts:19

Tests whether value falls within any of the given sorted, disjoint ranges, each represented as a pair of inclusive bounds in a flat array.

Finds the candidate range the same way bisectRight finds an insertion point (rightmost range whose start is at or before value), then checks value against that range’s end.

Complexity: O(log n) in the number of ranges (ranges.length / 2).

T

readonly T[]

Flat, sorted, non-overlapping [start, end, ...] pairs.

T

The value to test for membership.

Comparator<T>

Total order between two T values.

boolean