data-structure-typed 1.50.3 → 1.50.4

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.
Files changed (63) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -13
  2. package/CHANGELOG.md +1 -1
  3. package/README.md +6 -6
  4. package/README_zh-CN.md +6 -6
  5. package/dist/cjs/data-structures/binary-tree/{tree-multimap.d.ts → avl-tree-multi-map.d.ts} +11 -11
  6. package/dist/cjs/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +15 -15
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
  8. package/dist/cjs/data-structures/binary-tree/bst.js +5 -7
  9. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  10. package/dist/cjs/data-structures/binary-tree/index.d.ts +2 -1
  11. package/dist/cjs/data-structures/binary-tree/index.js +2 -1
  12. package/dist/cjs/data-structures/binary-tree/index.js.map +1 -1
  13. package/dist/cjs/data-structures/binary-tree/rb-tree.js +17 -9
  14. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +200 -0
  16. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +400 -0
  17. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -0
  18. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -0
  19. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js +3 -0
  20. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -0
  21. package/dist/cjs/types/data-structures/binary-tree/index.d.ts +2 -1
  22. package/dist/cjs/types/data-structures/binary-tree/index.js +2 -1
  23. package/dist/cjs/types/data-structures/binary-tree/index.js.map +1 -1
  24. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -0
  25. package/dist/cjs/types/data-structures/binary-tree/{tree-multimap.js → tree-multi-map.js} +1 -1
  26. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.js.map +1 -0
  27. package/dist/mjs/data-structures/binary-tree/{tree-multimap.d.ts → avl-tree-multi-map.d.ts} +11 -11
  28. package/dist/mjs/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +11 -11
  29. package/dist/mjs/data-structures/binary-tree/bst.js +5 -7
  30. package/dist/mjs/data-structures/binary-tree/index.d.ts +2 -1
  31. package/dist/mjs/data-structures/binary-tree/index.js +2 -1
  32. package/dist/mjs/data-structures/binary-tree/rb-tree.js +17 -9
  33. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +200 -0
  34. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +397 -0
  35. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -0
  36. package/dist/mjs/types/data-structures/binary-tree/index.d.ts +2 -1
  37. package/dist/mjs/types/data-structures/binary-tree/index.js +2 -1
  38. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -0
  39. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.js +1 -0
  40. package/dist/umd/data-structure-typed.js +399 -29
  41. package/dist/umd/data-structure-typed.min.js +2 -2
  42. package/dist/umd/data-structure-typed.min.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/data-structures/binary-tree/{tree-multimap.ts → avl-tree-multi-map.ts} +20 -20
  45. package/src/data-structures/binary-tree/bst.ts +5 -6
  46. package/src/data-structures/binary-tree/index.ts +2 -1
  47. package/src/data-structures/binary-tree/rb-tree.ts +20 -10
  48. package/src/data-structures/binary-tree/tree-multi-map.ts +463 -0
  49. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +8 -0
  50. package/src/types/data-structures/binary-tree/index.ts +2 -1
  51. package/src/types/data-structures/binary-tree/tree-multi-map.ts +8 -0
  52. package/test/integration/index.html +2 -2
  53. package/test/unit/data-structures/binary-tree/{tree-multimap.test.ts → avl-tree-multi-map.test.ts} +55 -55
  54. package/test/unit/data-structures/binary-tree/overall.test.ts +24 -25
  55. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +706 -0
  56. package/test/unit/data-structures/graph/undirected-graph.test.ts +4 -4
  57. package/test/unit/unrestricted-interconversion.test.ts +3 -3
  58. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +0 -1
  59. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.d.ts +0 -5
  60. package/dist/cjs/types/data-structures/binary-tree/tree-multimap.js.map +0 -1
  61. package/dist/mjs/types/data-structures/binary-tree/tree-multimap.d.ts +0 -5
  62. package/src/types/data-structures/binary-tree/tree-multimap.ts +0 -8
  63. /package/dist/mjs/types/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +0 -0
@@ -0,0 +1,200 @@
1
+ /**
2
+ * data-structure-typed
3
+ *
4
+ * @author Tyler Zeng
5
+ * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
+ * @license MIT License
7
+ */
8
+ import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
9
+ import { IterationType } from '../../types';
10
+ import { IBinaryTree } from '../../interfaces';
11
+ import { RedBlackTree, RedBlackTreeNode } from './rb-tree';
12
+ export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
13
+ /**
14
+ * The constructor function initializes an instance of a class with a key, value, and count.
15
+ * @param {K} key - The key parameter is of type K, which represents the type of the key for the
16
+ * constructor. It is required and must be provided when creating an instance of the class.
17
+ * @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
18
+ * value associated with the key in the constructor. If no value is provided, it will be `undefined`.
19
+ * @param [count=1] - The "count" parameter is an optional parameter that specifies the number of
20
+ * times the key-value pair should be repeated. If no value is provided for "count", it defaults to
21
+ * 1.
22
+ */
23
+ constructor(key: K, value?: V, count?: number);
24
+ protected _count: number;
25
+ /**
26
+ * The function returns the value of the private variable _count.
27
+ * @returns The count property of the object, which is of type number.
28
+ */
29
+ get count(): number;
30
+ /**
31
+ * The above function sets the value of the count property.
32
+ * @param {number} value - The value parameter is of type number, which means it can accept any
33
+ * numeric value.
34
+ */
35
+ set count(value: number);
36
+ }
37
+ export declare class TreeMultiMap<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, TREE extends TreeMultiMap<K, V, NODE, TREE> = TreeMultiMap<K, V, NODE, TreeMultiMapNested<K, V, NODE>>> extends RedBlackTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> {
38
+ /**
39
+ * The constructor function initializes a new instance of the TreeMultiMap class with optional
40
+ * initial keys, nodes, or entries.
41
+ * @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
42
+ * contain keys, nodes, or entries. It is used to initialize the TreeMultiMap with the provided keys,
43
+ * nodes, or entries.
44
+ * @param [options] - The `options` parameter is an optional object that can be passed to the
45
+ * constructor. It allows you to customize the behavior of the `TreeMultiMap` instance.
46
+ */
47
+ constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: TreeMultiMapOptions<K>);
48
+ protected _count: number;
49
+ /**
50
+ * The function calculates the sum of the count property of all nodes in a tree structure.
51
+ * @returns the sum of the count property of all nodes in the tree.
52
+ */
53
+ get count(): number;
54
+ /**
55
+ * The function creates a new TreeMultiMapNode object with the specified key, value, and count.
56
+ * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
57
+ * which is a generic type that can be replaced with any specific type when using the function.
58
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
59
+ * associated with the key in the node. It is of type `V`, which can be any data type.
60
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of a
61
+ * key-value pair in the TreeMultiMap. It is an optional parameter, so if it is not provided, it will
62
+ * default to 1.
63
+ * @returns a new instance of the TreeMultiMapNode class, casted as NODE.
64
+ */
65
+ createNode(key: K, value?: V, count?: number): NODE;
66
+ /**
67
+ * The function creates a new instance of a TreeMultiMap with the specified options and returns it.
68
+ * @param [options] - The `options` parameter is an optional object that contains additional
69
+ * configuration options for creating the `TreeMultiMap`. It can include properties such as
70
+ * `keyComparator`, `valueComparator`, `allowDuplicates`, etc.
71
+ * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
72
+ * existing `iterationType` option. The returned value is casted as `TREE`.
73
+ */
74
+ createTree(options?: TreeMultiMapOptions<K>): TREE;
75
+ /**
76
+ * The function `keyValueOrEntryToNode` takes a key, value, and count and returns a node if the input
77
+ * is valid.
78
+ * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
79
+ * NODE>`. It can accept three types of values:
80
+ * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
81
+ * value associated with a key in a key-value pair.
82
+ * @param [count=1] - The count parameter is an optional parameter that specifies the number of times
83
+ * the key-value pair should be added to the node. If not provided, it defaults to 1.
84
+ * @returns a NODE object or undefined.
85
+ */
86
+ keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
87
+ /**
88
+ * The function "isNode" checks if a given key, node, or entry is an instance of the TreeMultiMapNode
89
+ * class.
90
+ * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
91
+ * NODE>`.
92
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntry` is an instance
93
+ * of the `TreeMultiMapNode` class.
94
+ */
95
+ isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
96
+ /**
97
+ * Time Complexity: O(log n)
98
+ * Space Complexity: O(1)
99
+ */
100
+ /**
101
+ * Time Complexity: O(log n)
102
+ * Space Complexity: O(1)
103
+ *
104
+ * The function overrides the add method in TypeScript and adds a new node to the data structure.
105
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
106
+ * @param {V} [value] - The `value` parameter represents the value associated with the key in the
107
+ * data structure.
108
+ * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
109
+ * be added to the data structure. By default, it is set to 1, meaning that the key-value pair will
110
+ * be added once. However, you can specify a different value for `count` if you want to add
111
+ * @returns a boolean value.
112
+ */
113
+ add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
114
+ /**
115
+ * Time Complexity: O(log n)
116
+ * Space Complexity: O(1)
117
+ */
118
+ /**
119
+ * Time Complexity: O(log n)
120
+ * Space Complexity: O(1)
121
+ *
122
+ * The `delete` function in a TypeScript class is used to delete nodes from a binary tree based on a
123
+ * given identifier, and it returns an array of results containing information about the deleted
124
+ * nodes.
125
+ * @param {ReturnType<C> | null | undefined} identifier - The identifier parameter is the value used
126
+ * to identify the node to be deleted. It can be of any type that is returned by the callback
127
+ * function. It can also be null or undefined if no node needs to be deleted.
128
+ * @param {C} callback - The `callback` parameter is a function that takes a node of type `NODE` as
129
+ * input and returns a value of type `ReturnType<C>`. It is used to determine if a node matches the
130
+ * identifier for deletion. If no callback is provided, the `_defaultOneParamCallback` function is
131
+ * used
132
+ * @param [ignoreCount=false] - A boolean value indicating whether to ignore the count of the target
133
+ * node when performing deletion. If set to true, the count of the target node will not be considered
134
+ * and the node will be deleted regardless of its count. If set to false (default), the count of the
135
+ * target node will be decremented
136
+ * @returns an array of BinaryTreeDeleteResult<NODE> objects.
137
+ */
138
+ delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
139
+ /**
140
+ * Time Complexity: O(1)
141
+ * Space Complexity: O(1)
142
+ */
143
+ /**
144
+ * Time Complexity: O(1)
145
+ * Space Complexity: O(1)
146
+ *
147
+ * The "clear" function overrides the parent class's "clear" function and also resets the count to
148
+ * zero.
149
+ */
150
+ clear(): void;
151
+ /**
152
+ * Time Complexity: O(n log n)
153
+ * Space Complexity: O(log n)
154
+ */
155
+ /**
156
+ * Time Complexity: O(n log n)
157
+ * Space Complexity: O(log n)
158
+ *
159
+ * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
160
+ * tree using either a recursive or iterative approach.
161
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
162
+ * type of iteration to use when building the balanced binary search tree. It can have two possible
163
+ * values:
164
+ * @returns a boolean value.
165
+ */
166
+ perfectlyBalance(iterationType?: IterationType): boolean;
167
+ /**
168
+ * Time complexity: O(n)
169
+ * Space complexity: O(n)
170
+ */
171
+ /**
172
+ * Time complexity: O(n)
173
+ * Space complexity: O(n)
174
+ *
175
+ * The function overrides the clone method to create a deep copy of a tree object.
176
+ * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
177
+ */
178
+ clone(): TREE;
179
+ /**
180
+ * The function swaps the properties of two nodes in a binary search tree.
181
+ * @param srcNode - The source node that needs to be swapped with the destination node. It can be
182
+ * either a key or a node object.
183
+ * @param destNode - The `destNode` parameter is the node in the binary search tree where the
184
+ * properties will be swapped with the `srcNode`.
185
+ * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
186
+ * If both `srcNode` and `destNode` are valid nodes, the method swaps their `key`, `value`, `count`,
187
+ * and `color` properties. If the swapping is successful, the method returns the modified `destNode`.
188
+ * If either `srcNode` or `destNode` is
189
+ */
190
+ protected _swapProperties(srcNode: BSTNKeyOrNode<K, NODE>, destNode: BSTNKeyOrNode<K, NODE>): NODE | undefined;
191
+ /**
192
+ * The function replaces an old node with a new node and updates the count property of the new node.
193
+ * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
194
+ * needs to be replaced in the data structure.
195
+ * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
196
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
197
+ * superclass, after updating the `count` property of the `newNode` object.
198
+ */
199
+ protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
200
+ }
@@ -0,0 +1,400 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TreeMultiMap = exports.TreeMultiMapNode = void 0;
4
+ const types_1 = require("../../types");
5
+ const rb_tree_1 = require("./rb-tree");
6
+ class TreeMultiMapNode extends rb_tree_1.RedBlackTreeNode {
7
+ /**
8
+ * The constructor function initializes an instance of a class with a key, value, and count.
9
+ * @param {K} key - The key parameter is of type K, which represents the type of the key for the
10
+ * constructor. It is required and must be provided when creating an instance of the class.
11
+ * @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
12
+ * value associated with the key in the constructor. If no value is provided, it will be `undefined`.
13
+ * @param [count=1] - The "count" parameter is an optional parameter that specifies the number of
14
+ * times the key-value pair should be repeated. If no value is provided for "count", it defaults to
15
+ * 1.
16
+ */
17
+ constructor(key, value, count = 1) {
18
+ super(key, value);
19
+ this._count = 1;
20
+ this.count = count;
21
+ }
22
+ /**
23
+ * The function returns the value of the private variable _count.
24
+ * @returns The count property of the object, which is of type number.
25
+ */
26
+ get count() {
27
+ return this._count;
28
+ }
29
+ /**
30
+ * The above function sets the value of the count property.
31
+ * @param {number} value - The value parameter is of type number, which means it can accept any
32
+ * numeric value.
33
+ */
34
+ set count(value) {
35
+ this._count = value;
36
+ }
37
+ }
38
+ exports.TreeMultiMapNode = TreeMultiMapNode;
39
+ class TreeMultiMap extends rb_tree_1.RedBlackTree {
40
+ /**
41
+ * The constructor function initializes a new instance of the TreeMultiMap class with optional
42
+ * initial keys, nodes, or entries.
43
+ * @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
44
+ * contain keys, nodes, or entries. It is used to initialize the TreeMultiMap with the provided keys,
45
+ * nodes, or entries.
46
+ * @param [options] - The `options` parameter is an optional object that can be passed to the
47
+ * constructor. It allows you to customize the behavior of the `TreeMultiMap` instance.
48
+ */
49
+ constructor(keysOrNodesOrEntries = [], options) {
50
+ super([], options);
51
+ this._count = 0;
52
+ if (keysOrNodesOrEntries)
53
+ this.addMany(keysOrNodesOrEntries);
54
+ }
55
+ // TODO the _count is not accurate after nodes count modified
56
+ /**
57
+ * The function calculates the sum of the count property of all nodes in a tree structure.
58
+ * @returns the sum of the count property of all nodes in the tree.
59
+ */
60
+ get count() {
61
+ let sum = 0;
62
+ this.dfs(node => (sum += node.count));
63
+ return sum;
64
+ // return this._count;
65
+ }
66
+ /**
67
+ * The function creates a new TreeMultiMapNode object with the specified key, value, and count.
68
+ * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
69
+ * which is a generic type that can be replaced with any specific type when using the function.
70
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
71
+ * associated with the key in the node. It is of type `V`, which can be any data type.
72
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of a
73
+ * key-value pair in the TreeMultiMap. It is an optional parameter, so if it is not provided, it will
74
+ * default to 1.
75
+ * @returns a new instance of the TreeMultiMapNode class, casted as NODE.
76
+ */
77
+ createNode(key, value, count) {
78
+ return new TreeMultiMapNode(key, value, count);
79
+ }
80
+ /**
81
+ * The function creates a new instance of a TreeMultiMap with the specified options and returns it.
82
+ * @param [options] - The `options` parameter is an optional object that contains additional
83
+ * configuration options for creating the `TreeMultiMap`. It can include properties such as
84
+ * `keyComparator`, `valueComparator`, `allowDuplicates`, etc.
85
+ * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
86
+ * existing `iterationType` option. The returned value is casted as `TREE`.
87
+ */
88
+ createTree(options) {
89
+ return new TreeMultiMap([], Object.assign({ iterationType: this.iterationType }, options));
90
+ }
91
+ /**
92
+ * The function `keyValueOrEntryToNode` takes a key, value, and count and returns a node if the input
93
+ * is valid.
94
+ * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
95
+ * NODE>`. It can accept three types of values:
96
+ * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
97
+ * value associated with a key in a key-value pair.
98
+ * @param [count=1] - The count parameter is an optional parameter that specifies the number of times
99
+ * the key-value pair should be added to the node. If not provided, it defaults to 1.
100
+ * @returns a NODE object or undefined.
101
+ */
102
+ keyValueOrEntryToNode(keyOrNodeOrEntry, value, count = 1) {
103
+ let node;
104
+ if (keyOrNodeOrEntry === undefined || keyOrNodeOrEntry === null) {
105
+ return;
106
+ }
107
+ else if (this.isNode(keyOrNodeOrEntry)) {
108
+ node = keyOrNodeOrEntry;
109
+ }
110
+ else if (this.isEntry(keyOrNodeOrEntry)) {
111
+ const [key, value] = keyOrNodeOrEntry;
112
+ if (key === undefined || key === null) {
113
+ return;
114
+ }
115
+ else {
116
+ node = this.createNode(key, value, count);
117
+ }
118
+ }
119
+ else if (!this.isNode(keyOrNodeOrEntry)) {
120
+ node = this.createNode(keyOrNodeOrEntry, value, count);
121
+ }
122
+ else {
123
+ return;
124
+ }
125
+ return node;
126
+ }
127
+ /**
128
+ * The function "isNode" checks if a given key, node, or entry is an instance of the TreeMultiMapNode
129
+ * class.
130
+ * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
131
+ * NODE>`.
132
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntry` is an instance
133
+ * of the `TreeMultiMapNode` class.
134
+ */
135
+ isNode(keyOrNodeOrEntry) {
136
+ return keyOrNodeOrEntry instanceof TreeMultiMapNode;
137
+ }
138
+ /**
139
+ * Time Complexity: O(log n)
140
+ * Space Complexity: O(1)
141
+ */
142
+ /**
143
+ * Time Complexity: O(log n)
144
+ * Space Complexity: O(1)
145
+ *
146
+ * The function overrides the add method in TypeScript and adds a new node to the data structure.
147
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
148
+ * @param {V} [value] - The `value` parameter represents the value associated with the key in the
149
+ * data structure.
150
+ * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
151
+ * be added to the data structure. By default, it is set to 1, meaning that the key-value pair will
152
+ * be added once. However, you can specify a different value for `count` if you want to add
153
+ * @returns a boolean value.
154
+ */
155
+ add(keyOrNodeOrEntry, value, count = 1) {
156
+ const newNode = this.keyValueOrEntryToNode(keyOrNodeOrEntry, value, count);
157
+ if (newNode === undefined)
158
+ return false;
159
+ const orgNodeCount = (newNode === null || newNode === void 0 ? void 0 : newNode.count) || 0;
160
+ const inserted = super.add(newNode);
161
+ if (inserted) {
162
+ this._count += orgNodeCount;
163
+ }
164
+ return true;
165
+ }
166
+ /**
167
+ * Time Complexity: O(log n)
168
+ * Space Complexity: O(1)
169
+ */
170
+ /**
171
+ * Time Complexity: O(log n)
172
+ * Space Complexity: O(1)
173
+ *
174
+ * The `delete` function in a TypeScript class is used to delete nodes from a binary tree based on a
175
+ * given identifier, and it returns an array of results containing information about the deleted
176
+ * nodes.
177
+ * @param {ReturnType<C> | null | undefined} identifier - The identifier parameter is the value used
178
+ * to identify the node to be deleted. It can be of any type that is returned by the callback
179
+ * function. It can also be null or undefined if no node needs to be deleted.
180
+ * @param {C} callback - The `callback` parameter is a function that takes a node of type `NODE` as
181
+ * input and returns a value of type `ReturnType<C>`. It is used to determine if a node matches the
182
+ * identifier for deletion. If no callback is provided, the `_defaultOneParamCallback` function is
183
+ * used
184
+ * @param [ignoreCount=false] - A boolean value indicating whether to ignore the count of the target
185
+ * node when performing deletion. If set to true, the count of the target node will not be considered
186
+ * and the node will be deleted regardless of its count. If set to false (default), the count of the
187
+ * target node will be decremented
188
+ * @returns an array of BinaryTreeDeleteResult<NODE> objects.
189
+ */
190
+ delete(identifier, callback = this._defaultOneParamCallback, ignoreCount = false) {
191
+ const deleteResults = [];
192
+ if (identifier === null)
193
+ return deleteResults;
194
+ // Helper function to perform deletion
195
+ const deleteHelper = (node) => {
196
+ // Initialize targetNode to the sentinel node
197
+ let targetNode = this._Sentinel;
198
+ let currentNode;
199
+ // Find the node to be deleted based on the identifier
200
+ while (node !== this._Sentinel) {
201
+ // Update targetNode if the current node matches the identifier
202
+ if (node && callback(node) === identifier) {
203
+ targetNode = node;
204
+ }
205
+ // Move to the right or left based on the comparison with the identifier
206
+ if (node && identifier && callback(node) <= identifier) {
207
+ node = node.right;
208
+ }
209
+ else {
210
+ node = node === null || node === void 0 ? void 0 : node.left;
211
+ }
212
+ }
213
+ // If the target node is not found, decrement size and return
214
+ if (targetNode === this._Sentinel) {
215
+ return;
216
+ }
217
+ if (ignoreCount || targetNode.count <= 1) {
218
+ // Store the parent of the target node and its original color
219
+ let parentNode = targetNode;
220
+ let parentNodeOriginalColor = parentNode.color;
221
+ // Handle deletion based on the number of children of the target node
222
+ if (targetNode.left === this._Sentinel) {
223
+ // Target node has no left child - deletion case 1
224
+ currentNode = targetNode.right;
225
+ this._rbTransplant(targetNode, targetNode.right);
226
+ }
227
+ else if (targetNode.right === this._Sentinel) {
228
+ // Target node has no right child - deletion case 2
229
+ currentNode = targetNode.left;
230
+ this._rbTransplant(targetNode, targetNode.left);
231
+ }
232
+ else {
233
+ // Target node has both left and right children - deletion case 3
234
+ parentNode = this.getLeftMost(targetNode.right);
235
+ parentNodeOriginalColor = parentNode.color;
236
+ currentNode = parentNode.right;
237
+ if (parentNode.parent === targetNode) {
238
+ // Target node's right child becomes its parent's left child
239
+ currentNode.parent = parentNode;
240
+ }
241
+ else {
242
+ // Replace parentNode with its right child and update connections
243
+ this._rbTransplant(parentNode, parentNode.right);
244
+ parentNode.right = targetNode.right;
245
+ parentNode.right.parent = parentNode;
246
+ }
247
+ // Replace the target node with its in-order successor
248
+ this._rbTransplant(targetNode, parentNode);
249
+ parentNode.left = targetNode.left;
250
+ parentNode.left.parent = parentNode;
251
+ parentNode.color = targetNode.color;
252
+ }
253
+ // Fix the Red-Black Tree properties after deletion
254
+ if (parentNodeOriginalColor === types_1.RBTNColor.BLACK) {
255
+ this._fixDelete(currentNode);
256
+ }
257
+ // Decrement the size and store information about the deleted node
258
+ this._size--;
259
+ this._count -= targetNode.count;
260
+ deleteResults.push({ deleted: targetNode, needBalanced: undefined });
261
+ }
262
+ else {
263
+ targetNode.count--;
264
+ this._count--;
265
+ }
266
+ };
267
+ // Call the helper function with the root of the tree
268
+ deleteHelper(this.root);
269
+ // Return the result array
270
+ return deleteResults;
271
+ }
272
+ /**
273
+ * Time Complexity: O(1)
274
+ * Space Complexity: O(1)
275
+ */
276
+ /**
277
+ * Time Complexity: O(1)
278
+ * Space Complexity: O(1)
279
+ *
280
+ * The "clear" function overrides the parent class's "clear" function and also resets the count to
281
+ * zero.
282
+ */
283
+ clear() {
284
+ super.clear();
285
+ this._count = 0;
286
+ }
287
+ /**
288
+ * Time Complexity: O(n log n)
289
+ * Space Complexity: O(log n)
290
+ */
291
+ /**
292
+ * Time Complexity: O(n log n)
293
+ * Space Complexity: O(log n)
294
+ *
295
+ * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
296
+ * tree using either a recursive or iterative approach.
297
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
298
+ * type of iteration to use when building the balanced binary search tree. It can have two possible
299
+ * values:
300
+ * @returns a boolean value.
301
+ */
302
+ perfectlyBalance(iterationType = this.iterationType) {
303
+ const sorted = this.dfs(node => node, 'in'), n = sorted.length;
304
+ if (sorted.length < 1)
305
+ return false;
306
+ this.clear();
307
+ if (iterationType === types_1.IterationType.RECURSIVE) {
308
+ const buildBalanceBST = (l, r) => {
309
+ if (l > r)
310
+ return;
311
+ const m = l + Math.floor((r - l) / 2);
312
+ const midNode = sorted[m];
313
+ this.add(midNode.key, midNode.value, midNode.count);
314
+ buildBalanceBST(l, m - 1);
315
+ buildBalanceBST(m + 1, r);
316
+ };
317
+ buildBalanceBST(0, n - 1);
318
+ return true;
319
+ }
320
+ else {
321
+ const stack = [[0, n - 1]];
322
+ while (stack.length > 0) {
323
+ const popped = stack.pop();
324
+ if (popped) {
325
+ const [l, r] = popped;
326
+ if (l <= r) {
327
+ const m = l + Math.floor((r - l) / 2);
328
+ const midNode = sorted[m];
329
+ this.add(midNode.key, midNode.value, midNode.count);
330
+ stack.push([m + 1, r]);
331
+ stack.push([l, m - 1]);
332
+ }
333
+ }
334
+ }
335
+ return true;
336
+ }
337
+ }
338
+ /**
339
+ * Time complexity: O(n)
340
+ * Space complexity: O(n)
341
+ */
342
+ /**
343
+ * Time complexity: O(n)
344
+ * Space complexity: O(n)
345
+ *
346
+ * The function overrides the clone method to create a deep copy of a tree object.
347
+ * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
348
+ */
349
+ clone() {
350
+ const cloned = this.createTree();
351
+ this.bfs(node => cloned.add(node.key, node.value, node.count));
352
+ return cloned;
353
+ }
354
+ /**
355
+ * The function swaps the properties of two nodes in a binary search tree.
356
+ * @param srcNode - The source node that needs to be swapped with the destination node. It can be
357
+ * either a key or a node object.
358
+ * @param destNode - The `destNode` parameter is the node in the binary search tree where the
359
+ * properties will be swapped with the `srcNode`.
360
+ * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
361
+ * If both `srcNode` and `destNode` are valid nodes, the method swaps their `key`, `value`, `count`,
362
+ * and `color` properties. If the swapping is successful, the method returns the modified `destNode`.
363
+ * If either `srcNode` or `destNode` is
364
+ */
365
+ _swapProperties(srcNode, destNode) {
366
+ srcNode = this.ensureNode(srcNode);
367
+ destNode = this.ensureNode(destNode);
368
+ if (srcNode && destNode) {
369
+ const { key, value, count, color } = destNode;
370
+ const tempNode = this.createNode(key, value, count);
371
+ if (tempNode) {
372
+ tempNode.color = color;
373
+ destNode.key = srcNode.key;
374
+ destNode.value = srcNode.value;
375
+ destNode.count = srcNode.count;
376
+ destNode.color = srcNode.color;
377
+ srcNode.key = tempNode.key;
378
+ srcNode.value = tempNode.value;
379
+ srcNode.count = tempNode.count;
380
+ srcNode.color = tempNode.color;
381
+ }
382
+ return destNode;
383
+ }
384
+ return undefined;
385
+ }
386
+ /**
387
+ * The function replaces an old node with a new node and updates the count property of the new node.
388
+ * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
389
+ * needs to be replaced in the data structure.
390
+ * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
391
+ * @returns The method is returning the result of calling the `_replaceNode` method from the
392
+ * superclass, after updating the `count` property of the `newNode` object.
393
+ */
394
+ _replaceNode(oldNode, newNode) {
395
+ newNode.count = oldNode.count + newNode.count;
396
+ return super._replaceNode(oldNode, newNode);
397
+ }
398
+ }
399
+ exports.TreeMultiMap = TreeMultiMap;
400
+ //# sourceMappingURL=tree-multi-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-multi-map.ts"],"names":[],"mappings":";;;AAgBA,uCAAuD;AAEvD,uCAA2D;AAE3D,MAAa,gBAIX,SAAQ,0BAA4B;IACpC;;;;;;;;;OASG;IACH,YAAY,GAAM,EAAE,KAAS,EAAE,KAAK,GAAG,CAAC;QACtC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAIV,WAAM,GAAW,CAAC,CAAC;QAH3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAID;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;CACF;AAtCD,4CAsCC;AAED,MAAa,YAMX,SAAQ,sBAA8B;IAEtC;;;;;;;;OAQG;IACH,YAAY,uBAA+D,EAAE,EAAE,OAAgC;QAC7G,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAIX,WAAM,GAAG,CAAC,CAAC;QAHnB,IAAI,oBAAoB;YAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/D,CAAC;IAID,6DAA6D;IAC7D;;;OAGG;IACH,IAAI,KA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ptions } from './avl-tree';
3
+ export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ export type AVLTreeMultiMapNested<K, V, N extends AVLTreeMultiMapNode<K, V, N>> = AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ export type AVLTreeMultiMapOptions<K> = AVLTreeOptions<K> & {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=avl-tree-multi-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avl-tree-multi-map.js","sourceRoot":"","sources":["../../../../../src/types/data-structures/binary-tree/avl-tree-multi-map.ts"],"names":[],"mappings":""}
@@ -2,5 +2,6 @@ export * from './binary-tree';
2
2
  export * from './bst';
3
3
  export * from './avl-tree';
4
4
  export * from './segment-tree';
5
- export * from './tree-multimap';
5
+ export * from './avl-tree-multi-map';
6
6
  export * from './rb-tree';
7
+ export * from './tree-multi-map';
@@ -18,6 +18,7 @@ __exportStar(require("./binary-tree"), exports);
18
18
  __exportStar(require("./bst"), exports);
19
19
  __exportStar(require("./avl-tree"), exports);
20
20
  __exportStar(require("./segment-tree"), exports);
21
- __exportStar(require("./tree-multimap"), exports);
21
+ __exportStar(require("./avl-tree-multi-map"), exports);
22
22
  __exportStar(require("./rb-tree"), exports);
23
+ __exportStar(require("./tree-multi-map"), exports);
23
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/data-structures/binary-tree/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,wCAAsB;AACtB,6CAA2B;AAC3B,iDAA+B;AAC/B,kDAAgC;AAChC,4CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/data-structures/binary-tree/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,wCAAsB;AACtB,6CAA2B;AAC3B,iDAA+B;AAC/B,uDAAqC;AACrC,4CAA0B;AAC1B,mDAAiC"}