2023-11-22 09:18:37 +00:00
|
|
|
import { BinaryTree, BinaryTreeNode } from '../data-structures';
|
2024-01-24 10:38:34 +00:00
|
|
|
import type {
|
2023-12-11 06:14:46 +00:00
|
|
|
BinaryTreeDeleteResult,
|
2023-11-23 13:43:45 +00:00
|
|
|
BinaryTreeNested,
|
|
|
|
BinaryTreeNodeNested,
|
|
|
|
BinaryTreeOptions,
|
|
|
|
BTNCallback,
|
2024-01-24 10:38:34 +00:00
|
|
|
Comparable,
|
2023-12-23 03:53:18 +00:00
|
|
|
KeyOrNodeOrEntry
|
2023-11-23 13:43:45 +00:00
|
|
|
} from '../types';
|
2023-08-22 00:58:42 +00:00
|
|
|
|
2023-12-21 02:26:45 +00:00
|
|
|
export interface IBinaryTree<
|
2024-01-24 10:38:34 +00:00
|
|
|
K extends Comparable,
|
2023-12-21 02:26:45 +00:00
|
|
|
V = any,
|
2024-01-26 10:20:15 +00:00
|
|
|
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
|
|
|
> {
|
2024-01-26 10:20:15 +00:00
|
|
|
createNode(key: K, value?: NODE['value']): NODE;
|
2023-08-22 00:58:42 +00:00
|
|
|
|
2024-01-26 10:20:15 +00:00
|
|
|
createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
|
2023-11-23 13:43:45 +00:00
|
|
|
|
2024-01-26 10:20:15 +00:00
|
|
|
add(keyOrNodeOrEntryOrRawElement: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
|
2023-11-23 13:43:45 +00:00
|
|
|
|
2024-01-26 10:20:15 +00:00
|
|
|
addMany(nodes: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
|
2023-10-17 13:06:41 +00:00
|
|
|
|
2024-01-26 10:20:15 +00:00
|
|
|
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<NODE>[];
|
2023-10-17 13:06:41 +00:00
|
|
|
}
|