stack-typed 1.48.2 → 1.48.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-structures/binary-tree/avl-tree.d.ts +16 -16
- package/dist/data-structures/binary-tree/avl-tree.js +7 -7
- package/dist/data-structures/binary-tree/binary-tree.d.ts +89 -87
- package/dist/data-structures/binary-tree/binary-tree.js +67 -58
- package/dist/data-structures/binary-tree/bst.d.ts +28 -47
- package/dist/data-structures/binary-tree/bst.js +54 -57
- package/dist/data-structures/binary-tree/rb-tree.d.ts +15 -15
- package/dist/data-structures/binary-tree/rb-tree.js +7 -7
- package/dist/data-structures/binary-tree/tree-multimap.d.ts +22 -22
- package/dist/data-structures/binary-tree/tree-multimap.js +11 -11
- package/dist/interfaces/binary-tree.d.ts +6 -6
- package/dist/types/common.d.ts +11 -8
- package/dist/types/common.js +6 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
- package/dist/types/data-structures/binary-tree/bst.d.ts +6 -6
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/tree-multimap.d.ts +3 -3
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +20 -21
- package/src/data-structures/binary-tree/binary-tree.ts +147 -136
- package/src/data-structures/binary-tree/bst.ts +86 -82
- package/src/data-structures/binary-tree/rb-tree.ts +25 -26
- package/src/data-structures/binary-tree/tree-multimap.ts +30 -35
- package/src/interfaces/binary-tree.ts +5 -6
- package/src/types/common.ts +11 -8
- package/src/types/data-structures/binary-tree/avl-tree.ts +3 -3
- package/src/types/data-structures/binary-tree/binary-tree.ts +6 -5
- package/src/types/data-structures/binary-tree/bst.ts +6 -6
- package/src/types/data-structures/binary-tree/rb-tree.ts +3 -3
- package/src/types/data-structures/binary-tree/tree-multimap.ts +3 -3
|
@@ -5,26 +5,21 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
9
|
-
BSTNodeKeyOrNode,
|
|
10
|
-
BTNKey,
|
|
11
|
-
BTNodeExemplar,
|
|
12
|
-
TreeMultimapNodeNested,
|
|
13
|
-
TreeMultimapOptions
|
|
14
|
-
} from '../../types';
|
|
8
|
+
import type { BSTNodeKeyOrNode, BTNodeExemplar, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
|
|
15
9
|
import { BiTreeDeleteResult, BTNCallback, FamilyPosition, IterationType, TreeMultimapNested } from '../../types';
|
|
16
10
|
import { IBinaryTree } from '../../interfaces';
|
|
17
11
|
import { AVLTree, AVLTreeNode } from './avl-tree';
|
|
18
12
|
|
|
19
13
|
export class TreeMultimapNode<
|
|
14
|
+
K = any,
|
|
20
15
|
V = any,
|
|
21
|
-
N extends TreeMultimapNode<V, N> = TreeMultimapNodeNested<V>
|
|
22
|
-
> extends AVLTreeNode<V, N> {
|
|
16
|
+
N extends TreeMultimapNode<K, V, N> = TreeMultimapNodeNested<K, V>
|
|
17
|
+
> extends AVLTreeNode<K, V, N> {
|
|
23
18
|
count: number;
|
|
24
19
|
|
|
25
20
|
/**
|
|
26
21
|
* The constructor function initializes a BinaryTreeNode object with a key, value, and count.
|
|
27
|
-
* @param {
|
|
22
|
+
* @param {K} key - The `key` parameter is of type `K` and represents the unique identifier
|
|
28
23
|
* of the binary tree node.
|
|
29
24
|
* @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the value of the binary
|
|
30
25
|
* tree node. If no value is provided, it will be `undefined`.
|
|
@@ -32,7 +27,7 @@ export class TreeMultimapNode<
|
|
|
32
27
|
* occurs in a binary tree node. It has a default value of 1, which means that if no value is provided for the `count`
|
|
33
28
|
* parameter when creating a new instance of the `BinaryTreeNode` class.
|
|
34
29
|
*/
|
|
35
|
-
constructor(key:
|
|
30
|
+
constructor(key: K, value?: V, count = 1) {
|
|
36
31
|
super(key, value);
|
|
37
32
|
this.count = count;
|
|
38
33
|
}
|
|
@@ -41,12 +36,12 @@ export class TreeMultimapNode<
|
|
|
41
36
|
/**
|
|
42
37
|
* The only distinction between a TreeMultimap and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
|
|
43
38
|
*/
|
|
44
|
-
export class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultimapNode<V, TreeMultimapNodeNested<V>>,
|
|
45
|
-
TREE extends TreeMultimap<V, N, TREE> = TreeMultimap<V, N, TreeMultimapNested<V, N>>>
|
|
46
|
-
extends AVLTree<V, N, TREE>
|
|
47
|
-
implements IBinaryTree<V, N, TREE> {
|
|
39
|
+
export class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K, V, N> = TreeMultimapNode<K, V, TreeMultimapNodeNested<K, V>>,
|
|
40
|
+
TREE extends TreeMultimap<K, V, N, TREE> = TreeMultimap<K, V, N, TreeMultimapNested<K, V, N>>>
|
|
41
|
+
extends AVLTree<K, V, N, TREE>
|
|
42
|
+
implements IBinaryTree<K, V, N, TREE> {
|
|
48
43
|
|
|
49
|
-
constructor(elements?: Iterable<BTNodeExemplar<V, N>>, options?: Partial<TreeMultimapOptions
|
|
44
|
+
constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<TreeMultimapOptions<K>>) {
|
|
50
45
|
super([], options);
|
|
51
46
|
if (elements) this.addMany(elements);
|
|
52
47
|
}
|
|
@@ -62,43 +57,43 @@ export class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultim
|
|
|
62
57
|
|
|
63
58
|
/**
|
|
64
59
|
* The function creates a new BSTNode with the given key, value, and count.
|
|
65
|
-
* @param {
|
|
60
|
+
* @param {K} key - The key parameter is the unique identifier for the binary tree node. It is used to
|
|
66
61
|
* distinguish one node from another in the tree.
|
|
67
62
|
* @param {N} value - The `value` parameter represents the value that will be stored in the binary search tree node.
|
|
68
63
|
* @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of
|
|
69
64
|
* occurrences of the value in the binary search tree node. If not provided, the count will default to 1.
|
|
70
65
|
* @returns A new instance of the BSTNode class with the specified key, value, and count (if provided).
|
|
71
66
|
*/
|
|
72
|
-
override createNode(key:
|
|
67
|
+
override createNode(key: K, value?: V, count?: number): N {
|
|
73
68
|
return new TreeMultimapNode(key, value, count) as N;
|
|
74
69
|
}
|
|
75
70
|
|
|
76
|
-
override createTree(options?: TreeMultimapOptions): TREE {
|
|
77
|
-
return new TreeMultimap<V, N, TREE>([], {
|
|
71
|
+
override createTree(options?: TreeMultimapOptions<K>): TREE {
|
|
72
|
+
return new TreeMultimap<K, V, N, TREE>([], {
|
|
78
73
|
iterationType: this.iterationType,
|
|
79
|
-
|
|
74
|
+
variant: this.variant, ...options
|
|
80
75
|
}) as TREE;
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
/**
|
|
84
79
|
* The function checks if an exemplar is an instance of the TreeMultimapNode class.
|
|
85
|
-
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<V, N>`.
|
|
80
|
+
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
|
|
86
81
|
* @returns a boolean value indicating whether the exemplar is an instance of the TreeMultimapNode
|
|
87
82
|
* class.
|
|
88
83
|
*/
|
|
89
|
-
override isNode(exemplar: BTNodeExemplar<V, N>): exemplar is N {
|
|
84
|
+
override isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N {
|
|
90
85
|
return exemplar instanceof TreeMultimapNode;
|
|
91
86
|
}
|
|
92
87
|
|
|
93
88
|
/**
|
|
94
89
|
* The function `exemplarToNode` converts an exemplar object into a node object.
|
|
95
|
-
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<V, N>`, where `V` represents
|
|
90
|
+
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where `V` represents
|
|
96
91
|
* the value type and `N` represents the node type.
|
|
97
92
|
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
|
|
98
93
|
* times the node should be created. If not provided, it defaults to 1.
|
|
99
94
|
* @returns a value of type `N` (the generic type parameter) or `undefined`.
|
|
100
95
|
*/
|
|
101
|
-
override exemplarToNode(exemplar: BTNodeExemplar<V, N>, count = 1): N | undefined {
|
|
96
|
+
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, count = 1): N | undefined {
|
|
102
97
|
let node: N | undefined;
|
|
103
98
|
if (exemplar === undefined || exemplar === null) {
|
|
104
99
|
return;
|
|
@@ -111,7 +106,7 @@ export class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultim
|
|
|
111
106
|
} else {
|
|
112
107
|
node = this.createNode(key, value, count);
|
|
113
108
|
}
|
|
114
|
-
} else if (this.
|
|
109
|
+
} else if (this.isNotNodeInstance(exemplar)) {
|
|
115
110
|
node = this.createNode(exemplar, undefined, count);
|
|
116
111
|
} else {
|
|
117
112
|
return;
|
|
@@ -136,7 +131,7 @@ export class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultim
|
|
|
136
131
|
* is 1.
|
|
137
132
|
* @returns either a node (`N`) or `undefined`.
|
|
138
133
|
*/
|
|
139
|
-
override add(keyOrNodeOrEntry: BTNodeExemplar<V, N>, count = 1): N | undefined {
|
|
134
|
+
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, count = 1): N | undefined {
|
|
140
135
|
const newNode = this.exemplarToNode(keyOrNodeOrEntry, count);
|
|
141
136
|
if (newNode === undefined) return;
|
|
142
137
|
|
|
@@ -163,7 +158,7 @@ export class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultim
|
|
|
163
158
|
* either keys, nodes, or entries.
|
|
164
159
|
* @returns The method is returning an array of type `N | undefined`.
|
|
165
160
|
*/
|
|
166
|
-
override addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<V, N>>): (N | undefined)[] {
|
|
161
|
+
override addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<K, V, N>>): (N | undefined)[] {
|
|
167
162
|
return super.addMany(keysOrNodesOrEntries);
|
|
168
163
|
}
|
|
169
164
|
|
|
@@ -345,13 +340,13 @@ export class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultim
|
|
|
345
340
|
* @param {N | undefined} newNode - The `newNode` parameter represents the node that needs to be
|
|
346
341
|
* added to the binary tree. It can be of type `N` (which represents a node in the binary tree) or
|
|
347
342
|
* `undefined` if there is no node to add.
|
|
348
|
-
* @param {
|
|
343
|
+
* @param {K | N | undefined} parent - The `parent` parameter represents the parent node to
|
|
349
344
|
* which the new node will be added as a child. It can be either a node object (`N`) or a key value
|
|
350
|
-
* (`
|
|
345
|
+
* (`K`).
|
|
351
346
|
* @returns The method `_addTo` returns either the `parent.left` or `parent.right` node that was
|
|
352
347
|
* added, or `undefined` if no node was added.
|
|
353
348
|
*/
|
|
354
|
-
protected override _addTo(newNode: N | undefined, parent: BSTNodeKeyOrNode<N>): N | undefined {
|
|
349
|
+
protected override _addTo(newNode: N | undefined, parent: BSTNodeKeyOrNode<K, N>): N | undefined {
|
|
355
350
|
parent = this.ensureNode(parent);
|
|
356
351
|
if (parent) {
|
|
357
352
|
if (parent.left === undefined) {
|
|
@@ -379,14 +374,14 @@ export class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = TreeMultim
|
|
|
379
374
|
|
|
380
375
|
/**
|
|
381
376
|
* The `_swapProperties` function swaps the key, value, count, and height properties between two nodes.
|
|
382
|
-
* @param {
|
|
383
|
-
* which the values will be swapped. It can be of type `
|
|
384
|
-
* @param {
|
|
377
|
+
* @param {K | N | undefined} srcNode - The `srcNode` parameter represents the source node from
|
|
378
|
+
* which the values will be swapped. It can be of type `K`, `N`, or `undefined`.
|
|
379
|
+
* @param {K | N | undefined} destNode - The `destNode` parameter represents the destination
|
|
385
380
|
* node where the values from the source node will be swapped to.
|
|
386
381
|
* @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
|
|
387
382
|
* if either `srcNode` or `destNode` is undefined.
|
|
388
383
|
*/
|
|
389
|
-
protected override _swapProperties(srcNode: BSTNodeKeyOrNode<N>, destNode: BSTNodeKeyOrNode<N>): N | undefined {
|
|
384
|
+
protected override _swapProperties(srcNode: BSTNodeKeyOrNode<K, N>, destNode: BSTNodeKeyOrNode<K, N>): N | undefined {
|
|
390
385
|
srcNode = this.ensureNode(srcNode);
|
|
391
386
|
destNode = this.ensureNode(destNode);
|
|
392
387
|
if (srcNode && destNode) {
|
|
@@ -5,18 +5,17 @@ import {
|
|
|
5
5
|
BinaryTreeOptions,
|
|
6
6
|
BiTreeDeleteResult,
|
|
7
7
|
BTNCallback,
|
|
8
|
-
BTNKey,
|
|
9
8
|
BTNodeExemplar,
|
|
10
9
|
} from '../types';
|
|
11
10
|
|
|
12
|
-
export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>, TREE extends BinaryTree<V, N, TREE> = BinaryTreeNested<V, N>> {
|
|
13
|
-
createNode(key:
|
|
11
|
+
export interface IBinaryTree<K = number, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTreeNested<K, V, N>> {
|
|
12
|
+
createNode(key: K, value?: N['value']): N;
|
|
14
13
|
|
|
15
|
-
createTree(options?: Partial<BinaryTreeOptions
|
|
14
|
+
createTree(options?: Partial<BinaryTreeOptions<K>>): TREE;
|
|
16
15
|
|
|
17
|
-
add(keyOrNodeOrEntry: BTNodeExemplar<V, N>, count?: number): N | null | undefined;
|
|
16
|
+
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, count?: number): N | null | undefined;
|
|
18
17
|
|
|
19
|
-
addMany(nodes: Iterable<BTNodeExemplar<V, N>>): (N | null | undefined)[];
|
|
18
|
+
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>): (N | null | undefined)[];
|
|
20
19
|
|
|
21
20
|
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BiTreeDeleteResult<N>[];
|
|
22
21
|
}
|
package/src/types/common.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export type Comparator<K> = (a: K, b: K) => number;
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export enum BSTVariant {
|
|
4
|
+
MIN = 'MIN',
|
|
5
|
+
MAX = 'MAX',
|
|
6
|
+
}
|
|
4
7
|
|
|
5
8
|
export type DFSOrderPattern = 'pre' | 'in' | 'post';
|
|
6
9
|
|
|
@@ -24,14 +27,14 @@ export type IterableWithSizeOrLength<T> = IterableWithSize<T> | IterableWithLeng
|
|
|
24
27
|
|
|
25
28
|
export type BinaryTreePrintOptions = { isShowUndefined?: boolean, isShowNull?: boolean, isShowRedBlackNIL?: boolean }
|
|
26
29
|
|
|
27
|
-
export type BTNodeEntry<
|
|
30
|
+
export type BTNodeEntry<K, V> = [K | null | undefined, V | undefined];
|
|
28
31
|
|
|
29
|
-
export type BTNodeKeyOrNode<N> =
|
|
32
|
+
export type BTNodeKeyOrNode<K, N> = K | null | undefined | N;
|
|
30
33
|
|
|
31
|
-
export type BTNodeExemplar<
|
|
34
|
+
export type BTNodeExemplar<K, V, N> = BTNodeEntry<K, V> | BTNodeKeyOrNode<K, N>
|
|
32
35
|
|
|
33
|
-
export type BTNodePureExemplar<
|
|
36
|
+
export type BTNodePureExemplar<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>
|
|
34
37
|
|
|
35
|
-
export type BTNodePureKeyOrNode<N> =
|
|
38
|
+
export type BTNodePureKeyOrNode<K, N> = K | N;
|
|
36
39
|
|
|
37
|
-
export type BSTNodeKeyOrNode<N> =
|
|
40
|
+
export type BSTNodeKeyOrNode<K, N> = K | undefined | N;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AVLTree, AVLTreeNode } from '../../../data-structures';
|
|
2
2
|
import { BSTOptions } from './bst';
|
|
3
3
|
|
|
4
|
-
export type AVLTreeNodeNested<
|
|
4
|
+
export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
5
|
|
|
6
|
-
export type AVLTreeNested<
|
|
6
|
+
export type AVLTreeNested<K, V, N extends AVLTreeNode<K, V, N>> = AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
export type AVLTreeOptions = BSTOptions & {};
|
|
9
|
+
export type AVLTreeOptions<K> = BSTOptions<K> & {};
|
|
@@ -22,14 +22,15 @@ export enum FamilyPosition {
|
|
|
22
22
|
MAL_NODE = 'MAL_NODE'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export type BTNKey = number;
|
|
26
|
-
|
|
27
25
|
export type BiTreeDeleteResult<N> = { deleted: N | null | undefined; needBalanced: N | null | undefined };
|
|
28
26
|
|
|
29
|
-
export type BinaryTreeNodeNested<
|
|
27
|
+
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
30
28
|
|
|
31
|
-
export type BinaryTreeNested<
|
|
29
|
+
export type BinaryTreeNested<K, V, N extends BinaryTreeNode<K, V, N>> = BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
32
30
|
|
|
33
|
-
export type BinaryTreeOptions = {
|
|
31
|
+
export type BinaryTreeOptions<K> = {
|
|
32
|
+
iterationType: IterationType,
|
|
33
|
+
extractor: (key: K) => number
|
|
34
|
+
}
|
|
34
35
|
|
|
35
36
|
export type NodeDisplayLayout = [string[], number, number, number];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BST, BSTNode } from '../../../data-structures';
|
|
2
|
-
import type { BinaryTreeOptions
|
|
3
|
-
import {
|
|
2
|
+
import type { BinaryTreeOptions } from './binary-tree';
|
|
3
|
+
import { BSTVariant } from "../../common";
|
|
4
4
|
|
|
5
5
|
// prettier-ignore
|
|
6
|
-
export type BSTNodeNested<
|
|
6
|
+
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
7
7
|
|
|
8
|
-
export type BSTNested<
|
|
8
|
+
export type BSTNested<K, V, N extends BSTNode<K, V, N>> = BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
9
9
|
|
|
10
|
-
export type BSTOptions = BinaryTreeOptions & {
|
|
11
|
-
|
|
10
|
+
export type BSTOptions<K> = BinaryTreeOptions<K> & {
|
|
11
|
+
variant: BSTVariant
|
|
12
12
|
}
|
|
@@ -3,8 +3,8 @@ import { BSTOptions } from "./bst";
|
|
|
3
3
|
|
|
4
4
|
export enum RBTNColor { RED = 1, BLACK = 0}
|
|
5
5
|
|
|
6
|
-
export type RedBlackTreeNodeNested<
|
|
6
|
+
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
7
7
|
|
|
8
|
-
export type RedBlackTreeNested<
|
|
8
|
+
export type RedBlackTreeNested<K, V, N extends RedBlackTreeNode<K, V, N>> = RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
9
9
|
|
|
10
|
-
export type RBTreeOptions = BSTOptions & {};
|
|
10
|
+
export type RBTreeOptions<K> = BSTOptions<K> & {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TreeMultimap, TreeMultimapNode } from '../../../data-structures';
|
|
2
2
|
import { AVLTreeOptions } from './avl-tree';
|
|
3
3
|
|
|
4
|
-
export type TreeMultimapNodeNested<
|
|
4
|
+
export type TreeMultimapNodeNested<K, V> = TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
5
|
|
|
6
|
-
export type TreeMultimapNested<
|
|
6
|
+
export type TreeMultimapNested<K, V, N extends TreeMultimapNode<K, V, N>> = TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
7
7
|
|
|
8
|
-
export type TreeMultimapOptions = Omit<AVLTreeOptions
|
|
8
|
+
export type TreeMultimapOptions<K> = Omit<AVLTreeOptions<K>, 'isMergeDuplicatedNodeByKey'> & {}
|