/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ /** * @internal */ export declare const RBColor: { readonly RED: 0; readonly BLACK: 1; }; /** * @internal */ export type RBColor = (typeof RBColor)[keyof typeof RBColor]; /** * @internal */ export interface RBNode { key: TKey; data: TData; left: RBNode | undefined; right: RBNode | undefined; color: RBColor; size: number; } /** * @internal */ export interface IRBAugmentation { update(node: RBNode): void; } /** * @internal */ export interface IRBMatcher { continueSubtree(node: RBNode | undefined, key: TKey): boolean; matchNode(node: RBNode | undefined, key: TKey): boolean; } /** * @internal */ export interface RBNodeActions { infix?(node: RBNode): boolean; pre?(node: RBNode): boolean; post?(node: RBNode): boolean; showStructure?: boolean; } /** * @internal */ export interface KeyComparer { (a: TKey, b: TKey): number; } /** * @internal */ export interface Property { key: TKey; data: TData; } /** * @internal */ export interface PropertyAction { (p: Property, accum?: TAccum): boolean; } /** * @internal */ export interface QProperty { key?: TKey; data?: TData; } /** * @internal */ export type ConflictAction = (key: TKey, currentKey: TKey, data: TData, currentData: TData) => QProperty; /** * @internal */ export interface SortedDictionary extends Dictionary { max(): Property | undefined; min(): Property | undefined; mapRange(action: PropertyAction, accum?: TAccum, start?: TKey, end?: TKey): void; } /** * @internal */ export interface Dictionary { get(key: TKey): Property | undefined; put(key: TKey, data: TData, conflict?: ConflictAction): void; remove(key: TKey): void; map(action: PropertyAction, accum?: TAccum): void; } /** * @internal */ export declare class RedBlackTree implements SortedDictionary { private readonly compareKeys; private readonly aug?; private root; constructor(compareKeys: KeyComparer, aug?: IRBAugmentation | undefined); private makeNode; private isRed; private nodeSize; size(): number; isEmpty(): boolean; get(key: TKey): RBNode | undefined; private nodeGet; private contains; gather(key: TKey, matcher: IRBMatcher): RBNode[]; private nodeGather; walkExactMatchesForward(compareFn: (node: RBNode) => number, actionFn: (node: RBNode) => void, continueLeftFn: (number: number) => boolean, continueRightFn: (number: number) => boolean): void; private nodeWalkExactMatchesForward; walkExactMatchesBackward(compareFn: (node: RBNode) => number, actionFn: (node: RBNode) => void, continueLeftFn: (number: number) => boolean, continueRightFn: (number: number) => boolean): void; private nodeWalkExactMatchesBackward; put(key: TKey, data: TData, conflict?: ConflictAction): void; private nodePut; private updateLocal; private nodeRemoveMin; remove(key: TKey): void; removeExisting(key: TKey): void; private nodeRemove; /** * Finds the largest node that is less than or equal to a given key. */ floor(key: TKey): RBNode | undefined; private nodeFloor; /** * Finds the smallest node that is greater than or equal to a given key. */ ceil(key: TKey): RBNode | undefined; private nodeCeil; min(): RBNode | undefined; private nodeMin; max(): RBNode | undefined; private nodeMax; private rotateRight; private rotateLeft; private oppositeColor; private flipColors; private moveRedLeft; private moveRedRight; private balance; mapRange(action: PropertyAction, accum?: TAccum, start?: TKey, end?: TKey): void; map(action: PropertyAction, accum?: TAccum): void; keys(): TKey[]; /** * Depth-first traversal with custom action; if action returns * false, traversal is halted. * @param action - action to apply to each node */ walk(actions: RBNodeActions): void; walkBackward(actions: RBNodeActions): void; private nodeWalk; private nodeWalkBackward; private nodeMap; } //# sourceMappingURL=rbTree.d.ts.map