min-heap-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/dist/data-structures/base/iterable-element-base.d.ts +1 -37
- package/dist/data-structures/base/iterable-element-base.js +1 -37
- package/dist/data-structures/base/iterable-entry-base.d.ts +2 -54
- package/dist/data-structures/base/iterable-entry-base.js +1 -49
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
- package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -46
- package/dist/data-structures/binary-tree/avl-tree.js +0 -46
- package/dist/data-structures/binary-tree/binary-tree.d.ts +82 -147
- package/dist/data-structures/binary-tree/binary-tree.js +299 -331
- package/dist/data-structures/binary-tree/bst.d.ts +1 -40
- package/dist/data-structures/binary-tree/bst.js +12 -44
- package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -48
- package/dist/data-structures/binary-tree/rb-tree.js +2 -50
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
- package/dist/data-structures/binary-tree/tree-multi-map.js +9 -41
- package/dist/data-structures/graph/abstract-graph.d.ts +0 -75
- package/dist/data-structures/graph/abstract-graph.js +0 -75
- package/dist/data-structures/graph/directed-graph.d.ts +0 -98
- package/dist/data-structures/graph/directed-graph.js +0 -98
- package/dist/data-structures/graph/undirected-graph.d.ts +0 -50
- package/dist/data-structures/graph/undirected-graph.js +0 -50
- package/dist/data-structures/hash/hash-map.d.ts +5 -92
- package/dist/data-structures/hash/hash-map.js +29 -115
- package/dist/data-structures/heap/heap.d.ts +0 -32
- package/dist/data-structures/heap/heap.js +0 -32
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
- package/dist/data-structures/linked-list/doubly-linked-list.js +5 -88
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +1 -83
- package/dist/data-structures/linked-list/singly-linked-list.js +2 -84
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +1 -35
- package/dist/data-structures/linked-list/skip-linked-list.js +1 -35
- package/dist/data-structures/queue/deque.d.ts +1 -98
- package/dist/data-structures/queue/deque.js +3 -99
- package/dist/data-structures/queue/queue.d.ts +5 -58
- package/dist/data-structures/queue/queue.js +4 -57
- package/dist/data-structures/stack/stack.d.ts +1 -34
- package/dist/data-structures/stack/stack.js +1 -34
- package/dist/data-structures/tree/tree.js +2 -1
- package/dist/data-structures/trie/trie.d.ts +0 -64
- package/dist/data-structures/trie/trie.js +0 -64
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
- package/dist/types/data-structures/binary-tree/binary-tree.js +6 -0
- package/dist/types/utils/utils.d.ts +13 -12
- package/dist/utils/number.d.ts +13 -0
- package/dist/utils/number.js +13 -0
- package/dist/utils/utils.d.ts +125 -3
- package/dist/utils/utils.js +177 -21
- package/package.json +2 -2
- 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
|
@@ -114,6 +114,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
114
114
|
* an instance of the `BSTNode` class.
|
|
115
115
|
*/
|
|
116
116
|
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
|
|
117
|
+
isKey(key: any): key is K;
|
|
117
118
|
/**
|
|
118
119
|
* Time Complexity: O(log n)
|
|
119
120
|
* Space Complexity: O(1)
|
|
@@ -126,10 +127,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
126
127
|
* @returns a boolean value.
|
|
127
128
|
*/
|
|
128
129
|
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Time Complexity: O(log n)
|
|
131
|
-
* Space Complexity: O(log n)
|
|
132
|
-
*/
|
|
133
130
|
/**
|
|
134
131
|
* Time Complexity: O(k log n)
|
|
135
132
|
* Space Complexity: O(k + log n)
|
|
@@ -175,10 +172,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
175
172
|
* @returns The method `getNodes` returns an array of `NODE` objects.
|
|
176
173
|
*/
|
|
177
174
|
getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[];
|
|
178
|
-
/**
|
|
179
|
-
* Time Complexity: O(log n)
|
|
180
|
-
* Space Complexity: O(1)
|
|
181
|
-
*/
|
|
182
175
|
/**
|
|
183
176
|
* Time Complexity: O(log n)
|
|
184
177
|
* Space Complexity: O(1)
|
|
@@ -201,10 +194,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
201
194
|
* @returns The method is returning a NODE object or undefined.
|
|
202
195
|
*/
|
|
203
196
|
getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): OptBSTN<NODE>;
|
|
204
|
-
/**
|
|
205
|
-
* Time Complexity: O(k log n)
|
|
206
|
-
* Space Complexity: O(k + log n)
|
|
207
|
-
*/
|
|
208
197
|
/**
|
|
209
198
|
* Time Complexity: O(log n)
|
|
210
199
|
* Space Complexity: O(1)
|
|
@@ -219,10 +208,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
219
208
|
* @returns The method is returning a NODE object or undefined.
|
|
220
209
|
*/
|
|
221
210
|
getNodeByKey(key: K, iterationType?: IterationType): OptBSTN<NODE>;
|
|
222
|
-
/**
|
|
223
|
-
* Time Complexity: O(log n)
|
|
224
|
-
* Space Complexity: O(k + log n)
|
|
225
|
-
*/
|
|
226
211
|
/**
|
|
227
212
|
* Time complexity: O(n)
|
|
228
213
|
* Space complexity: O(n)
|
|
@@ -244,10 +229,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
244
229
|
* @returns The method is returning an array of the return type of the callback function.
|
|
245
230
|
*/
|
|
246
231
|
dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
|
|
247
|
-
/**
|
|
248
|
-
* Time Complexity: O(log n)
|
|
249
|
-
* Space Complexity: O(1)
|
|
250
|
-
*/
|
|
251
232
|
/**
|
|
252
233
|
* Time complexity: O(n)
|
|
253
234
|
* Space complexity: O(n)
|
|
@@ -266,10 +247,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
266
247
|
* @returns an array of the return type of the callback function.
|
|
267
248
|
*/
|
|
268
249
|
bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
|
|
269
|
-
/**
|
|
270
|
-
* Time Complexity: O(log n)
|
|
271
|
-
* Space Complexity: O(1)
|
|
272
|
-
*/
|
|
273
250
|
/**
|
|
274
251
|
* Time complexity: O(n)
|
|
275
252
|
* Space complexity: O(n)
|
|
@@ -289,10 +266,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
289
266
|
* function.
|
|
290
267
|
*/
|
|
291
268
|
listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[][];
|
|
292
|
-
/**
|
|
293
|
-
* Time complexity: O(n)
|
|
294
|
-
* Space complexity: O(n)
|
|
295
|
-
*/
|
|
296
269
|
/**
|
|
297
270
|
* Time complexity: O(n)
|
|
298
271
|
* Space complexity: O(n)
|
|
@@ -315,10 +288,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
315
288
|
* `ReturnType<C>`, which is the return type of the callback function passed as an argument.
|
|
316
289
|
*/
|
|
317
290
|
lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
|
|
318
|
-
/**
|
|
319
|
-
* Time complexity: O(n)
|
|
320
|
-
* Space complexity: O(n)
|
|
321
|
-
*/
|
|
322
291
|
/**
|
|
323
292
|
* Time complexity: O(n)
|
|
324
293
|
* Space complexity: O(n)
|
|
@@ -332,10 +301,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
332
301
|
* @returns The function `perfectlyBalance` returns a boolean value.
|
|
333
302
|
*/
|
|
334
303
|
perfectlyBalance(iterationType?: IterationType): boolean;
|
|
335
|
-
/**
|
|
336
|
-
* Time complexity: O(n)
|
|
337
|
-
* Space complexity: O(n)
|
|
338
|
-
*/
|
|
339
304
|
/**
|
|
340
305
|
* Time Complexity: O(n)
|
|
341
306
|
* Space Complexity: O(log n)
|
|
@@ -351,10 +316,6 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
351
316
|
isAVLBalanced(iterationType?: IterationType): boolean;
|
|
352
317
|
protected _DEFAULT_COMPARATOR: (a: K, b: K) => number;
|
|
353
318
|
protected _comparator: Comparator<K>;
|
|
354
|
-
/**
|
|
355
|
-
* Time Complexity: O(n)
|
|
356
|
-
* Space Complexity: O(log n)
|
|
357
|
-
*/
|
|
358
319
|
/**
|
|
359
320
|
* The function returns the value of the _comparator property.
|
|
360
321
|
* @returns The `_comparator` property is being returned.
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BST = exports.BSTNode = void 0;
|
|
4
4
|
const binary_tree_1 = require("./binary-tree");
|
|
5
5
|
const queue_1 = require("../queue");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
6
7
|
class BSTNode extends binary_tree_1.BinaryTreeNode {
|
|
7
8
|
constructor(key, value) {
|
|
8
9
|
super(key, value);
|
|
@@ -145,7 +146,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
145
146
|
* @returns The method is returning either the node that was ensured or `undefined` if the node could
|
|
146
147
|
* not be ensured.
|
|
147
148
|
*/
|
|
148
|
-
ensureNode(keyOrNodeOrEntryOrRawElement, iterationType =
|
|
149
|
+
ensureNode(keyOrNodeOrEntryOrRawElement, iterationType = this.iterationType) {
|
|
149
150
|
var _a;
|
|
150
151
|
return (_a = super.ensureNode(keyOrNodeOrEntryOrRawElement, iterationType)) !== null && _a !== void 0 ? _a : undefined;
|
|
151
152
|
}
|
|
@@ -159,6 +160,9 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
159
160
|
isNode(keyOrNodeOrEntryOrRawElement) {
|
|
160
161
|
return keyOrNodeOrEntryOrRawElement instanceof BSTNode;
|
|
161
162
|
}
|
|
163
|
+
isKey(key) {
|
|
164
|
+
return (0, utils_1.isComparable)(key, this.comparator !== this._DEFAULT_COMPARATOR);
|
|
165
|
+
}
|
|
162
166
|
/**
|
|
163
167
|
* Time Complexity: O(log n)
|
|
164
168
|
* Space Complexity: O(1)
|
|
@@ -204,10 +208,6 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
204
208
|
}
|
|
205
209
|
return false;
|
|
206
210
|
}
|
|
207
|
-
/**
|
|
208
|
-
* Time Complexity: O(log n)
|
|
209
|
-
* Space Complexity: O(log n)
|
|
210
|
-
*/
|
|
211
211
|
/**
|
|
212
212
|
* Time Complexity: O(k log n)
|
|
213
213
|
* Space Complexity: O(k + log n)
|
|
@@ -337,6 +337,10 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
337
337
|
* @returns The method `getNodes` returns an array of `NODE` objects.
|
|
338
338
|
*/
|
|
339
339
|
getNodes(identifier, callback = this._DEFAULT_CALLBACK, onlyOne = false, beginRoot = this.root, iterationType = this.iterationType) {
|
|
340
|
+
if (identifier === undefined)
|
|
341
|
+
return [];
|
|
342
|
+
if (identifier === null)
|
|
343
|
+
return [];
|
|
340
344
|
beginRoot = this.ensureNode(beginRoot);
|
|
341
345
|
if (!beginRoot)
|
|
342
346
|
return [];
|
|
@@ -397,10 +401,6 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
397
401
|
}
|
|
398
402
|
return ans;
|
|
399
403
|
}
|
|
400
|
-
/**
|
|
401
|
-
* Time Complexity: O(log n)
|
|
402
|
-
* Space Complexity: O(1)
|
|
403
|
-
*/
|
|
404
404
|
/**
|
|
405
405
|
* Time Complexity: O(log n)
|
|
406
406
|
* Space Complexity: O(1)
|
|
@@ -426,10 +426,6 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
426
426
|
var _a;
|
|
427
427
|
return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) !== null && _a !== void 0 ? _a : undefined;
|
|
428
428
|
}
|
|
429
|
-
/**
|
|
430
|
-
* Time Complexity: O(k log n)
|
|
431
|
-
* Space Complexity: O(k + log n)
|
|
432
|
-
*/
|
|
433
429
|
/**
|
|
434
430
|
* Time Complexity: O(log n)
|
|
435
431
|
* Space Complexity: O(1)
|
|
@@ -443,13 +439,9 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
443
439
|
* It has a default value of `'ITERATIVE'`.
|
|
444
440
|
* @returns The method is returning a NODE object or undefined.
|
|
445
441
|
*/
|
|
446
|
-
getNodeByKey(key, iterationType =
|
|
442
|
+
getNodeByKey(key, iterationType = this.iterationType) {
|
|
447
443
|
return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType);
|
|
448
444
|
}
|
|
449
|
-
/**
|
|
450
|
-
* Time Complexity: O(log n)
|
|
451
|
-
* Space Complexity: O(k + log n)
|
|
452
|
-
*/
|
|
453
445
|
/**
|
|
454
446
|
* Time complexity: O(n)
|
|
455
447
|
* Space complexity: O(n)
|
|
@@ -470,13 +462,9 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
470
462
|
* following values:
|
|
471
463
|
* @returns The method is returning an array of the return type of the callback function.
|
|
472
464
|
*/
|
|
473
|
-
dfs(callback = this._DEFAULT_CALLBACK, pattern = 'IN', beginRoot = this.root, iterationType =
|
|
474
|
-
return super.dfs(callback, pattern, beginRoot, iterationType
|
|
465
|
+
dfs(callback = this._DEFAULT_CALLBACK, pattern = 'IN', beginRoot = this.root, iterationType = this.iterationType) {
|
|
466
|
+
return super.dfs(callback, pattern, beginRoot, iterationType);
|
|
475
467
|
}
|
|
476
|
-
/**
|
|
477
|
-
* Time Complexity: O(log n)
|
|
478
|
-
* Space Complexity: O(1)
|
|
479
|
-
*/
|
|
480
468
|
/**
|
|
481
469
|
* Time complexity: O(n)
|
|
482
470
|
* Space complexity: O(n)
|
|
@@ -497,10 +485,6 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
497
485
|
bfs(callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
|
|
498
486
|
return super.bfs(callback, beginRoot, iterationType, false);
|
|
499
487
|
}
|
|
500
|
-
/**
|
|
501
|
-
* Time Complexity: O(log n)
|
|
502
|
-
* Space Complexity: O(1)
|
|
503
|
-
*/
|
|
504
488
|
/**
|
|
505
489
|
* Time complexity: O(n)
|
|
506
490
|
* Space complexity: O(n)
|
|
@@ -522,10 +506,6 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
522
506
|
listLevels(callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
|
|
523
507
|
return super.listLevels(callback, beginRoot, iterationType, false);
|
|
524
508
|
}
|
|
525
|
-
/**
|
|
526
|
-
* Time complexity: O(n)
|
|
527
|
-
* Space complexity: O(n)
|
|
528
|
-
*/
|
|
529
509
|
/**
|
|
530
510
|
* Time complexity: O(n)
|
|
531
511
|
* Space complexity: O(n)
|
|
@@ -585,10 +565,6 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
585
565
|
return ans;
|
|
586
566
|
}
|
|
587
567
|
}
|
|
588
|
-
/**
|
|
589
|
-
* Time complexity: O(n)
|
|
590
|
-
* Space complexity: O(n)
|
|
591
|
-
*/
|
|
592
568
|
/**
|
|
593
569
|
* Time complexity: O(n)
|
|
594
570
|
* Space complexity: O(n)
|
|
@@ -637,10 +613,6 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
637
613
|
return true;
|
|
638
614
|
}
|
|
639
615
|
}
|
|
640
|
-
/**
|
|
641
|
-
* Time complexity: O(n)
|
|
642
|
-
* Space complexity: O(n)
|
|
643
|
-
*/
|
|
644
616
|
/**
|
|
645
617
|
* Time Complexity: O(n)
|
|
646
618
|
* Space Complexity: O(log n)
|
|
@@ -699,10 +671,6 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
699
671
|
}
|
|
700
672
|
return balanced;
|
|
701
673
|
}
|
|
702
|
-
/**
|
|
703
|
-
* Time Complexity: O(n)
|
|
704
|
-
* Space Complexity: O(log n)
|
|
705
|
-
*/
|
|
706
674
|
/**
|
|
707
675
|
* The function returns the value of the _comparator property.
|
|
708
676
|
* @returns The `_comparator` property is being returned.
|
|
@@ -67,10 +67,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
67
67
|
* @returns a new instance of a RedBlackTree object.
|
|
68
68
|
*/
|
|
69
69
|
createTree(options?: RBTreeOptions<K, V, R>): TREE;
|
|
70
|
-
/**
|
|
71
|
-
* Time Complexity: O(1)
|
|
72
|
-
* Space Complexity: O(1)
|
|
73
|
-
*/
|
|
74
70
|
/**
|
|
75
71
|
* Time Complexity: O(1)
|
|
76
72
|
* Space Complexity: O(1)
|
|
@@ -82,10 +78,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
82
78
|
* an instance of the `RedBlackTreeNode` class.
|
|
83
79
|
*/
|
|
84
80
|
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
|
|
85
|
-
/**
|
|
86
|
-
* Time Complexity: O(1)
|
|
87
|
-
* Space Complexity: O(1)
|
|
88
|
-
*/
|
|
89
81
|
/**
|
|
90
82
|
* Time Complexity: O(1)
|
|
91
83
|
* Space Complexity: O(1)
|
|
@@ -94,10 +86,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
94
86
|
* size counter to zero.
|
|
95
87
|
*/
|
|
96
88
|
clear(): void;
|
|
97
|
-
/**
|
|
98
|
-
* Time Complexity: O(log n)
|
|
99
|
-
* Space Complexity: O(1)
|
|
100
|
-
*/
|
|
101
89
|
/**
|
|
102
90
|
* Time Complexity: O(log n)
|
|
103
91
|
* Space Complexity: O(1)
|
|
@@ -114,10 +102,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
114
102
|
* returns true. If the node cannot be added or updated, the method returns false.
|
|
115
103
|
*/
|
|
116
104
|
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Time Complexity: O(log n)
|
|
119
|
-
* Space Complexity: O(1)
|
|
120
|
-
*/
|
|
121
105
|
/**
|
|
122
106
|
* Time Complexity: O(log n)
|
|
123
107
|
* Space Complexity: O(1)
|
|
@@ -135,10 +119,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
135
119
|
* @returns an array of BinaryTreeDeleteResult<NODE> objects.
|
|
136
120
|
*/
|
|
137
121
|
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback?: C): BinaryTreeDeleteResult<NODE>[];
|
|
138
|
-
/**
|
|
139
|
-
* Time Complexity: O(1)
|
|
140
|
-
* Space Complexity: O(1)
|
|
141
|
-
*/
|
|
142
122
|
/**
|
|
143
123
|
* Time Complexity: O(1)
|
|
144
124
|
* Space Complexity: O(1)
|
|
@@ -148,10 +128,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
148
128
|
* @param {NODE | undefined} v - v is a parameter of type NODE or undefined.
|
|
149
129
|
*/
|
|
150
130
|
protected _setRoot(v: NODE | undefined): void;
|
|
151
|
-
/**
|
|
152
|
-
* Time Complexity: O(1)
|
|
153
|
-
* Space Complexity: O(1)
|
|
154
|
-
*/
|
|
155
131
|
/**
|
|
156
132
|
* Time Complexity: O(1)
|
|
157
133
|
* Space Complexity: O(1)
|
|
@@ -165,10 +141,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
165
141
|
* superclass, with the `oldNode` and `newNode` parameters.
|
|
166
142
|
*/
|
|
167
143
|
protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
|
|
168
|
-
/**
|
|
169
|
-
* Time Complexity: O(log n)
|
|
170
|
-
* Space Complexity: O(1)
|
|
171
|
-
*/
|
|
172
144
|
/**
|
|
173
145
|
* Time Complexity: O(log n)
|
|
174
146
|
* Space Complexity: O(1)
|
|
@@ -182,10 +154,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
182
154
|
* was created and inserted into the tree.
|
|
183
155
|
*/
|
|
184
156
|
protected _insert(node: NODE): CRUD;
|
|
185
|
-
/**
|
|
186
|
-
* Time Complexity: O(1)
|
|
187
|
-
* Space Complexity: O(1)
|
|
188
|
-
*/
|
|
189
157
|
/**
|
|
190
158
|
* Time Complexity: O(1)
|
|
191
159
|
* Space Complexity: O(1)
|
|
@@ -196,10 +164,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
196
164
|
* either be a `NODE` object or `undefined`.
|
|
197
165
|
*/
|
|
198
166
|
protected _transplant(u: NODE, v: NODE | undefined): void;
|
|
199
|
-
/**
|
|
200
|
-
* Time Complexity: O(log n)
|
|
201
|
-
* Space Complexity: O(1)
|
|
202
|
-
*/
|
|
203
167
|
/**
|
|
204
168
|
* Time Complexity: O(log n)
|
|
205
169
|
* Space Complexity: O(1)
|
|
@@ -209,10 +173,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
209
173
|
* structure. It can either be a valid node or `undefined`.
|
|
210
174
|
*/
|
|
211
175
|
protected _insertFixup(z: NODE | undefined): void;
|
|
212
|
-
/**
|
|
213
|
-
* Time Complexity: O(log n)
|
|
214
|
-
* Space Complexity: O(1)
|
|
215
|
-
*/
|
|
216
176
|
/**
|
|
217
177
|
* Time Complexity: O(log n)
|
|
218
178
|
* Space Complexity: O(1)
|
|
@@ -225,10 +185,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
225
185
|
* does not return anything.
|
|
226
186
|
*/
|
|
227
187
|
protected _deleteFixup(node: NODE | undefined): void;
|
|
228
|
-
/**
|
|
229
|
-
* Time Complexity: O(1)
|
|
230
|
-
* Space Complexity: O(1)
|
|
231
|
-
*/
|
|
232
188
|
/**
|
|
233
189
|
* Time Complexity: O(1)
|
|
234
190
|
* Space Complexity: O(1)
|
|
@@ -239,10 +195,6 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
239
195
|
* @returns void, which means it does not return any value.
|
|
240
196
|
*/
|
|
241
197
|
protected _leftRotate(x: NODE | undefined): void;
|
|
242
|
-
/**
|
|
243
|
-
* Time Complexity: O(1)
|
|
244
|
-
* Space Complexity: O(1)
|
|
245
|
-
*/
|
|
246
198
|
/**
|
|
247
199
|
* Time Complexity: O(1)
|
|
248
200
|
* Space Complexity: O(1)
|
|
@@ -85,10 +85,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
85
85
|
createTree(options) {
|
|
86
86
|
return new RedBlackTree([], Object.assign({ iterationType: this.iterationType }, options));
|
|
87
87
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Time Complexity: O(1)
|
|
90
|
-
* Space Complexity: O(1)
|
|
91
|
-
*/
|
|
92
88
|
/**
|
|
93
89
|
* Time Complexity: O(1)
|
|
94
90
|
* Space Complexity: O(1)
|
|
@@ -124,7 +120,7 @@ class RedBlackTree extends bst_1.BST {
|
|
|
124
120
|
//
|
|
125
121
|
// if (this.toEntryFn) {
|
|
126
122
|
// const [key, entryValue] = this.toEntryFn(keyOrNodeOrEntryOrRawElement as R);
|
|
127
|
-
// if (key) return this.createNode(key, entryValue ?? value, 'RED');
|
|
123
|
+
// if (this.isKey(key)) return this.createNode(key, entryValue ?? value, 'RED');
|
|
128
124
|
// }
|
|
129
125
|
//
|
|
130
126
|
// if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
|
|
@@ -137,10 +133,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
137
133
|
//
|
|
138
134
|
// return ;
|
|
139
135
|
// }
|
|
140
|
-
/**
|
|
141
|
-
* Time Complexity: O(1)
|
|
142
|
-
* Space Complexity: O(1)
|
|
143
|
-
*/
|
|
144
136
|
/**
|
|
145
137
|
* Time Complexity: O(1)
|
|
146
138
|
* Space Complexity: O(1)
|
|
@@ -152,10 +144,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
152
144
|
super.clear();
|
|
153
145
|
this._root = this.NIL;
|
|
154
146
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Time Complexity: O(log n)
|
|
157
|
-
* Space Complexity: O(1)
|
|
158
|
-
*/
|
|
159
147
|
/**
|
|
160
148
|
* Time Complexity: O(log n)
|
|
161
149
|
* Space Complexity: O(1)
|
|
@@ -190,10 +178,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
190
178
|
else
|
|
191
179
|
return insertStatus === 'UPDATED';
|
|
192
180
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Time Complexity: O(log n)
|
|
195
|
-
* Space Complexity: O(1)
|
|
196
|
-
*/
|
|
197
181
|
/**
|
|
198
182
|
* Time Complexity: O(log n)
|
|
199
183
|
* Space Complexity: O(1)
|
|
@@ -230,7 +214,7 @@ class RedBlackTree extends bst_1.BST {
|
|
|
230
214
|
this._transplant(nodeToDelete, nodeToDelete.left);
|
|
231
215
|
}
|
|
232
216
|
else {
|
|
233
|
-
const successor = this.getLeftMost(nodeToDelete.right);
|
|
217
|
+
const successor = this.getLeftMost(node => node, nodeToDelete.right);
|
|
234
218
|
if (successor) {
|
|
235
219
|
originalColor = successor.color;
|
|
236
220
|
replacementNode = successor.right;
|
|
@@ -262,10 +246,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
262
246
|
results.push({ deleted: nodeToDelete, needBalanced: undefined });
|
|
263
247
|
return results;
|
|
264
248
|
}
|
|
265
|
-
/**
|
|
266
|
-
* Time Complexity: O(1)
|
|
267
|
-
* Space Complexity: O(1)
|
|
268
|
-
*/
|
|
269
249
|
/**
|
|
270
250
|
* Time Complexity: O(1)
|
|
271
251
|
* Space Complexity: O(1)
|
|
@@ -280,10 +260,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
280
260
|
}
|
|
281
261
|
this._root = v;
|
|
282
262
|
}
|
|
283
|
-
/**
|
|
284
|
-
* Time Complexity: O(1)
|
|
285
|
-
* Space Complexity: O(1)
|
|
286
|
-
*/
|
|
287
263
|
/**
|
|
288
264
|
* Time Complexity: O(1)
|
|
289
265
|
* Space Complexity: O(1)
|
|
@@ -300,10 +276,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
300
276
|
newNode.color = oldNode.color;
|
|
301
277
|
return super._replaceNode(oldNode, newNode);
|
|
302
278
|
}
|
|
303
|
-
/**
|
|
304
|
-
* Time Complexity: O(log n)
|
|
305
|
-
* Space Complexity: O(1)
|
|
306
|
-
*/
|
|
307
279
|
/**
|
|
308
280
|
* Time Complexity: O(log n)
|
|
309
281
|
* Space Complexity: O(1)
|
|
@@ -350,10 +322,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
350
322
|
this._insertFixup(node);
|
|
351
323
|
return 'CREATED';
|
|
352
324
|
}
|
|
353
|
-
/**
|
|
354
|
-
* Time Complexity: O(1)
|
|
355
|
-
* Space Complexity: O(1)
|
|
356
|
-
*/
|
|
357
325
|
/**
|
|
358
326
|
* Time Complexity: O(1)
|
|
359
327
|
* Space Complexity: O(1)
|
|
@@ -377,10 +345,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
377
345
|
v.parent = u.parent;
|
|
378
346
|
}
|
|
379
347
|
}
|
|
380
|
-
/**
|
|
381
|
-
* Time Complexity: O(log n)
|
|
382
|
-
* Space Complexity: O(1)
|
|
383
|
-
*/
|
|
384
348
|
/**
|
|
385
349
|
* Time Complexity: O(log n)
|
|
386
350
|
* Space Complexity: O(1)
|
|
@@ -448,10 +412,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
448
412
|
if (this.isRealNode(this._root))
|
|
449
413
|
this._root.color = 'BLACK';
|
|
450
414
|
}
|
|
451
|
-
/**
|
|
452
|
-
* Time Complexity: O(log n)
|
|
453
|
-
* Space Complexity: O(1)
|
|
454
|
-
*/
|
|
455
415
|
/**
|
|
456
416
|
* Time Complexity: O(log n)
|
|
457
417
|
* Space Complexity: O(1)
|
|
@@ -539,10 +499,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
539
499
|
node.color = 'BLACK';
|
|
540
500
|
}
|
|
541
501
|
}
|
|
542
|
-
/**
|
|
543
|
-
* Time Complexity: O(1)
|
|
544
|
-
* Space Complexity: O(1)
|
|
545
|
-
*/
|
|
546
502
|
/**
|
|
547
503
|
* Time Complexity: O(1)
|
|
548
504
|
* Space Complexity: O(1)
|
|
@@ -574,10 +530,6 @@ class RedBlackTree extends bst_1.BST {
|
|
|
574
530
|
y.left = x;
|
|
575
531
|
x.parent = y;
|
|
576
532
|
}
|
|
577
|
-
/**
|
|
578
|
-
* Time Complexity: O(1)
|
|
579
|
-
* Space Complexity: O(1)
|
|
580
|
-
*/
|
|
581
533
|
/**
|
|
582
534
|
* Time Complexity: O(1)
|
|
583
535
|
* Space Complexity: O(1)
|
|
@@ -53,10 +53,6 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
53
53
|
* @returns the sum of the count property of all nodes in the tree.
|
|
54
54
|
*/
|
|
55
55
|
get count(): number;
|
|
56
|
-
/**
|
|
57
|
-
* Time Complexity: O(n)
|
|
58
|
-
* Space Complexity: O(1)
|
|
59
|
-
*/
|
|
60
56
|
/**
|
|
61
57
|
* Time Complexity: O(n)
|
|
62
58
|
* Space Complexity: O(1)
|
|
@@ -110,10 +106,6 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
110
106
|
* an instance of the `TreeMultiMapNode` class.
|
|
111
107
|
*/
|
|
112
108
|
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
|
|
113
|
-
/**
|
|
114
|
-
* Time Complexity: O(log n)
|
|
115
|
-
* Space Complexity: O(1)
|
|
116
|
-
*/
|
|
117
109
|
/**
|
|
118
110
|
* Time Complexity: O(log n)
|
|
119
111
|
* Space Complexity: O(1)
|
|
@@ -131,10 +123,6 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
131
123
|
* was successful, and false otherwise.
|
|
132
124
|
*/
|
|
133
125
|
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Time Complexity: O(log n)
|
|
136
|
-
* Space Complexity: O(1)
|
|
137
|
-
*/
|
|
138
126
|
/**
|
|
139
127
|
* Time Complexity: O(log n)
|
|
140
128
|
* Space Complexity: O(1)
|
|
@@ -154,10 +142,6 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
154
142
|
* @returns an array of BinaryTreeDeleteResult<NODE> objects.
|
|
155
143
|
*/
|
|
156
144
|
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, 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 TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
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)
|
|
@@ -184,10 +164,6 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
184
164
|
* balancing operation is successful, and `false` if there are no nodes to balance.
|
|
185
165
|
*/
|
|
186
166
|
perfectlyBalance(iterationType?: IterationType): boolean;
|
|
187
|
-
/**
|
|
188
|
-
* Time complexity: O(n)
|
|
189
|
-
* Space complexity: O(n)
|
|
190
|
-
*/
|
|
191
167
|
/**
|
|
192
168
|
* Time complexity: O(n)
|
|
193
169
|
* Space complexity: O(n)
|
|
@@ -196,10 +172,6 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
196
172
|
* @returns The `clone()` method is returning a cloned instance of the `TREE` object.
|
|
197
173
|
*/
|
|
198
174
|
clone(): TREE;
|
|
199
|
-
/**
|
|
200
|
-
* Time Complexity: O(1)
|
|
201
|
-
* Space Complexity: O(1)
|
|
202
|
-
*/
|
|
203
175
|
/**
|
|
204
176
|
* Time Complexity: O(1)
|
|
205
177
|
* Space Complexity: O(1)
|
|
@@ -215,10 +187,6 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
215
187
|
* If either `srcNode` or `destNode` is undefined, it returns undefined.
|
|
216
188
|
*/
|
|
217
189
|
protected _swapProperties(srcNode: R | BSTNKeyOrNode<K, NODE>, destNode: R | BSTNKeyOrNode<K, NODE>): NODE | undefined;
|
|
218
|
-
/**
|
|
219
|
-
* Time Complexity: O(1)
|
|
220
|
-
* Space Complexity: O(1)
|
|
221
|
-
*/
|
|
222
190
|
/**
|
|
223
191
|
* Time Complexity: O(1)
|
|
224
192
|
* Space Complexity: O(1)
|