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

28 lines
895 B
TypeScript
Raw Normal View History

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