An IntervalTree is a tree structure that stores intervals and allows for efficient querying of overlapping intervals. It is useful for applications that require range queries.
import { IntervalTree } from "collection-kit";
import { IntervalTree } from "collection-kit";
const tree = new IntervalTree();
tree.insert([1, 5]);
tree.insert([3, 7]);
tree.insert([6, 10]);
const overlapping = tree.query([4, 8]);
console.log("Overlapping intervals:", overlapping);