// Type definitions for flatten-interval-tree library // Project: https://github.com/alexbol99/flatten-js // Definitions by: Alex Bol /// type Comparable = any; // any object that implements operators '<' and '==' and method 'max' // Define Value with the required.less_than method if T is not a primitive type PrimitiveComparable = number | string | bigint; type LessThanFn = (this: T, other: T) => boolean; export type Value = T extends PrimitiveComparable ? T : T & { less_than: LessThanFn }; export type NumericTuple = [number,number]; type MappedItem = any; type OutputMapperFn = (value: Value, key: Interval) => MappedItem export type SearchOutput = Array> | Array | Array export type IterableOutput = Iterable> | Iterable | Iterable interface IntervalInterface { low: Comparable; high: Comparable; readonly max: Comparable; clone(): Interval; less_than(other_interval: Interval) : boolean; equal_to(other_interval: Interval) : boolean; intersect(other_interval: Interval) : boolean; not_intersect(other_interval: Interval) : boolean; output() : any; } export declare class Interval implements IntervalInterface { low: Comparable; high: Comparable; constructor(low: Comparable, high: Comparable); readonly max: Interval; clone(): Interval; less_than(other_interval: Interval) : boolean; equal_to(other_interval: Interval) : boolean; intersect(other_interval: Interval) : boolean; not_intersect(other_interval: Interval) : boolean; merge(other_interval: Interval) : Interval; output() : NumericTuple; static comparable_max(arg1: Interval, arg2: Interval) : Interval; static comparable_less_than(arg1: Comparable, arg2: Comparable ) : boolean; } type Item = {key: Interval, value: Value} export declare class Node { constructor(key?: Interval | NumericTuple, value?: Value ) left: Node; right: Node; parent: Node; color: 1 | 0; item: Item; isNil() : boolean; less_than(other_node: Node) : boolean; equal_to(other_node: Node) : boolean; intersect(other_node: Node) : boolean; copy_data(other_node: Node) : void; update_max() : void; } declare class IntervalTree { constructor() root: Node | null; readonly size: number; readonly keys: Node[]; readonly values: Value[]; readonly items: Array<{key:Interval, value: Value}>; isEmpty(): boolean; clear(): void; insert(key: Interval | NumericTuple, value?: Value) : Node; exist(key: Interval | NumericTuple, value?: Value): boolean; remove(key: Interval | NumericTuple, value?: Value) : Node; search(interval: Interval | NumericTuple, outputMapperFn?: OutputMapperFn) : SearchOutput; iterate(interval?: Interval | NumericTuple, outputMapperFn?: OutputMapperFn) : IterableOutput intersect_any(interval: Interval | NumericTuple) : boolean; forEach(callbackfn: (key: Interval, value: Value) => void, thisArg?: any ) : void; map(callbackFn: (value: Value, key?: Interval) => any, thisArg?: any ): IntervalTree; } export default IntervalTree;