Skip to content

StaticIntervalTree

Defined in: packages/data/src/interval/static-interval-tree.ts:51

A centered interval tree: which intervals contain a point, or overlap a range.

Intervals are half-open, [from, to), so touching intervals do not count as overlapping — the convention that makes adjacent ranges tile without ambiguity.

Each node picks a center point and holds every interval spanning it, kept in two orders so a query can stop as soon as an interval is out of range rather than scanning the whole node. Intervals entirely left or right of the center recurse into subtrees.

Static: the whole interval set is given at construction, which is what allows the balanced centers. Building is O(n log n).

Time complexity: O(log n + k) per query for k results.

P

The endpoint type.

V

The value carried by an interval.

new StaticIntervalTree<P, V>(intervals, options?): StaticIntervalTree<P, V>

Defined in: packages/data/src/interval/static-interval-tree.ts:57

Iterable<Interval<P, V>>

StaticIntervalTreeOptions<P>

StaticIntervalTree<P, V>

readonly comparator: Comparator<P>

Defined in: packages/data/src/interval/static-interval-tree.ts:55

count(): number

Defined in: packages/data/src/interval/static-interval-tree.ts:90

The number of intervals indexed.

Empty (from === to) intervals are discarded at construction, so this can be lower than the number handed in.

number


overlapping(from, to): IterableIterator<V>

Defined in: packages/data/src/interval/static-interval-tree.ts:108

The values of every interval overlapping [from, to).

An empty or inverted query range yields nothing: no interval overlaps a range of zero width.

P

P

IterableIterator<V>

IIntervalIndex.overlapping


stab(point): IterableIterator<V>

Defined in: packages/data/src/interval/static-interval-tree.ts:98

The values of every interval containing point, i.e. where from <= point < to.

P

IterableIterator<V>

IIntervalIndex.stab