data-structure-typed 1.52.3 → 1.52.5
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/CHANGELOG.md +2 -1
- package/README.md +13 -13
- package/README_zh-CN.md +216 -26
- package/benchmark/report.html +13 -13
- package/benchmark/report.json +158 -158
- package/dist/cjs/data-structures/base/iterable-element-base.d.ts +1 -37
- package/dist/cjs/data-structures/base/iterable-element-base.js +1 -37
- package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
- package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +2 -54
- package/dist/cjs/data-structures/base/iterable-entry-base.js +1 -49
- package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -46
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +299 -331
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +1 -40
- package/dist/cjs/data-structures/binary-tree/bst.js +12 -44
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +2 -50
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +9 -41
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -75
- package/dist/cjs/data-structures/graph/abstract-graph.js +0 -75
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +0 -98
- package/dist/cjs/data-structures/graph/directed-graph.js +0 -98
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +0 -50
- package/dist/cjs/data-structures/graph/undirected-graph.js +0 -50
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +5 -92
- package/dist/cjs/data-structures/hash/hash-map.js +29 -115
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +0 -32
- package/dist/cjs/data-structures/heap/heap.js +0 -32
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +5 -88
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +1 -83
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +2 -84
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +1 -35
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +1 -35
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +1 -98
- package/dist/cjs/data-structures/queue/deque.js +3 -99
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +5 -58
- package/dist/cjs/data-structures/queue/queue.js +4 -57
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +1 -34
- package/dist/cjs/data-structures/stack/stack.js +1 -34
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/tree/tree.js +0 -1
- package/dist/cjs/data-structures/tree/tree.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +0 -64
- package/dist/cjs/data-structures/trie/trie.js +0 -64
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +6 -0
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/types/utils/utils.d.ts +13 -12
- package/dist/cjs/utils/number.d.ts +13 -0
- package/dist/cjs/utils/number.js +13 -0
- package/dist/cjs/utils/number.js.map +1 -1
- package/dist/cjs/utils/utils.d.ts +125 -3
- package/dist/cjs/utils/utils.js +177 -21
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/base/iterable-element-base.d.ts +1 -37
- package/dist/mjs/data-structures/base/iterable-element-base.js +1 -37
- package/dist/mjs/data-structures/base/iterable-entry-base.d.ts +2 -54
- package/dist/mjs/data-structures/base/iterable-entry-base.js +1 -49
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +0 -46
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +298 -332
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +1 -40
- package/dist/mjs/data-structures/binary-tree/bst.js +12 -44
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +2 -50
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +9 -41
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +0 -75
- package/dist/mjs/data-structures/graph/abstract-graph.js +0 -75
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +0 -98
- package/dist/mjs/data-structures/graph/directed-graph.js +0 -98
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +0 -50
- package/dist/mjs/data-structures/graph/undirected-graph.js +0 -50
- package/dist/mjs/data-structures/hash/hash-map.d.ts +5 -92
- package/dist/mjs/data-structures/hash/hash-map.js +29 -115
- package/dist/mjs/data-structures/heap/heap.d.ts +0 -32
- package/dist/mjs/data-structures/heap/heap.js +0 -32
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +5 -88
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +1 -83
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +2 -84
- package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +1 -35
- package/dist/mjs/data-structures/linked-list/skip-linked-list.js +1 -35
- package/dist/mjs/data-structures/queue/deque.d.ts +1 -98
- package/dist/mjs/data-structures/queue/deque.js +3 -99
- package/dist/mjs/data-structures/queue/queue.d.ts +5 -58
- package/dist/mjs/data-structures/queue/queue.js +4 -57
- package/dist/mjs/data-structures/stack/stack.d.ts +1 -34
- package/dist/mjs/data-structures/stack/stack.js +1 -34
- package/dist/mjs/data-structures/tree/tree.js +0 -1
- package/dist/mjs/data-structures/trie/trie.d.ts +0 -64
- package/dist/mjs/data-structures/trie/trie.js +0 -64
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +5 -1
- package/dist/mjs/types/utils/utils.d.ts +13 -12
- package/dist/mjs/utils/number.d.ts +13 -0
- package/dist/mjs/utils/number.js +13 -0
- package/dist/mjs/utils/utils.d.ts +125 -3
- package/dist/mjs/utils/utils.js +177 -21
- package/dist/umd/data-structure-typed.js +414 -1482
- package/dist/umd/data-structure-typed.min.js +5 -4
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +6 -6
- package/src/data-structures/base/iterable-element-base.ts +2 -42
- package/src/data-structures/base/iterable-entry-base.ts +3 -62
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +8 -48
- package/src/data-structures/binary-tree/avl-tree.ts +0 -57
- package/src/data-structures/binary-tree/binary-tree.ts +329 -358
- package/src/data-structures/binary-tree/bst.ts +11 -54
- package/src/data-structures/binary-tree/rb-tree.ts +2 -62
- package/src/data-structures/binary-tree/tree-multi-map.ts +8 -48
- package/src/data-structures/graph/abstract-graph.ts +0 -92
- package/src/data-structures/graph/directed-graph.ts +0 -122
- package/src/data-structures/graph/undirected-graph.ts +0 -62
- package/src/data-structures/hash/hash-map.ts +31 -139
- package/src/data-structures/heap/heap.ts +0 -40
- package/src/data-structures/linked-list/doubly-linked-list.ts +5 -112
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -104
- package/src/data-structures/linked-list/skip-linked-list.ts +1 -44
- package/src/data-structures/queue/deque.ts +2 -125
- package/src/data-structures/queue/queue.ts +5 -72
- package/src/data-structures/stack/stack.ts +1 -43
- package/src/data-structures/tree/tree.ts +1 -1
- package/src/data-structures/trie/trie.ts +0 -80
- package/src/types/data-structures/binary-tree/binary-tree.ts +8 -1
- package/src/types/utils/utils.ts +17 -15
- package/src/utils/number.ts +13 -0
- package/src/utils/utils.ts +174 -18
- package/test/config.ts +8 -0
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +13 -13
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +18 -13
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +471 -64
- package/test/unit/data-structures/binary-tree/bst.test.ts +167 -23
- package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +136 -13
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +18 -13
- package/test/unit/data-structures/graph/directed-graph.test.ts +46 -32
- package/test/unit/data-structures/graph/map-graph.test.ts +24 -2
- package/test/unit/data-structures/graph/undirected-graph.test.ts +24 -24
- package/test/unit/data-structures/hash/hash-map.test.ts +225 -35
- package/test/unit/data-structures/heap/heap.test.ts +47 -39
- package/test/unit/data-structures/heap/min-heap.test.ts +5 -5
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +34 -4
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +32 -0
- package/test/unit/data-structures/matrix/matrix.test.ts +35 -5
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +31 -0
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +18 -0
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +17 -0
- package/test/unit/data-structures/queue/deque.test.ts +288 -47
- package/test/unit/data-structures/queue/queue.test.ts +62 -37
- package/test/unit/data-structures/stack/stack.test.ts +30 -5
- package/test/unit/data-structures/tree/tree.test.ts +58 -0
- package/test/unit/data-structures/trie/trie.test.ts +46 -5
- package/test/unit/utils/utils.test.ts +169 -0
|
@@ -20,10 +20,6 @@ export class IterableEntryBase {
|
|
|
20
20
|
*[Symbol.iterator](...args) {
|
|
21
21
|
yield* this._getIterator(...args);
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Time Complexity: O(n)
|
|
25
|
-
* Space Complexity: O(n)
|
|
26
|
-
*/
|
|
27
23
|
/**
|
|
28
24
|
* Time Complexity: O(n)
|
|
29
25
|
* Space Complexity: O(n)
|
|
@@ -36,10 +32,6 @@ export class IterableEntryBase {
|
|
|
36
32
|
yield item;
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Time Complexity: O(n)
|
|
41
|
-
* Space Complexity: O(n)
|
|
42
|
-
*/
|
|
43
35
|
/**
|
|
44
36
|
* Time Complexity: O(n)
|
|
45
37
|
* Space Complexity: O(n)
|
|
@@ -51,10 +43,6 @@ export class IterableEntryBase {
|
|
|
51
43
|
yield item[0];
|
|
52
44
|
}
|
|
53
45
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Time Complexity: O(n)
|
|
56
|
-
* Space Complexity: O(n)
|
|
57
|
-
*/
|
|
58
46
|
/**
|
|
59
47
|
* Time Complexity: O(n)
|
|
60
48
|
* Space Complexity: O(n)
|
|
@@ -66,10 +54,6 @@ export class IterableEntryBase {
|
|
|
66
54
|
yield item[1];
|
|
67
55
|
}
|
|
68
56
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Time Complexity: O(n)
|
|
71
|
-
* Space Complexity: O(1)
|
|
72
|
-
*/
|
|
73
57
|
/**
|
|
74
58
|
* Time Complexity: O(n)
|
|
75
59
|
* Space Complexity: O(1)
|
|
@@ -93,10 +77,6 @@ export class IterableEntryBase {
|
|
|
93
77
|
}
|
|
94
78
|
return true;
|
|
95
79
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Time Complexity: O(n)
|
|
98
|
-
* Space Complexity: O(1)
|
|
99
|
-
*/
|
|
100
80
|
/**
|
|
101
81
|
* Time Complexity: O(n)
|
|
102
82
|
* Space Complexity: O(1)
|
|
@@ -121,14 +101,6 @@ export class IterableEntryBase {
|
|
|
121
101
|
}
|
|
122
102
|
return false;
|
|
123
103
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Time Complexity: O(n)
|
|
126
|
-
* Space Complexity: O(1)
|
|
127
|
-
*/
|
|
128
|
-
/**
|
|
129
|
-
* Time Complexity: O(n)
|
|
130
|
-
* Space Complexity: O(1)
|
|
131
|
-
*/
|
|
132
104
|
/**
|
|
133
105
|
* Time Complexity: O(n)
|
|
134
106
|
* Space Complexity: O(1)
|
|
@@ -149,10 +121,6 @@ export class IterableEntryBase {
|
|
|
149
121
|
callbackfn.call(thisArg, value, key, index++, this);
|
|
150
122
|
}
|
|
151
123
|
}
|
|
152
|
-
/**
|
|
153
|
-
* Time Complexity: O(n)
|
|
154
|
-
* Space Complexity: O(1)
|
|
155
|
-
*/
|
|
156
124
|
/**
|
|
157
125
|
* Time Complexity: O(n)
|
|
158
126
|
* Space Complexity: O(1)
|
|
@@ -179,10 +147,6 @@ export class IterableEntryBase {
|
|
|
179
147
|
}
|
|
180
148
|
return;
|
|
181
149
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Time Complexity: O(n)
|
|
184
|
-
* Space Complexity: O(1)
|
|
185
|
-
*/
|
|
186
150
|
/**
|
|
187
151
|
* Time Complexity: O(n)
|
|
188
152
|
* Space Complexity: O(1)
|
|
@@ -201,10 +165,6 @@ export class IterableEntryBase {
|
|
|
201
165
|
}
|
|
202
166
|
return false;
|
|
203
167
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Time Complexity: O(n)
|
|
206
|
-
* Space Complexity: O(1)
|
|
207
|
-
*/
|
|
208
168
|
/**
|
|
209
169
|
* Time Complexity: O(n)
|
|
210
170
|
* Space Complexity: O(1)
|
|
@@ -221,10 +181,6 @@ export class IterableEntryBase {
|
|
|
221
181
|
}
|
|
222
182
|
return false;
|
|
223
183
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Time Complexity: O(n)
|
|
226
|
-
* Space Complexity: O(1)
|
|
227
|
-
*/
|
|
228
184
|
/**
|
|
229
185
|
* Time Complexity: O(n)
|
|
230
186
|
* Space Complexity: O(1)
|
|
@@ -268,10 +224,6 @@ export class IterableEntryBase {
|
|
|
268
224
|
}
|
|
269
225
|
return accumulator;
|
|
270
226
|
}
|
|
271
|
-
/**
|
|
272
|
-
* Time Complexity: O(n)
|
|
273
|
-
* Space Complexity: O(n)
|
|
274
|
-
*/
|
|
275
227
|
/**
|
|
276
228
|
* Time Complexity: O(n)
|
|
277
229
|
* Space Complexity: O(n)
|
|
@@ -279,6 +231,6 @@ export class IterableEntryBase {
|
|
|
279
231
|
* The print function logs the elements of an array to the console.
|
|
280
232
|
*/
|
|
281
233
|
print() {
|
|
282
|
-
|
|
234
|
+
return [...this];
|
|
283
235
|
}
|
|
284
236
|
}
|
|
@@ -54,10 +54,6 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
54
54
|
* @returns the sum of the count property of all nodes in the tree.
|
|
55
55
|
*/
|
|
56
56
|
get count(): number;
|
|
57
|
-
/**
|
|
58
|
-
* Time Complexity: O(n)
|
|
59
|
-
* Space Complexity: O(1)
|
|
60
|
-
*/
|
|
61
57
|
/**
|
|
62
58
|
* Time Complexity: O(n)
|
|
63
59
|
* Space Complexity: O(1)
|
|
@@ -108,10 +104,6 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
108
104
|
* @returns either a NODE object or undefined.
|
|
109
105
|
*/
|
|
110
106
|
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* Time Complexity: O(log n)
|
|
113
|
-
* Space Complexity: O(1)
|
|
114
|
-
*/
|
|
115
107
|
/**
|
|
116
108
|
* Time Complexity: O(log n)
|
|
117
109
|
* Space Complexity: O(1)
|
|
@@ -130,10 +122,6 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
130
122
|
* @returns a boolean value.
|
|
131
123
|
*/
|
|
132
124
|
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Time Complexity: O(log n)
|
|
135
|
-
* Space Complexity: O(1)
|
|
136
|
-
*/
|
|
137
125
|
/**
|
|
138
126
|
* Time Complexity: O(log n)
|
|
139
127
|
* Space Complexity: O(1)
|
|
@@ -154,10 +142,6 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
154
142
|
* @returns an array of `BinaryTreeDeleteResult<NODE>`.
|
|
155
143
|
*/
|
|
156
144
|
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
|
|
157
|
-
/**
|
|
158
|
-
* Time Complexity: O(1)
|
|
159
|
-
* Space Complexity: O(1)
|
|
160
|
-
*/
|
|
161
145
|
/**
|
|
162
146
|
* Time Complexity: O(1)
|
|
163
147
|
* Space Complexity: O(1)
|
|
@@ -166,10 +150,6 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
166
150
|
* zero.
|
|
167
151
|
*/
|
|
168
152
|
clear(): void;
|
|
169
|
-
/**
|
|
170
|
-
* Time Complexity: O(n log n)
|
|
171
|
-
* Space Complexity: O(log n)
|
|
172
|
-
*/
|
|
173
153
|
/**
|
|
174
154
|
* Time Complexity: O(n log n)
|
|
175
155
|
* Space Complexity: O(log n)
|
|
@@ -183,10 +163,6 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
183
163
|
* balancing operation is successful, and `false` if there are no nodes to balance.
|
|
184
164
|
*/
|
|
185
165
|
perfectlyBalance(iterationType?: IterationType): boolean;
|
|
186
|
-
/**
|
|
187
|
-
* Time complexity: O(n)
|
|
188
|
-
* Space complexity: O(n)
|
|
189
|
-
*/
|
|
190
166
|
/**
|
|
191
167
|
* Time complexity: O(n)
|
|
192
168
|
* Space complexity: O(n)
|
|
@@ -195,10 +171,6 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
195
171
|
* @returns The `clone()` method is returning a cloned instance of the `TREE` object.
|
|
196
172
|
*/
|
|
197
173
|
clone(): TREE;
|
|
198
|
-
/**
|
|
199
|
-
* Time Complexity: O(1)
|
|
200
|
-
* Space Complexity: O(1)
|
|
201
|
-
*/
|
|
202
174
|
/**
|
|
203
175
|
* Time Complexity: O(1)
|
|
204
176
|
* Space Complexity: O(1)
|
|
@@ -213,10 +185,6 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
|
|
|
213
185
|
* If either `srcNode` or `destNode` is undefined, it returns `undefined`.
|
|
214
186
|
*/
|
|
215
187
|
protected _swapProperties(srcNode: R | BSTNKeyOrNode<K, NODE>, destNode: R | BSTNKeyOrNode<K, NODE>): NODE | undefined;
|
|
216
|
-
/**
|
|
217
|
-
* Time Complexity: O(1)
|
|
218
|
-
* Space Complexity: O(1)
|
|
219
|
-
*/
|
|
220
188
|
/**
|
|
221
189
|
* Time Complexity: O(1)
|
|
222
190
|
* Space Complexity: O(1)
|
|
@@ -57,10 +57,6 @@ export class AVLTreeMultiMap extends AVLTree {
|
|
|
57
57
|
get count() {
|
|
58
58
|
return this._count;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Time Complexity: O(n)
|
|
62
|
-
* Space Complexity: O(1)
|
|
63
|
-
*/
|
|
64
60
|
/**
|
|
65
61
|
* Time Complexity: O(n)
|
|
66
62
|
* Space Complexity: O(1)
|
|
@@ -129,26 +125,22 @@ export class AVLTreeMultiMap extends AVLTree {
|
|
|
129
125
|
return;
|
|
130
126
|
if (this.isNode(keyOrNodeOrEntryOrRawElement))
|
|
131
127
|
return keyOrNodeOrEntryOrRawElement;
|
|
132
|
-
if (this.toEntryFn) {
|
|
133
|
-
const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
|
|
134
|
-
if (key)
|
|
135
|
-
return this.createNode(key, entryValue ?? value, count);
|
|
136
|
-
}
|
|
137
128
|
if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
|
|
138
|
-
const [key,
|
|
129
|
+
const [key, entryValue] = keyOrNodeOrEntryOrRawElement;
|
|
139
130
|
if (key === undefined || key === null)
|
|
140
131
|
return;
|
|
141
|
-
|
|
142
|
-
return this.createNode(key, value, count);
|
|
132
|
+
if (this.isKey(key))
|
|
133
|
+
return this.createNode(key, value ?? entryValue, count);
|
|
134
|
+
}
|
|
135
|
+
if (this.toEntryFn) {
|
|
136
|
+
const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
|
|
137
|
+
if (this.isKey(key))
|
|
138
|
+
return this.createNode(key, value ?? entryValue, count);
|
|
143
139
|
}
|
|
144
140
|
if (this.isKey(keyOrNodeOrEntryOrRawElement))
|
|
145
141
|
return this.createNode(keyOrNodeOrEntryOrRawElement, value, count);
|
|
146
142
|
return;
|
|
147
143
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Time Complexity: O(log n)
|
|
150
|
-
* Space Complexity: O(1)
|
|
151
|
-
*/
|
|
152
144
|
/**
|
|
153
145
|
* Time Complexity: O(log n)
|
|
154
146
|
* Space Complexity: O(1)
|
|
@@ -177,10 +169,6 @@ export class AVLTreeMultiMap extends AVLTree {
|
|
|
177
169
|
}
|
|
178
170
|
return true;
|
|
179
171
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Time Complexity: O(log n)
|
|
182
|
-
* Space Complexity: O(1)
|
|
183
|
-
*/
|
|
184
172
|
/**
|
|
185
173
|
* Time Complexity: O(log n)
|
|
186
174
|
* Space Complexity: O(1)
|
|
@@ -232,7 +220,7 @@ export class AVLTreeMultiMap extends AVLTree {
|
|
|
232
220
|
}
|
|
233
221
|
}
|
|
234
222
|
else {
|
|
235
|
-
const leftSubTreeRightMost = curr.left ? this.getRightMost(curr.left) : undefined;
|
|
223
|
+
const leftSubTreeRightMost = curr.left ? this.getRightMost(node => node, curr.left) : undefined;
|
|
236
224
|
if (leftSubTreeRightMost) {
|
|
237
225
|
const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
|
|
238
226
|
orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
|
|
@@ -258,10 +246,6 @@ export class AVLTreeMultiMap extends AVLTree {
|
|
|
258
246
|
}
|
|
259
247
|
return deletedResult;
|
|
260
248
|
}
|
|
261
|
-
/**
|
|
262
|
-
* Time Complexity: O(1)
|
|
263
|
-
* Space Complexity: O(1)
|
|
264
|
-
*/
|
|
265
249
|
/**
|
|
266
250
|
* Time Complexity: O(1)
|
|
267
251
|
* Space Complexity: O(1)
|
|
@@ -273,10 +257,6 @@ export class AVLTreeMultiMap extends AVLTree {
|
|
|
273
257
|
super.clear();
|
|
274
258
|
this._count = 0;
|
|
275
259
|
}
|
|
276
|
-
/**
|
|
277
|
-
* Time Complexity: O(n log n)
|
|
278
|
-
* Space Complexity: O(log n)
|
|
279
|
-
*/
|
|
280
260
|
/**
|
|
281
261
|
* Time Complexity: O(n log n)
|
|
282
262
|
* Space Complexity: O(log n)
|
|
@@ -325,10 +305,6 @@ export class AVLTreeMultiMap extends AVLTree {
|
|
|
325
305
|
return true;
|
|
326
306
|
}
|
|
327
307
|
}
|
|
328
|
-
/**
|
|
329
|
-
* Time complexity: O(n)
|
|
330
|
-
* Space complexity: O(n)
|
|
331
|
-
*/
|
|
332
308
|
/**
|
|
333
309
|
* Time complexity: O(n)
|
|
334
310
|
* Space complexity: O(n)
|
|
@@ -341,10 +317,6 @@ export class AVLTreeMultiMap extends AVLTree {
|
|
|
341
317
|
this.bfs(node => cloned.add(node.key, node.value, node.count));
|
|
342
318
|
return cloned;
|
|
343
319
|
}
|
|
344
|
-
/**
|
|
345
|
-
* Time Complexity: O(1)
|
|
346
|
-
* Space Complexity: O(1)
|
|
347
|
-
*/
|
|
348
320
|
/**
|
|
349
321
|
* Time Complexity: O(1)
|
|
350
322
|
* Space Complexity: O(1)
|
|
@@ -379,10 +351,6 @@ export class AVLTreeMultiMap extends AVLTree {
|
|
|
379
351
|
}
|
|
380
352
|
return undefined;
|
|
381
353
|
}
|
|
382
|
-
/**
|
|
383
|
-
* Time Complexity: O(1)
|
|
384
|
-
* Space Complexity: O(1)
|
|
385
|
-
*/
|
|
386
354
|
/**
|
|
387
355
|
* Time Complexity: O(1)
|
|
388
356
|
* Space Complexity: O(1)
|
|
@@ -80,11 +80,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
80
80
|
* an instance of the `AVLTreeNode` class.
|
|
81
81
|
*/
|
|
82
82
|
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
|
|
83
|
-
/**
|
|
84
|
-
* Time Complexity: O(log n)
|
|
85
|
-
* Space Complexity: O(1)
|
|
86
|
-
* logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
|
|
87
|
-
*/
|
|
88
83
|
/**
|
|
89
84
|
* Time Complexity: O(log n)
|
|
90
85
|
* Space Complexity: O(1)
|
|
@@ -99,10 +94,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
99
94
|
* @returns The method is returning a boolean value.
|
|
100
95
|
*/
|
|
101
96
|
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Time Complexity: O(log n)
|
|
104
|
-
* Space Complexity: O(1)
|
|
105
|
-
*/
|
|
106
97
|
/**
|
|
107
98
|
* Time Complexity: O(log n)
|
|
108
99
|
* Space Complexity: O(1)
|
|
@@ -117,10 +108,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
117
108
|
* @returns The method is returning an array of BinaryTreeDeleteResult<NODE> objects.
|
|
118
109
|
*/
|
|
119
110
|
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback?: C): BinaryTreeDeleteResult<NODE>[];
|
|
120
|
-
/**
|
|
121
|
-
* Time Complexity: O(1)
|
|
122
|
-
* Space Complexity: O(1)
|
|
123
|
-
*/
|
|
124
111
|
/**
|
|
125
112
|
* Time Complexity: O(1)
|
|
126
113
|
* Space Complexity: O(1)
|
|
@@ -135,10 +122,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
135
122
|
* `destNodeEnsured` are truthy. Otherwise, it returns `undefined`.
|
|
136
123
|
*/
|
|
137
124
|
protected _swapProperties(srcNode: R | BSTNKeyOrNode<K, NODE>, destNode: R | BSTNKeyOrNode<K, NODE>): NODE | undefined;
|
|
138
|
-
/**
|
|
139
|
-
* Time Complexity: O(1)
|
|
140
|
-
* Space Complexity: O(1)
|
|
141
|
-
*/
|
|
142
125
|
/**
|
|
143
126
|
* Time Complexity: O(1)
|
|
144
127
|
* Space Complexity: O(1)
|
|
@@ -150,10 +133,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
150
133
|
* height of the left subtree from the height of the right subtree.
|
|
151
134
|
*/
|
|
152
135
|
protected _balanceFactor(node: NODE): number;
|
|
153
|
-
/**
|
|
154
|
-
* Time Complexity: O(1)
|
|
155
|
-
* Space Complexity: O(1)
|
|
156
|
-
*/
|
|
157
136
|
/**
|
|
158
137
|
* Time Complexity: O(1)
|
|
159
138
|
* Space Complexity: O(1)
|
|
@@ -163,10 +142,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
163
142
|
* @param {NODE} node - The parameter "node" represents a node in a binary tree data structure.
|
|
164
143
|
*/
|
|
165
144
|
protected _updateHeight(node: NODE): void;
|
|
166
|
-
/**
|
|
167
|
-
* Time Complexity: O(1)
|
|
168
|
-
* Space Complexity: O(1)
|
|
169
|
-
*/
|
|
170
145
|
/**
|
|
171
146
|
* Time Complexity: O(1)
|
|
172
147
|
* Space Complexity: O(1)
|
|
@@ -175,10 +150,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
175
150
|
* @param {NODE} A - A is a node in a binary tree.
|
|
176
151
|
*/
|
|
177
152
|
protected _balanceLL(A: NODE): void;
|
|
178
|
-
/**
|
|
179
|
-
* Time Complexity: O(1)
|
|
180
|
-
* Space Complexity: O(1)
|
|
181
|
-
*/
|
|
182
153
|
/**
|
|
183
154
|
* Time Complexity: O(1)
|
|
184
155
|
* Space Complexity: O(1)
|
|
@@ -187,10 +158,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
187
158
|
* @param {NODE} A - A is a node in a binary tree.
|
|
188
159
|
*/
|
|
189
160
|
protected _balanceLR(A: NODE): void;
|
|
190
|
-
/**
|
|
191
|
-
* Time Complexity: O(1)
|
|
192
|
-
* Space Complexity: O(1)
|
|
193
|
-
*/
|
|
194
161
|
/**
|
|
195
162
|
* Time Complexity: O(1)
|
|
196
163
|
* Space Complexity: O(1)
|
|
@@ -199,10 +166,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
199
166
|
* @param {NODE} A - A is a node in a binary tree.
|
|
200
167
|
*/
|
|
201
168
|
protected _balanceRR(A: NODE): void;
|
|
202
|
-
/**
|
|
203
|
-
* Time Complexity: O(1)
|
|
204
|
-
* Space Complexity: O(1)
|
|
205
|
-
*/
|
|
206
169
|
/**
|
|
207
170
|
* Time Complexity: O(1)
|
|
208
171
|
* Space Complexity: O(1)
|
|
@@ -211,11 +174,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
211
174
|
* @param {NODE} A - A is a node in a binary tree.
|
|
212
175
|
*/
|
|
213
176
|
protected _balanceRL(A: NODE): void;
|
|
214
|
-
/**
|
|
215
|
-
* Time Complexity: O(log n)
|
|
216
|
-
* Space Complexity: O(1)
|
|
217
|
-
* logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root. constant space, as it doesn't use additional data structures that scale with input size.
|
|
218
|
-
*/
|
|
219
177
|
/**
|
|
220
178
|
* Time Complexity: O(log n)
|
|
221
179
|
* Space Complexity: O(1)
|
|
@@ -226,10 +184,6 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
|
|
|
226
184
|
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
227
185
|
*/
|
|
228
186
|
protected _balancePath(node: R | BTNKeyOrNodeOrEntry<K, V, NODE>): void;
|
|
229
|
-
/**
|
|
230
|
-
* Time Complexity: O(1)
|
|
231
|
-
* Space Complexity: O(1)
|
|
232
|
-
*/
|
|
233
187
|
/**
|
|
234
188
|
* Time Complexity: O(1)
|
|
235
189
|
* Space Complexity: O(1)
|
|
@@ -98,11 +98,6 @@ export class AVLTree extends BST {
|
|
|
98
98
|
isNode(keyOrNodeOrEntryOrRawElement) {
|
|
99
99
|
return keyOrNodeOrEntryOrRawElement instanceof AVLTreeNode;
|
|
100
100
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Time Complexity: O(log n)
|
|
103
|
-
* Space Complexity: O(1)
|
|
104
|
-
* logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
|
|
105
|
-
*/
|
|
106
101
|
/**
|
|
107
102
|
* Time Complexity: O(log n)
|
|
108
103
|
* Space Complexity: O(1)
|
|
@@ -124,10 +119,6 @@ export class AVLTree extends BST {
|
|
|
124
119
|
this._balancePath(keyOrNodeOrEntryOrRawElement);
|
|
125
120
|
return inserted;
|
|
126
121
|
}
|
|
127
|
-
/**
|
|
128
|
-
* Time Complexity: O(log n)
|
|
129
|
-
* Space Complexity: O(1)
|
|
130
|
-
*/
|
|
131
122
|
/**
|
|
132
123
|
* Time Complexity: O(log n)
|
|
133
124
|
* Space Complexity: O(1)
|
|
@@ -150,10 +141,6 @@ export class AVLTree extends BST {
|
|
|
150
141
|
}
|
|
151
142
|
return deletedResults;
|
|
152
143
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Time Complexity: O(1)
|
|
155
|
-
* Space Complexity: O(1)
|
|
156
|
-
*/
|
|
157
144
|
/**
|
|
158
145
|
* Time Complexity: O(1)
|
|
159
146
|
* Space Complexity: O(1)
|
|
@@ -186,10 +173,6 @@ export class AVLTree extends BST {
|
|
|
186
173
|
}
|
|
187
174
|
return undefined;
|
|
188
175
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Time Complexity: O(1)
|
|
191
|
-
* Space Complexity: O(1)
|
|
192
|
-
*/
|
|
193
176
|
/**
|
|
194
177
|
* Time Complexity: O(1)
|
|
195
178
|
* Space Complexity: O(1)
|
|
@@ -210,10 +193,6 @@ export class AVLTree extends BST {
|
|
|
210
193
|
else
|
|
211
194
|
return node.right.height - node.left.height;
|
|
212
195
|
}
|
|
213
|
-
/**
|
|
214
|
-
* Time Complexity: O(1)
|
|
215
|
-
* Space Complexity: O(1)
|
|
216
|
-
*/
|
|
217
196
|
/**
|
|
218
197
|
* Time Complexity: O(1)
|
|
219
198
|
* Space Complexity: O(1)
|
|
@@ -234,10 +213,6 @@ export class AVLTree extends BST {
|
|
|
234
213
|
else
|
|
235
214
|
node.height = 1 + Math.max(node.right.height, node.left.height);
|
|
236
215
|
}
|
|
237
|
-
/**
|
|
238
|
-
* Time Complexity: O(1)
|
|
239
|
-
* Space Complexity: O(1)
|
|
240
|
-
*/
|
|
241
216
|
/**
|
|
242
217
|
* Time Complexity: O(1)
|
|
243
218
|
* Space Complexity: O(1)
|
|
@@ -275,10 +250,6 @@ export class AVLTree extends BST {
|
|
|
275
250
|
if (B)
|
|
276
251
|
this._updateHeight(B);
|
|
277
252
|
}
|
|
278
|
-
/**
|
|
279
|
-
* Time Complexity: O(1)
|
|
280
|
-
* Space Complexity: O(1)
|
|
281
|
-
*/
|
|
282
253
|
/**
|
|
283
254
|
* Time Complexity: O(1)
|
|
284
255
|
* Space Complexity: O(1)
|
|
@@ -331,10 +302,6 @@ export class AVLTree extends BST {
|
|
|
331
302
|
B && this._updateHeight(B);
|
|
332
303
|
C && this._updateHeight(C);
|
|
333
304
|
}
|
|
334
|
-
/**
|
|
335
|
-
* Time Complexity: O(1)
|
|
336
|
-
* Space Complexity: O(1)
|
|
337
|
-
*/
|
|
338
305
|
/**
|
|
339
306
|
* Time Complexity: O(1)
|
|
340
307
|
* Space Complexity: O(1)
|
|
@@ -373,10 +340,6 @@ export class AVLTree extends BST {
|
|
|
373
340
|
this._updateHeight(A);
|
|
374
341
|
B && this._updateHeight(B);
|
|
375
342
|
}
|
|
376
|
-
/**
|
|
377
|
-
* Time Complexity: O(1)
|
|
378
|
-
* Space Complexity: O(1)
|
|
379
|
-
*/
|
|
380
343
|
/**
|
|
381
344
|
* Time Complexity: O(1)
|
|
382
345
|
* Space Complexity: O(1)
|
|
@@ -429,11 +392,6 @@ export class AVLTree extends BST {
|
|
|
429
392
|
B && this._updateHeight(B);
|
|
430
393
|
C && this._updateHeight(C);
|
|
431
394
|
}
|
|
432
|
-
/**
|
|
433
|
-
* Time Complexity: O(log n)
|
|
434
|
-
* Space Complexity: O(1)
|
|
435
|
-
* logarithmic time, where "n" is the number of nodes in the tree. The method traverses the path from the inserted node to the root. constant space, as it doesn't use additional data structures that scale with input size.
|
|
436
|
-
*/
|
|
437
395
|
/**
|
|
438
396
|
* Time Complexity: O(log n)
|
|
439
397
|
* Space Complexity: O(1)
|
|
@@ -483,10 +441,6 @@ export class AVLTree extends BST {
|
|
|
483
441
|
// TODO So far, no sure if this is necessary that Recursive Repair: Once rotation operations are executed, it may cause imbalance issues at higher levels of the tree. Therefore, you need to recursively check and repair imbalance problems upwards until you reach the root node.
|
|
484
442
|
}
|
|
485
443
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Time Complexity: O(1)
|
|
488
|
-
* Space Complexity: O(1)
|
|
489
|
-
*/
|
|
490
444
|
/**
|
|
491
445
|
* Time Complexity: O(1)
|
|
492
446
|
* Space Complexity: O(1)
|