import { BinaryTreeNode } from '../data-structures'; import type { BinaryTreeOptions, BTNRep, DFSOrderPattern, EntryCallback, IterationType, NodeCallback, NodePredicate, OptNodeOrNull, ReduceEntryCallback, ToEntryFn } from '../types'; /** * Public, implementation-agnostic binary tree API. * K = key, V = value, R = raw/record used with toEntryFn (optional). * Transforming methods like `map` use method-level generics MK/MV/MR. */ export interface IBinaryTree { readonly size: number; readonly root: BinaryTreeNode | null | undefined; readonly isMapMode: boolean; iterationType: IterationType; readonly NIL: BinaryTreeNode; readonly store: Map>; readonly toEntryFn?: ToEntryFn; readonly isDuplicate: boolean; createNode(key: K, value?: BinaryTreeNode['value']): BinaryTreeNode; createTree(options?: Partial>): IBinaryTree; add(keyOrNodeOrEntryOrRawElement: BTNRep>, value?: V, count?: number): boolean; set(keyOrNodeOrEntryOrRawElement: BTNRep>, value?: V, count?: number): boolean; addMany(keysNodesEntriesOrRaws: Iterable | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable): boolean[]; delete(keyNodeEntryRawOrPredicate: BTNRep> | NodePredicate | null>): boolean; clear(): void; isEmpty(): boolean; get(keyNodeEntryOrPredicate: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): V | undefined; has(keyNodeEntryOrPredicate?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined | NodePredicate | null>, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): boolean; hasValue(value: V): boolean; find(predicate: EntryCallback, thisArg?: unknown): [K, V | undefined] | undefined; [Symbol.iterator](): IterableIterator<[K, V | undefined]>; entries(): IterableIterator<[K, V | undefined]>; keys(): IterableIterator; values(): IterableIterator; forEach(callbackfn: EntryCallback, thisArg?: unknown): void; every(callbackfn: EntryCallback, thisArg?: unknown): boolean; some(callbackfn: EntryCallback, thisArg?: unknown): boolean; reduce(reducer: ReduceEntryCallback, initialValue: U): U; getNode(keyNodeEntryOrPredicate: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined | NodePredicate | null>, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): OptNodeOrNull>; getLeftMost>>>(callback?: C, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType; getRightMost | undefined>>(callback?: C, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType; dfs>>(callback?: C, pattern?: DFSOrderPattern, onlyOne?: boolean, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType[]; dfs | null>>(callback?: C, pattern?: DFSOrderPattern, onlyOne?: boolean, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: boolean): ReturnType[]; bfs>>(callback?: C, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType[]; bfs | null>>(callback?: C, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType[]; morris | null>>(callback?: C, pattern?: DFSOrderPattern, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined): ReturnType[]; leaves | null>>(callback?: C, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType[]; listLevels>>(callback?: C, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType[][]; listLevels | null>>(callback?: C, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType[][]; getPathToRoot>>>(beginNode: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, callback?: C, isReverse?: boolean): ReturnType[]; getDepth(dist: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined): number; getHeight(startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): number; getMinHeight(startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): number; isPerfectlyBalanced(startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined): boolean; isBST(startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): boolean; search | null>>(keyNodeEntryOrPredicate: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined | NodePredicate | null>, onlyOne?: boolean, callback?: C, startNode?: K | BinaryTreeNode | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType[]; clone(): this; filter(predicate: EntryCallback, thisArg?: unknown): this; map(callback: EntryCallback, options?: Partial>, thisArg?: unknown): IBinaryTree; merge(anotherTree: IBinaryTree): void; }