intersectIntervals
intersectIntervals<
T>(a,b,compare):T[]
Defined in: interval/intersect-intervals.ts:21
Every point both sets cover, as the same flat, stride-2 [start, end, …]
form.
Both inputs must already be ascending and disjoint — run mergeIntervals
first if they are not. Needs no IntervalStep, unlike complementIntervals
and subtractIntervals: an intersection’s bounds are always bounds one of
the inputs already named, so nothing has to be stepped past.
Complexity: O(n + m) in the two interval counts, by a single merge walk.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”readonly T[]
Flat [start, end, …] pairs, ascending and disjoint.
readonly T[]
The same, and independent of a’s bounds.
compare
Section titled “compare”Comparator<T>
Total order over the bound type.
Returns
Section titled “Returns”T[]
A fresh flat array, ascending and disjoint. Inherits both inputs’ non-adjacency: it can only narrow intervals, never bring two closer.
Throws
Section titled “Throws”When either input holds an odd number of bounds.