import Node from './node'; import { Key } from './types'; export declare type Comparator = (a: Key, b: Key) => number; export declare type Visitor = (node: Node) => void; export declare type NodePrinter = (node: Node) => string; declare function DEFAULT_COMPARE(a: Key, b: Key): number; export default class Tree { private _comparator; private _root; private _size; constructor(comparator?: typeof DEFAULT_COMPARE); /** * Inserts a key, allows duplicates */ insert(key: Key, data?: Value): Node; /** * Adds a key, if it is not present in the tree */ add(key: Key, data?: Value): Node; /** * @param {Key} key * @return {Node|null} */ remove(key: Key): void; /** * Deletes i from the tree if it's there */ private _remove; /** * Removes and returns the node with smallest key */ pop(): { key: Key; data: Value; } | null; /** * Find without splaying */ findStatic(key: Key): Node | null; find(key: Key): Node | null; contains(key: Key): boolean; forEach(visitor: Visitor, ctx?: any): Tree; /** * Walk key range from `low` to `high`. Stops if `fn` returns a value. */ range(low: Key, high: Key, fn: Visitor, ctx?: any): Tree; /** * Returns array of keys */ keys(): Key[]; /** * Returns array of all the data in the nodes */ values(): Value[]; min(): Key | null; max(): Key | null; minNode(t?: Node): Node | null; maxNode(t?: Node): Node | null; /** * Returns node at given index */ at(index: number): Node | null; next(d: Node): Node | null; prev(d: Node): Node | null; clear(): Tree; toList(): Node; /** * Bulk-load items. Both array have to be same size */ load(keys: Key[], values?: Value[], presort?: boolean): this; isEmpty(): boolean; readonly size: number; readonly root: Node | null; toString(printNode?: NodePrinter): string; update(key: Key, newKey: Key, newData?: Value): void; split(key: Key): { left: Node; right: Node; }; [Symbol.iterator](): IterableIterator>; } export {};