/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
import { ConflictAction, IIntegerRange, KeyComparer, PropertyAction, SortedDictionary } from "./base";
export declare class Stack<T> {
    items: T[];
    push(val: T): void;
    empty(): boolean;
    top(): T | undefined;
    pop(): T | undefined;
}
export declare function ListRemoveEntry<U>(entry: List<U>): List<U> | undefined;
export declare function ListMakeHead<U>(): List<U>;
export declare class List<T> {
    isHead: boolean;
    data: T | undefined;
    next: List<T>;
    prev: List<T>;
    constructor(isHead: boolean, data: T | undefined);
    clear(): void;
    private add;
    dequeue(): T | undefined;
    enqueue(data: T): List<T>;
    walk(fn: (data: T, l: List<T>) => void): void;
    some(fn: (data: T, l: List<T>) => boolean, rev?: boolean): T[];
    count(): number;
    first(): T | undefined;
    last(): T | undefined;
    empty(): boolean;
    /**
     * @deprecated - use unshift
     */
    push(data: T): void;
    unshift(data: T): void;
    [Symbol.iterator](): IterableIterator<T>;
}
export interface Comparer<T> {
    compare(a: T, b: T): number;
    min: T;
}
export declare class Heap<T> {
    comp: Comparer<T>;
    private L;
    count(): number;
    constructor(a: T[], comp: Comparer<T>);
    peek(): T;
    get(): T;
    add(x: T): void;
    private fixup;
    private fixDown;
}
export declare const RBColor: {
    readonly RED: 0;
    readonly BLACK: 1;
};
export declare type RBColor = typeof RBColor[keyof typeof RBColor];
export interface RBNode<TKey, TData> {
    key: TKey;
    data: TData;
    left: RBNode<TKey, TData> | undefined;
    right: RBNode<TKey, TData> | undefined;
    color: RBColor;
    size: number;
}
export interface IRBAugmentation<TKey, TData> {
    update(node: RBNode<TKey, TData>): void;
}
export interface IRBMatcher<TKey, TData> {
    continueSubtree(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;
    matchNode(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;
}
export interface RBNodeActions<TKey, TData> {
    infix?(node: RBNode<TKey, TData>): boolean;
    pre?(node: RBNode<TKey, TData>): boolean;
    post?(node: RBNode<TKey, TData>): boolean;
    showStructure?: boolean;
}
export declare class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData> {
    private readonly compareKeys;
    private readonly aug?;
    private root;
    constructor(compareKeys: KeyComparer<TKey>, aug?: IRBAugmentation<TKey, TData> | undefined);
    private makeNode;
    private isRed;
    private nodeSize;
    size(): number;
    isEmpty(): boolean;
    get(key: TKey): RBNode<TKey, TData> | undefined;
    private nodeGet;
    private contains;
    gather(key: TKey, matcher: IRBMatcher<TKey, TData>): RBNode<TKey, TData>[];
    private nodeGather;
    walkExactMatchesForward(compareFn: (node: RBNode<TKey, TData>) => number, actionFn: (node: RBNode<TKey, TData>) => void, continueLeftFn: (number: number) => boolean, continueRightFn: (number: number) => boolean): void;
    private nodeWalkExactMatchesForward;
    walkExactMatchesBackward(compareFn: (node: RBNode<TKey, TData>) => number, actionFn: (node: RBNode<TKey, TData>) => void, continueLeftFn: (number: number) => boolean, continueRightFn: (number: number) => boolean): void;
    private nodeWalkExactMatchesBackward;
    put(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>): void;
    private nodePut;
    private updateLocal;
    private nodeRemoveMin;
    remove(key: TKey): void;
    removeExisting(key: TKey): void;
    private nodeRemove;
    floor(key: TKey): RBNode<TKey, TData> | undefined;
    private nodeFloor;
    ceil(key: TKey): RBNode<TKey, TData> | undefined;
    private nodeCeil;
    min(): RBNode<TKey, TData> | undefined;
    private nodeMin;
    max(): RBNode<TKey, TData> | undefined;
    private nodeMax;
    private rotateRight;
    private rotateLeft;
    private oppositeColor;
    private flipColors;
    private moveRedLeft;
    private moveRedRight;
    private balance;
    mapRange<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum, start?: TKey, end?: TKey): void;
    map<TAccum>(action: PropertyAction<TKey, TData>, 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<TKey, TData>): void;
    walkBackward(actions: RBNodeActions<TKey, TData>): void;
    private nodeWalk;
    private nodeWalkBackward;
    private nodeMap;
}
export interface AugmentedIntervalNode {
    minmax: IInterval;
}
export declare const integerRangeToString: (range: IIntegerRange) => string;
export interface IInterval {
    clone(): IInterval;
    compare(b: IInterval): number;
    compareStart(b: IInterval): number;
    compareEnd(b: IInterval): number;
    modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage): IInterval | undefined;
    overlaps(b: IInterval): boolean;
    union(b: IInterval): IInterval;
}
export declare type IntervalNode<T extends IInterval> = RBNode<T, AugmentedIntervalNode>;
export declare type IntervalConflictResolver<TInterval> = (a: TInterval, b: TInterval) => TInterval;
export declare class IntervalTree<T extends IInterval> implements IRBAugmentation<T, AugmentedIntervalNode>, IRBMatcher<T, AugmentedIntervalNode> {
    intervals: RedBlackTree<T, AugmentedIntervalNode>;
    remove(x: T): void;
    removeExisting(x: T): void;
    put(x: T, conflict?: IntervalConflictResolver<T>): void;
    map(fn: (x: T) => void): void;
    mapUntil(fn: (X: T) => boolean): void;
    mapBackward(fn: (x: T) => void): void;
    match(x: T): RBNode<T, AugmentedIntervalNode>[];
    matchNode(node: IntervalNode<T> | undefined, key: T): boolean;
    continueSubtree(node: IntervalNode<T> | undefined, key: T): boolean;
    update(node: IntervalNode<T>): void;
}
export interface TSTResult<T> {
    key: string;
    val: T;
}
export interface TSTNode<T> {
    c: string;
    left?: TSTNode<T>;
    mid?: TSTNode<T>;
    right?: TSTNode<T>;
    val?: T;
}
export interface ProxString<T> {
    text: string;
    invDistance: number;
    val: T;
}
export declare class TST<T> {
    private n;
    private root;
    size(): number;
    private contains;
    get(key: string): T | undefined;
    private nodeGet;
    put(key: string, val: T): void;
    private nodePut;
    neighbors(text: string, distance?: number): ProxString<T>[];
    keysWithPrefix(text: string): string[];
    private collect;
    private mapNode;
    map(fn: (key: string, val: T) => void): void;
    pairsWithPrefix(text: string): TSTResult<T>[];
    private collectPairs;
    private nodeProximity;
}
//# sourceMappingURL=collections.d.ts.map