data-structure-typed/src/interfaces/binary-tree.ts

28 lines
854 B
TypeScript
Raw Normal View History

import { BinaryTree, BinaryTreeNode } from '../data-structures';
import type {
BinaryTreeDeleteResult,
BinaryTreeNested,
BinaryTreeNodeNested,
BinaryTreeOptions,
BTNCallback,
Comparable,
KeyOrNodeOrEntry
} from '../types';
2023-12-21 02:26:45 +00:00
export interface IBinaryTree<
K extends Comparable,
2023-12-21 02:26:45 +00:00
V = any,
N extends BinaryTreeNode<K, V, N> = BinaryTreeNodeNested<K, V>,
TREE extends BinaryTree<K, V, N, TREE> = BinaryTreeNested<K, V, N>
> {
createNode(key: K, value?: N['value']): N;
createTree(options?: Partial<BinaryTreeOptions<K>>): TREE;
add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V, count?: number): boolean;
addMany(nodes: Iterable<KeyOrNodeOrEntry<K, V, N>>, values?: Iterable<V | undefined>): boolean[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<N>[];
}