/** This module is browser compatible. */ import { BSNode, direction } from "./bs_node"; export * from "./_comparators"; /** * An unbalanced binary search tree. The values are in ascending order by default, * using JavaScript's built in comparison operators to sort the values. */ export declare class BSTree implements Iterable { protected compare: (a: T, b: T) => number; protected root: BSNode | null; protected _size: number; constructor(compare?: (a: T, b: T) => number); /** Creates a new binary search tree from an array like or iterable object. */ static from(collection: ArrayLike | Iterable | BSTree): BSTree; static from(collection: ArrayLike | Iterable | BSTree, options: { compare?: (a: T, b: T) => number; }): BSTree; static from(collection: ArrayLike | Iterable | BSTree, options: { compare?: (a: U, b: U) => number; map: (value: T, index: number) => U; thisArg?: V; }): BSTree; /** The amount of values stored in the binary search tree. */ get size(): number; protected findNode(value: T): BSNode | null; protected rotateNode(node: BSNode, direction: direction): void; protected insertNode(Node: typeof BSNode, value: T): BSNode | null; protected removeNode(value: T): BSNode | null; /** * Adds the value to the binary search tree if it does not already exist in it. * Returns true if successful. */ insert(value: T): boolean; /** * Removes node value from the binary search tree if found. * Returns true if found and removed. */ remove(value: T): boolean; /** Returns node value if found in the binary search tree. */ find(value: T): T | null; /** Returns the minimum value in the binary search tree or null if empty. */ min(): T | null; /** Returns the maximum value in the binary search tree or null if empty. */ max(): T | null; /** Removes all values from the binary search tree. */ clear(): void; /** Checks if the binary search tree is empty. */ isEmpty(): boolean; /** * Returns an iterator that uses in-order (LNR) tree traversal for * retrieving values from the binary search tree. */ lnrValues(): IterableIterator; /** * Returns an iterator that uses reverse in-order (RNL) tree traversal for * retrieving values from the binary search tree. */ rnlValues(): IterableIterator; /** * Returns an iterator that uses pre-order (NLR) tree traversal for * retrieving values from the binary search tree. */ nlrValues(): IterableIterator; /** * Returns an iterator that uses post-order (LRN) tree traversal for * retrieving values from the binary search tree. */ lrnValues(): IterableIterator; /** * Returns an iterator that uses level order tree traversal for * retrieving values from the binary search tree. */ lvlValues(): IterableIterator; /** * Returns an iterator that uses in-order (LNR) tree traversal for * retrieving values from the binary search tree. */ [Symbol.iterator](): IterableIterator; }