UNPKG

sonic-forest

Version:

High-performance (binary) tree and sorted map implementation (AVL, Splay, Radix, Red-Black)

40 lines (39 loc) 1.35 kB
import type { Comparator, SonicMap } from '../types'; export declare class LlrbNode<K, V> { readonly k: K; v: V; b: boolean; p: LlrbNode<K, V> | undefined; l: LlrbNode<K, V> | undefined; r: LlrbNode<K, V> | undefined; constructor(k: K, v: V, b: boolean); } export declare class LlrbTree<K, V> implements SonicMap<K, V, LlrbNode<K, V>> { readonly comparator: Comparator<K>; min: LlrbNode<K, V> | undefined; root: LlrbNode<K, V> | undefined; max: LlrbNode<K, V> | undefined; protected _size: number; constructor(comparator?: Comparator<K>); set(k: K, v: V): LlrbNode<K, V>; private _fixRRB; private _fixBRR; private _fixBBR; private _fix; find(k: K): LlrbNode<K, V> | undefined; get(k: K): V | undefined; del(k: K): boolean; clear(): void; has(k: K): boolean; size(): number; isEmpty(): boolean; getOrNextLower(k: K): LlrbNode<K, V> | undefined; forEach(fn: (node: LlrbNode<K, V>) => void): void; first(): LlrbNode<K, V> | undefined; last(): LlrbNode<K, V> | undefined; readonly next: <N extends import("../types").HeadlessNode>(curr: N) => N | undefined; iterator0(): () => undefined | LlrbNode<K, V>; iterator(): Iterator<LlrbNode<K, V>>; entries(): IterableIterator<LlrbNode<K, V>>; toString(tab: string): string; }