bst-typed 2.1.0 → 2.1.2
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/cjs/index.cjs +3413 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/index.mjs +3406 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/data-structures/base/index.d.ts +2 -1
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +182 -2
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +135 -2
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +291 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -1
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -29
- package/dist/types/data-structures/binary-tree/bst.d.ts +413 -12
- package/dist/types/data-structures/binary-tree/index.d.ts +3 -2
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +208 -3
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -1
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +190 -2
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +270 -2
- package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -14
- package/dist/types/data-structures/graph/directed-graph.d.ts +207 -1
- package/dist/types/data-structures/graph/index.d.ts +2 -1
- package/dist/types/data-structures/graph/map-graph.d.ts +78 -1
- package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -1
- package/dist/types/data-structures/hash/hash-map.d.ts +345 -19
- package/dist/types/data-structures/hash/index.d.ts +0 -1
- package/dist/types/data-structures/heap/heap.d.ts +503 -5
- package/dist/types/data-structures/heap/index.d.ts +2 -0
- package/dist/types/data-structures/heap/max-heap.d.ts +32 -1
- package/dist/types/data-structures/heap/min-heap.d.ts +33 -1
- package/dist/types/data-structures/index.d.ts +7 -7
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -2
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -4
- package/dist/types/data-structures/matrix/index.d.ts +1 -1
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -7
- package/dist/types/data-structures/matrix/navigator.d.ts +54 -13
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -1
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -1
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -2
- package/dist/types/data-structures/queue/deque.d.ts +431 -4
- package/dist/types/data-structures/queue/queue.d.ts +308 -4
- package/dist/types/data-structures/stack/stack.d.ts +306 -2
- package/dist/types/data-structures/tree/tree.d.ts +62 -1
- package/dist/types/data-structures/trie/trie.d.ts +350 -4
- package/dist/types/index.d.ts +13 -2
- package/dist/{interfaces → types/interfaces}/binary-tree.d.ts +3 -3
- package/dist/types/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
- package/dist/{data-structures → types/types/data-structures}/binary-tree/index.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
- package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
- package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
- package/dist/{data-structures → types/types/data-structures}/graph/index.d.ts +1 -2
- package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
- package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
- package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
- package/dist/types/types/data-structures/hash/index.d.ts +2 -0
- package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
- package/dist/types/types/data-structures/heap/index.d.ts +1 -0
- package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
- package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
- package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
- package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
- package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
- package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
- package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
- package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
- package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
- package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/utils/index.d.ts +2 -0
- package/dist/types/types/utils/utils.d.ts +22 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +209 -22
- package/dist/umd/bst-typed.js +3410 -0
- package/dist/umd/bst-typed.js.map +1 -0
- package/dist/umd/bst-typed.min.js +13 -0
- package/dist/umd/bst-typed.min.js.map +1 -0
- package/package.json +24 -5
- package/src/data-structures/binary-tree/avl-tree-counter.ts +8 -11
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +6 -11
- package/src/data-structures/binary-tree/avl-tree.ts +6 -8
- package/src/data-structures/binary-tree/binary-tree.ts +13 -15
- package/src/data-structures/binary-tree/bst.ts +6 -11
- package/src/data-structures/binary-tree/red-black-tree.ts +6 -11
- package/src/data-structures/binary-tree/tree-counter.ts +8 -13
- package/src/data-structures/binary-tree/tree-multi-map.ts +6 -11
- package/src/data-structures/heap/heap.ts +5 -5
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/interfaces/binary-tree.ts +3 -3
- package/tsconfig.base.json +23 -0
- package/tsconfig.json +8 -34
- package/tsconfig.test.json +8 -0
- package/tsconfig.types.json +15 -0
- package/tsup.config.js +28 -0
- package/tsup.node.config.js +37 -0
- package/dist/common/index.js +0 -28
- package/dist/constants/index.js +0 -8
- package/dist/data-structures/base/index.d.ts +0 -2
- package/dist/data-structures/base/index.js +0 -18
- package/dist/data-structures/base/iterable-element-base.js +0 -243
- package/dist/data-structures/base/iterable-entry-base.js +0 -183
- package/dist/data-structures/base/linear-base.js +0 -415
- package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
- package/dist/data-structures/binary-tree/avl-tree-counter.js +0 -374
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +0 -250
- package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -291
- package/dist/data-structures/binary-tree/avl-tree.js +0 -611
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +0 -294
- package/dist/data-structures/binary-tree/binary-tree.d.ts +0 -754
- package/dist/data-structures/binary-tree/binary-tree.js +0 -1925
- package/dist/data-structures/binary-tree/bst.d.ts +0 -413
- package/dist/data-structures/binary-tree/bst.js +0 -903
- package/dist/data-structures/binary-tree/index.js +0 -26
- package/dist/data-structures/binary-tree/red-black-tree.d.ts +0 -208
- package/dist/data-structures/binary-tree/red-black-tree.js +0 -546
- package/dist/data-structures/binary-tree/segment-tree.d.ts +0 -160
- package/dist/data-structures/binary-tree/segment-tree.js +0 -297
- package/dist/data-structures/binary-tree/tree-counter.d.ts +0 -190
- package/dist/data-structures/binary-tree/tree-counter.js +0 -413
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
- package/dist/data-structures/binary-tree/tree-multi-map.js +0 -384
- package/dist/data-structures/graph/abstract-graph.d.ts +0 -340
- package/dist/data-structures/graph/abstract-graph.js +0 -896
- package/dist/data-structures/graph/directed-graph.d.ts +0 -207
- package/dist/data-structures/graph/directed-graph.js +0 -525
- package/dist/data-structures/graph/index.js +0 -20
- package/dist/data-structures/graph/map-graph.d.ts +0 -78
- package/dist/data-structures/graph/map-graph.js +0 -107
- package/dist/data-structures/graph/undirected-graph.d.ts +0 -188
- package/dist/data-structures/graph/undirected-graph.js +0 -424
- package/dist/data-structures/hash/hash-map.d.ts +0 -345
- package/dist/data-structures/hash/hash-map.js +0 -692
- package/dist/data-structures/hash/index.d.ts +0 -1
- package/dist/data-structures/hash/index.js +0 -17
- package/dist/data-structures/heap/heap.d.ts +0 -503
- package/dist/data-structures/heap/heap.js +0 -901
- package/dist/data-structures/heap/index.d.ts +0 -3
- package/dist/data-structures/heap/index.js +0 -19
- package/dist/data-structures/heap/max-heap.d.ts +0 -32
- package/dist/data-structures/heap/max-heap.js +0 -40
- package/dist/data-structures/heap/min-heap.d.ts +0 -33
- package/dist/data-structures/heap/min-heap.js +0 -31
- package/dist/data-structures/index.js +0 -28
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
- package/dist/data-structures/linked-list/doubly-linked-list.js +0 -1111
- package/dist/data-structures/linked-list/index.js +0 -19
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -451
- package/dist/data-structures/linked-list/singly-linked-list.js +0 -850
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -27
- package/dist/data-structures/linked-list/skip-linked-list.js +0 -144
- package/dist/data-structures/matrix/index.js +0 -18
- package/dist/data-structures/matrix/matrix.d.ts +0 -168
- package/dist/data-structures/matrix/matrix.js +0 -448
- package/dist/data-structures/matrix/navigator.d.ts +0 -55
- package/dist/data-structures/matrix/navigator.js +0 -111
- package/dist/data-structures/priority-queue/index.js +0 -19
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
- package/dist/data-structures/priority-queue/max-priority-queue.js +0 -34
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
- package/dist/data-structures/priority-queue/min-priority-queue.js +0 -24
- package/dist/data-structures/priority-queue/priority-queue.d.ts +0 -15
- package/dist/data-structures/priority-queue/priority-queue.js +0 -20
- package/dist/data-structures/queue/deque.d.ts +0 -431
- package/dist/data-structures/queue/deque.js +0 -879
- package/dist/data-structures/queue/index.js +0 -18
- package/dist/data-structures/queue/queue.d.ts +0 -308
- package/dist/data-structures/queue/queue.js +0 -473
- package/dist/data-structures/stack/index.js +0 -17
- package/dist/data-structures/stack/stack.d.ts +0 -306
- package/dist/data-structures/stack/stack.js +0 -401
- package/dist/data-structures/tree/index.js +0 -17
- package/dist/data-structures/tree/tree.d.ts +0 -62
- package/dist/data-structures/tree/tree.js +0 -107
- package/dist/data-structures/trie/index.js +0 -17
- package/dist/data-structures/trie/trie.d.ts +0 -350
- package/dist/data-structures/trie/trie.js +0 -610
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -30
- package/dist/interfaces/binary-tree.js +0 -2
- package/dist/interfaces/doubly-linked-list.js +0 -2
- package/dist/interfaces/graph.js +0 -2
- package/dist/interfaces/heap.js +0 -2
- package/dist/interfaces/index.js +0 -24
- package/dist/interfaces/navigator.js +0 -2
- package/dist/interfaces/priority-queue.js +0 -2
- package/dist/interfaces/segment-tree.js +0 -2
- package/dist/interfaces/singly-linked-list.js +0 -2
- package/dist/types/common.js +0 -2
- package/dist/types/data-structures/base/base.js +0 -2
- package/dist/types/data-structures/base/index.js +0 -17
- package/dist/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
- package/dist/types/data-structures/binary-tree/avl-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/binary-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/bst.js +0 -2
- package/dist/types/data-structures/binary-tree/index.js +0 -25
- package/dist/types/data-structures/binary-tree/red-black-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/segment-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/tree-counter.js +0 -2
- package/dist/types/data-structures/binary-tree/tree-multi-map.js +0 -2
- package/dist/types/data-structures/graph/abstract-graph.js +0 -2
- package/dist/types/data-structures/graph/directed-graph.js +0 -2
- package/dist/types/data-structures/graph/index.js +0 -19
- package/dist/types/data-structures/graph/map-graph.js +0 -2
- package/dist/types/data-structures/graph/undirected-graph.js +0 -2
- package/dist/types/data-structures/hash/hash-map.js +0 -2
- package/dist/types/data-structures/hash/index.js +0 -17
- package/dist/types/data-structures/heap/heap.js +0 -2
- package/dist/types/data-structures/heap/index.js +0 -17
- package/dist/types/data-structures/heap/max-heap.js +0 -2
- package/dist/types/data-structures/heap/min-heap.js +0 -2
- package/dist/types/data-structures/index.js +0 -28
- package/dist/types/data-structures/linked-list/doubly-linked-list.js +0 -2
- package/dist/types/data-structures/linked-list/index.js +0 -19
- package/dist/types/data-structures/linked-list/singly-linked-list.js +0 -2
- package/dist/types/data-structures/linked-list/skip-linked-list.js +0 -2
- package/dist/types/data-structures/matrix/index.js +0 -18
- package/dist/types/data-structures/matrix/matrix.js +0 -2
- package/dist/types/data-structures/matrix/navigator.js +0 -2
- package/dist/types/data-structures/priority-queue/index.js +0 -19
- package/dist/types/data-structures/priority-queue/max-priority-queue.js +0 -2
- package/dist/types/data-structures/priority-queue/min-priority-queue.js +0 -2
- package/dist/types/data-structures/priority-queue/priority-queue.js +0 -2
- package/dist/types/data-structures/queue/deque.js +0 -2
- package/dist/types/data-structures/queue/index.js +0 -18
- package/dist/types/data-structures/queue/queue.js +0 -2
- package/dist/types/data-structures/stack/index.js +0 -17
- package/dist/types/data-structures/stack/stack.js +0 -2
- package/dist/types/data-structures/tree/index.js +0 -17
- package/dist/types/data-structures/tree/tree.js +0 -2
- package/dist/types/data-structures/trie/index.js +0 -17
- package/dist/types/data-structures/trie/trie.js +0 -2
- package/dist/types/index.js +0 -19
- package/dist/types/utils/index.js +0 -18
- package/dist/types/utils/utils.js +0 -2
- package/dist/types/utils/validate-type.js +0 -2
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -18
- package/dist/utils/number.js +0 -24
- package/dist/utils/utils.d.ts +0 -209
- package/dist/utils/utils.js +0 -353
- package/dist/{common → types/common}/index.d.ts +0 -0
- package/dist/{constants → types/constants}/index.d.ts +0 -0
- package/dist/{data-structures → types/data-structures}/base/iterable-element-base.d.ts +0 -0
- package/dist/{data-structures → types/data-structures}/base/iterable-entry-base.d.ts +0 -0
- package/dist/{data-structures → types/data-structures}/base/linear-base.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/doubly-linked-list.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/graph.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/heap.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/index.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/navigator.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/priority-queue.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/segment-tree.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/singly-linked-list.d.ts +0 -0
- package/dist/types/{common.d.ts → types/common.d.ts} +0 -0
- package/dist/types/{data-structures → types/data-structures}/base/base.d.ts +0 -0
- package/dist/{data-structures → types/types/data-structures}/index.d.ts +7 -7
- package/dist/{data-structures → types/types/data-structures}/linked-list/index.d.ts +0 -0
- package/dist/{data-structures → types/types/data-structures}/matrix/index.d.ts +1 -1
- /package/dist/{data-structures → types/types/data-structures}/priority-queue/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/queue/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/stack/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/tree/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/trie/index.d.ts +0 -0
- /package/dist/types/{utils → types/utils}/validate-type.d.ts +0 -0
- /package/dist/{utils → types/utils}/number.d.ts +0 -0
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* data-structure-typed
|
|
4
|
-
*
|
|
5
|
-
* @author Pablo Zeng
|
|
6
|
-
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
7
|
-
* @license MIT License
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.AVLTreeCounter = exports.AVLTreeCounterNode = void 0;
|
|
11
|
-
const avl_tree_1 = require("./avl-tree");
|
|
12
|
-
/**
|
|
13
|
-
* AVL node with an extra 'count' field; keeps parent/child links.
|
|
14
|
-
* @remarks Time O(1), Space O(1)
|
|
15
|
-
* @template K
|
|
16
|
-
* @template V
|
|
17
|
-
*/
|
|
18
|
-
class AVLTreeCounterNode extends avl_tree_1.AVLTreeNode {
|
|
19
|
-
/**
|
|
20
|
-
* Create an AVL counter node.
|
|
21
|
-
* @remarks Time O(1), Space O(1)
|
|
22
|
-
* @param key - Key of the node.
|
|
23
|
-
* @param [value] - Associated value (ignored in map mode).
|
|
24
|
-
* @param [count] - Initial count for this node (default 1).
|
|
25
|
-
* @returns New AVLTreeCounterNode instance.
|
|
26
|
-
*/
|
|
27
|
-
constructor(key, value, count = 1) {
|
|
28
|
-
super(key, value);
|
|
29
|
-
this.parent = undefined;
|
|
30
|
-
this._left = undefined;
|
|
31
|
-
this._right = undefined;
|
|
32
|
-
this.count = count;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get the left child pointer.
|
|
36
|
-
* @remarks Time O(1), Space O(1)
|
|
37
|
-
* @returns Left child node, or null/undefined.
|
|
38
|
-
*/
|
|
39
|
-
get left() {
|
|
40
|
-
return this._left;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Set the left child and update its parent pointer.
|
|
44
|
-
* @remarks Time O(1), Space O(1)
|
|
45
|
-
* @param v - New left child node, or null/undefined.
|
|
46
|
-
* @returns void
|
|
47
|
-
*/
|
|
48
|
-
set left(v) {
|
|
49
|
-
if (v) {
|
|
50
|
-
v.parent = this;
|
|
51
|
-
}
|
|
52
|
-
this._left = v;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get the right child pointer.
|
|
56
|
-
* @remarks Time O(1), Space O(1)
|
|
57
|
-
* @returns Right child node, or null/undefined.
|
|
58
|
-
*/
|
|
59
|
-
get right() {
|
|
60
|
-
return this._right;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Set the right child and update its parent pointer.
|
|
64
|
-
* @remarks Time O(1), Space O(1)
|
|
65
|
-
* @param v - New right child node, or null/undefined.
|
|
66
|
-
* @returns void
|
|
67
|
-
*/
|
|
68
|
-
set right(v) {
|
|
69
|
-
if (v) {
|
|
70
|
-
v.parent = this;
|
|
71
|
-
}
|
|
72
|
-
this._right = v;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.AVLTreeCounterNode = AVLTreeCounterNode;
|
|
76
|
-
/**
|
|
77
|
-
* AVL tree that tracks an aggregate 'count' across nodes; supports balanced insert/delete and map-like mode.
|
|
78
|
-
* @remarks Time O(1), Space O(1)
|
|
79
|
-
* @template K
|
|
80
|
-
* @template V
|
|
81
|
-
* @template R
|
|
82
|
-
*/
|
|
83
|
-
class AVLTreeCounter extends avl_tree_1.AVLTree {
|
|
84
|
-
/**
|
|
85
|
-
* Create a AVLTreeCounter instance
|
|
86
|
-
* @remarks Time O(n), Space O(n)
|
|
87
|
-
* @param keysNodesEntriesOrRaws
|
|
88
|
-
* @param options
|
|
89
|
-
* @returns New AVLTreeCounterNode instance.
|
|
90
|
-
*/
|
|
91
|
-
constructor(keysNodesEntriesOrRaws = [], options) {
|
|
92
|
-
super([], options);
|
|
93
|
-
this._count = 0;
|
|
94
|
-
if (keysNodesEntriesOrRaws)
|
|
95
|
-
this.addMany(keysNodesEntriesOrRaws);
|
|
96
|
-
}
|
|
97
|
-
get count() {
|
|
98
|
-
return this._count;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Compute the total count by traversing the tree (sums node.count).
|
|
102
|
-
* @remarks Time O(N), Space O(H)
|
|
103
|
-
* @returns Total count recomputed from nodes.
|
|
104
|
-
*/
|
|
105
|
-
getComputedCount() {
|
|
106
|
-
let sum = 0;
|
|
107
|
-
this.dfs(node => (sum += node.count));
|
|
108
|
-
return sum;
|
|
109
|
-
}
|
|
110
|
-
_createNode(key, value, count) {
|
|
111
|
-
return new AVLTreeCounterNode(key, this._isMapMode ? undefined : value, count);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Type guard: check whether the input is an AVLTreeCounterNode.
|
|
115
|
-
* @remarks Time O(1), Space O(1)
|
|
116
|
-
* @returns True if the value is an AVLTreeCounterNode.
|
|
117
|
-
*/
|
|
118
|
-
isNode(keyNodeOrEntry) {
|
|
119
|
-
return keyNodeOrEntry instanceof AVLTreeCounterNode;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Insert or increment a node and update aggregate count.
|
|
123
|
-
* @remarks Time O(log N), Space O(1)
|
|
124
|
-
* @param keyNodeOrEntry - Key, node, or [key, value] entry to insert.
|
|
125
|
-
* @param [value] - Value when a bare key is provided (ignored in map mode).
|
|
126
|
-
* @param [count] - How much to increase the node's count (default 1).
|
|
127
|
-
* @returns True if inserted/updated; false if ignored.
|
|
128
|
-
*/
|
|
129
|
-
add(keyNodeOrEntry, value, count = 1) {
|
|
130
|
-
const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
|
|
131
|
-
if (newNode === undefined)
|
|
132
|
-
return false;
|
|
133
|
-
const orgNodeCount = (newNode === null || newNode === void 0 ? void 0 : newNode.count) || 0;
|
|
134
|
-
const inserted = super.add(newNode, newValue);
|
|
135
|
-
if (inserted) {
|
|
136
|
-
this._count += orgNodeCount;
|
|
137
|
-
}
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Delete a node (or decrement its count) and rebalance if needed.
|
|
142
|
-
* @remarks Time O(log N), Space O(1)
|
|
143
|
-
* @param keyNodeOrEntry - Key, node, or [key, value] entry identifying the node.
|
|
144
|
-
* @param [ignoreCount] - If true, remove the node regardless of its count.
|
|
145
|
-
* @returns Array of deletion results including deleted node and a rebalance hint when present.
|
|
146
|
-
*/
|
|
147
|
-
delete(keyNodeOrEntry, ignoreCount = false) {
|
|
148
|
-
var _a;
|
|
149
|
-
const deletedResult = [];
|
|
150
|
-
if (!this.root)
|
|
151
|
-
return deletedResult;
|
|
152
|
-
const curr = (_a = this.getNode(keyNodeOrEntry)) !== null && _a !== void 0 ? _a : undefined;
|
|
153
|
-
if (!curr)
|
|
154
|
-
return deletedResult;
|
|
155
|
-
const parent = (curr === null || curr === void 0 ? void 0 : curr.parent) ? curr.parent : undefined;
|
|
156
|
-
let needBalanced = undefined, orgCurrent = curr;
|
|
157
|
-
if (curr.count > 1 && !ignoreCount) {
|
|
158
|
-
curr.count--;
|
|
159
|
-
this._count--;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
if (!curr.left) {
|
|
163
|
-
if (!parent) {
|
|
164
|
-
if (curr.right !== undefined && curr.right !== null)
|
|
165
|
-
this._setRoot(curr.right);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
const { familyPosition: fp } = curr;
|
|
169
|
-
if (fp === 'LEFT' || fp === 'ROOT_LEFT') {
|
|
170
|
-
parent.left = curr.right;
|
|
171
|
-
}
|
|
172
|
-
else if (fp === 'RIGHT' || fp === 'ROOT_RIGHT') {
|
|
173
|
-
parent.right = curr.right;
|
|
174
|
-
}
|
|
175
|
-
needBalanced = parent;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
const leftSubTreeRightMost = curr.left ? this.getRightMost(node => node, curr.left) : undefined;
|
|
180
|
-
if (leftSubTreeRightMost) {
|
|
181
|
-
const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
|
|
182
|
-
orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
|
|
183
|
-
if (parentOfLeftSubTreeMax) {
|
|
184
|
-
if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost) {
|
|
185
|
-
parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
|
|
189
|
-
}
|
|
190
|
-
needBalanced = parentOfLeftSubTreeMax;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
this._size = this._size - 1;
|
|
195
|
-
if (orgCurrent)
|
|
196
|
-
this._count -= orgCurrent.count;
|
|
197
|
-
}
|
|
198
|
-
deletedResult.push({ deleted: orgCurrent, needBalanced });
|
|
199
|
-
if (needBalanced) {
|
|
200
|
-
this._balancePath(needBalanced);
|
|
201
|
-
}
|
|
202
|
-
return deletedResult;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Remove all nodes and reset aggregate counters.
|
|
206
|
-
* @remarks Time O(N), Space O(1)
|
|
207
|
-
* @returns void
|
|
208
|
-
*/
|
|
209
|
-
clear() {
|
|
210
|
-
super.clear();
|
|
211
|
-
this._count = 0;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Rebuild the tree into a perfectly balanced form using in-order nodes.
|
|
215
|
-
* @remarks Time O(N), Space O(N)
|
|
216
|
-
* @param [iterationType] - Traversal style to use when constructing the balanced tree.
|
|
217
|
-
* @returns True if rebalancing succeeded (tree not empty).
|
|
218
|
-
*/
|
|
219
|
-
perfectlyBalance(iterationType = this.iterationType) {
|
|
220
|
-
const nodes = this.dfs(node => node, 'IN', false, this._root, iterationType);
|
|
221
|
-
const n = nodes.length;
|
|
222
|
-
if (n === 0)
|
|
223
|
-
return false;
|
|
224
|
-
let total = 0;
|
|
225
|
-
for (const nd of nodes)
|
|
226
|
-
total += nd ? nd.count : 0;
|
|
227
|
-
this._clearNodes();
|
|
228
|
-
const build = (l, r, parent) => {
|
|
229
|
-
if (l > r)
|
|
230
|
-
return undefined;
|
|
231
|
-
const m = l + ((r - l) >> 1);
|
|
232
|
-
const root = nodes[m];
|
|
233
|
-
root.left = build(l, m - 1, root);
|
|
234
|
-
root.right = build(m + 1, r, root);
|
|
235
|
-
root.parent = parent;
|
|
236
|
-
const lh = root.left ? root.left.height : -1;
|
|
237
|
-
const rh = root.right ? root.right.height : -1;
|
|
238
|
-
root.height = Math.max(lh, rh) + 1;
|
|
239
|
-
return root;
|
|
240
|
-
};
|
|
241
|
-
const newRoot = build(0, n - 1, undefined);
|
|
242
|
-
this._setRoot(newRoot);
|
|
243
|
-
this._size = n;
|
|
244
|
-
this._count = total;
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Deep copy this tree, preserving map mode and aggregate counts.
|
|
249
|
-
* @remarks Time O(N), Space O(N)
|
|
250
|
-
* @returns A deep copy of this tree.
|
|
251
|
-
*/
|
|
252
|
-
clone() {
|
|
253
|
-
const out = this._createInstance();
|
|
254
|
-
if (this._isMapMode) {
|
|
255
|
-
this.bfs(node => out.add(node.key, undefined, node.count));
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
this.bfs(node => out.add(node.key, node.value, node.count));
|
|
259
|
-
}
|
|
260
|
-
if (this._isMapMode)
|
|
261
|
-
out._store = this._store;
|
|
262
|
-
return out;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Create a new AVLTreeCounter by mapping each [key, value] entry.
|
|
266
|
-
* @remarks Time O(N log N), Space O(N)
|
|
267
|
-
* @template MK
|
|
268
|
-
* @template MV
|
|
269
|
-
* @template MR
|
|
270
|
-
* @param callback - Function mapping (key, value, index, tree) → [newKey, newValue].
|
|
271
|
-
* @param [options] - Options for the output tree.
|
|
272
|
-
* @param [thisArg] - Value for `this` inside the callback.
|
|
273
|
-
* @returns A new AVLTreeCounter with mapped entries.
|
|
274
|
-
*/
|
|
275
|
-
map(callback, options, thisArg) {
|
|
276
|
-
const out = this._createLike([], options);
|
|
277
|
-
let index = 0;
|
|
278
|
-
for (const [key, value] of this) {
|
|
279
|
-
out.add(callback.call(thisArg, key, value, index++, this));
|
|
280
|
-
}
|
|
281
|
-
return out;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* (Protected) Create an empty instance of the same concrete class.
|
|
285
|
-
* @remarks Time O(1), Space O(1)
|
|
286
|
-
* @template TK
|
|
287
|
-
* @template TV
|
|
288
|
-
* @template TR
|
|
289
|
-
* @param [options] - Optional constructor options for the like-kind instance.
|
|
290
|
-
* @returns An empty like-kind instance.
|
|
291
|
-
*/
|
|
292
|
-
_createInstance(options) {
|
|
293
|
-
const Ctor = this.constructor;
|
|
294
|
-
return new Ctor([], Object.assign(Object.assign({}, this._snapshotOptions()), (options !== null && options !== void 0 ? options : {})));
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* (Protected) Create a like-kind instance and seed it from an iterable.
|
|
298
|
-
* @remarks Time O(N log N), Space O(N)
|
|
299
|
-
* @template TK
|
|
300
|
-
* @template TV
|
|
301
|
-
* @template TR
|
|
302
|
-
* @param iter - Iterable used to seed the new tree.
|
|
303
|
-
* @param [options] - Options merged with the current snapshot.
|
|
304
|
-
* @returns A like-kind AVLTreeCounter built from the iterable.
|
|
305
|
-
*/
|
|
306
|
-
_createLike(iter = [], options) {
|
|
307
|
-
const Ctor = this.constructor;
|
|
308
|
-
return new Ctor(iter, Object.assign(Object.assign({}, this._snapshotOptions()), (options !== null && options !== void 0 ? options : {})));
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* (Protected) Normalize input into a node plus its effective value and count.
|
|
312
|
-
* @remarks Time O(1), Space O(1)
|
|
313
|
-
* @param keyNodeOrEntry - Key, node, or [key, value] entry.
|
|
314
|
-
* @param [value] - Value used when a bare key is provided.
|
|
315
|
-
* @param [count] - Count increment to apply (default 1).
|
|
316
|
-
* @returns Tuple [node, value] where node may be undefined.
|
|
317
|
-
*/
|
|
318
|
-
_keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count = 1) {
|
|
319
|
-
if (keyNodeOrEntry === undefined || keyNodeOrEntry === null)
|
|
320
|
-
return [undefined, undefined];
|
|
321
|
-
if (this.isNode(keyNodeOrEntry))
|
|
322
|
-
return [keyNodeOrEntry, value];
|
|
323
|
-
if (this.isEntry(keyNodeOrEntry)) {
|
|
324
|
-
const [key, entryValue] = keyNodeOrEntry;
|
|
325
|
-
if (key === undefined || key === null)
|
|
326
|
-
return [undefined, undefined];
|
|
327
|
-
const finalValue = value !== null && value !== void 0 ? value : entryValue;
|
|
328
|
-
return [this._createNode(key, finalValue, count), finalValue];
|
|
329
|
-
}
|
|
330
|
-
return [this._createNode(keyNodeOrEntry, value, count), value];
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* (Protected) Swap keys/values/counters between the source and destination nodes.
|
|
334
|
-
* @remarks Time O(1), Space O(1)
|
|
335
|
-
* @param srcNode - Source node (or key) whose properties will be moved.
|
|
336
|
-
* @param destNode - Destination node (or key) to receive properties.
|
|
337
|
-
* @returns Destination node after swap, or undefined.
|
|
338
|
-
*/
|
|
339
|
-
_swapProperties(srcNode, destNode) {
|
|
340
|
-
srcNode = this.ensureNode(srcNode);
|
|
341
|
-
destNode = this.ensureNode(destNode);
|
|
342
|
-
if (srcNode && destNode) {
|
|
343
|
-
const { key, value, count, height } = destNode;
|
|
344
|
-
const tempNode = this._createNode(key, value, count);
|
|
345
|
-
if (tempNode) {
|
|
346
|
-
tempNode.height = height;
|
|
347
|
-
destNode.key = srcNode.key;
|
|
348
|
-
if (!this._isMapMode)
|
|
349
|
-
destNode.value = srcNode.value;
|
|
350
|
-
destNode.count = srcNode.count;
|
|
351
|
-
destNode.height = srcNode.height;
|
|
352
|
-
srcNode.key = tempNode.key;
|
|
353
|
-
if (!this._isMapMode)
|
|
354
|
-
srcNode.value = tempNode.value;
|
|
355
|
-
srcNode.count = tempNode.count;
|
|
356
|
-
srcNode.height = tempNode.height;
|
|
357
|
-
}
|
|
358
|
-
return destNode;
|
|
359
|
-
}
|
|
360
|
-
return undefined;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* (Protected) Replace one node by another and adjust counters accordingly.
|
|
364
|
-
* @remarks Time O(1), Space O(1)
|
|
365
|
-
* @param oldNode - Node being replaced.
|
|
366
|
-
* @param newNode - Replacement node.
|
|
367
|
-
* @returns The new node after replacement.
|
|
368
|
-
*/
|
|
369
|
-
_replaceNode(oldNode, newNode) {
|
|
370
|
-
newNode.count = oldNode.count + newNode.count;
|
|
371
|
-
return super._replaceNode(oldNode, newNode);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
exports.AVLTreeCounter = AVLTreeCounter;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* data-structure-typed
|
|
3
|
-
*
|
|
4
|
-
* @author Pablo Zeng
|
|
5
|
-
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
|
-
* @license MIT License
|
|
7
|
-
*/
|
|
8
|
-
import type { AVLTreeMultiMapOptions, AVLTreeOptions, ElemOf, EntryCallback, IterationType } from '../../types';
|
|
9
|
-
import { AVLTree, AVLTreeNode } from './avl-tree';
|
|
10
|
-
import { IBinaryTree } from '../../interfaces';
|
|
11
|
-
/**
|
|
12
|
-
* Node used by AVLTreeMultiMap; stores the key with a bucket of values (array).
|
|
13
|
-
* @remarks Time O(1), Space O(1)
|
|
14
|
-
* @template K
|
|
15
|
-
* @template V
|
|
16
|
-
*/
|
|
17
|
-
export declare class AVLTreeMultiMapNode<K = any, V = any> extends AVLTreeNode<K, V[]> {
|
|
18
|
-
parent?: AVLTreeMultiMapNode<K, V>;
|
|
19
|
-
/**
|
|
20
|
-
* Create an AVLTreeMultiMap node with a value bucket.
|
|
21
|
-
* @remarks Time O(1), Space O(1)
|
|
22
|
-
* @param key - Key of the node.
|
|
23
|
-
* @param value - Initial array of values.
|
|
24
|
-
* @returns New AVLTreeMultiMapNode instance.
|
|
25
|
-
*/
|
|
26
|
-
constructor(key: K, value: V[]);
|
|
27
|
-
_left?: AVLTreeMultiMapNode<K, V> | null | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Get the left child pointer.
|
|
30
|
-
* @remarks Time O(1), Space O(1)
|
|
31
|
-
* @returns Left child node, or null/undefined.
|
|
32
|
-
*/
|
|
33
|
-
get left(): AVLTreeMultiMapNode<K, V> | null | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Set the left child and update its parent pointer.
|
|
36
|
-
* @remarks Time O(1), Space O(1)
|
|
37
|
-
* @param v - New left child node, or null/undefined.
|
|
38
|
-
* @returns void
|
|
39
|
-
*/
|
|
40
|
-
set left(v: AVLTreeMultiMapNode<K, V> | null | undefined);
|
|
41
|
-
_right?: AVLTreeMultiMapNode<K, V> | null | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Get the right child pointer.
|
|
44
|
-
* @remarks Time O(1), Space O(1)
|
|
45
|
-
* @returns Right child node, or null/undefined.
|
|
46
|
-
*/
|
|
47
|
-
get right(): AVLTreeMultiMapNode<K, V> | null | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Set the right child and update its parent pointer.
|
|
50
|
-
* @remarks Time O(1), Space O(1)
|
|
51
|
-
* @param v - New right child node, or null/undefined.
|
|
52
|
-
* @returns void
|
|
53
|
-
*/
|
|
54
|
-
set right(v: AVLTreeMultiMapNode<K, V> | null | undefined);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* AVL-tree–based multimap (key → array of values). Preserves O(log N) updates and supports map-like mode.
|
|
58
|
-
* @remarks Time O(1), Space O(1)
|
|
59
|
-
* @template K
|
|
60
|
-
* @template V
|
|
61
|
-
* @template R
|
|
62
|
-
*/
|
|
63
|
-
export declare class AVLTreeMultiMap<K = any, V = any, R extends object = object> extends AVLTree<K, V[], R> implements IBinaryTree<K, V[], R> {
|
|
64
|
-
/**
|
|
65
|
-
* Create an AVLTreeMultiMap and optionally bulk-insert items.
|
|
66
|
-
* @remarks Time O(N log N), Space O(N)
|
|
67
|
-
* @param [keysNodesEntriesOrRaws] - Iterable of keys/nodes/entries/raw items to insert.
|
|
68
|
-
* @param [options] - Options for AVLTreeMultiMap (comparator, reverse, map mode).
|
|
69
|
-
* @returns New AVLTreeMultiMap instance.
|
|
70
|
-
*/
|
|
71
|
-
constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined | R>, options?: AVLTreeMultiMapOptions<K, V[], R>);
|
|
72
|
-
_createNode(key: K, value?: V[]): AVLTreeMultiMapNode<K, V>;
|
|
73
|
-
add(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
|
|
74
|
-
add(key: K, value: V): boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
|
|
77
|
-
* @remarks Time O(log N), Space O(1)
|
|
78
|
-
* @param keyNodeOrEntry - Key, node, or [key, values] entry to locate the bucket.
|
|
79
|
-
* @param value - Value to remove from the bucket.
|
|
80
|
-
* @returns True if the value was removed; false if not found.
|
|
81
|
-
*/
|
|
82
|
-
deleteValue(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined, value: V): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Rebuild the tree into a perfectly balanced form using in-order nodes.
|
|
85
|
-
* @remarks Time O(N), Space O(N)
|
|
86
|
-
* @param [iterationType] - Traversal style to use when constructing the balanced tree.
|
|
87
|
-
* @returns True if rebalancing succeeded (tree not empty).
|
|
88
|
-
*/
|
|
89
|
-
perfectlyBalance(iterationType?: IterationType): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Create a new tree by mapping each [key, values] bucket.
|
|
92
|
-
* @remarks Time O(N log N), Space O(N)
|
|
93
|
-
* @template MK
|
|
94
|
-
* @template MVArr
|
|
95
|
-
* @template MR
|
|
96
|
-
* @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
|
|
97
|
-
* @param [options] - Options for the output tree.
|
|
98
|
-
* @param [thisArg] - Value for `this` inside the callback.
|
|
99
|
-
* @returns A new AVLTreeMultiMap when mapping to array values; see overloads.
|
|
100
|
-
*/
|
|
101
|
-
map<MK = K, MVArr extends unknown[] = V[], MR extends object = object>(callback: EntryCallback<K, V[] | undefined, [MK, MVArr]>, options?: Partial<AVLTreeOptions<MK, MVArr, MR>>, thisArg?: unknown): AVLTreeMultiMap<MK, ElemOf<MVArr>, MR>;
|
|
102
|
-
/**
|
|
103
|
-
* Create a new tree by mapping each [key, values] bucket.
|
|
104
|
-
* @remarks Time O(N log N), Space O(N)
|
|
105
|
-
* @template MK
|
|
106
|
-
* @template MV
|
|
107
|
-
* @template MR
|
|
108
|
-
* @param callback - Function mapping (key, values, index, tree) → [newKey, newValue].
|
|
109
|
-
* @param [options] - Options for the output tree.
|
|
110
|
-
* @param [thisArg] - Value for `this` inside the callback.
|
|
111
|
-
* @returns A new AVLTree when mapping to non-array values; see overloads.
|
|
112
|
-
*/
|
|
113
|
-
map<MK = K, MV = V[], MR extends object = object>(callback: EntryCallback<K, V[] | undefined, [MK, MV]>, options?: Partial<AVLTreeOptions<MK, MV, MR>>, thisArg?: unknown): AVLTree<MK, MV, MR>;
|
|
114
|
-
/**
|
|
115
|
-
* (Protected) Create an empty instance of the same concrete class.
|
|
116
|
-
* @remarks Time O(1), Space O(1)
|
|
117
|
-
* @template TK
|
|
118
|
-
* @template TV
|
|
119
|
-
* @template TR
|
|
120
|
-
* @param [options] - Optional constructor options for the like-kind instance.
|
|
121
|
-
* @returns An empty like-kind instance.
|
|
122
|
-
*/
|
|
123
|
-
protected _createInstance<TK = K, TV = V, TR extends object = R>(options?: Partial<AVLTreeOptions<TK, TV, TR>>): this;
|
|
124
|
-
/**
|
|
125
|
-
* (Protected) Create a like-kind instance and seed it from an iterable.
|
|
126
|
-
* @remarks Time O(N log N), Space O(N)
|
|
127
|
-
* @template TK
|
|
128
|
-
* @template TV
|
|
129
|
-
* @template TR
|
|
130
|
-
* @param iter - Iterable used to seed the new tree.
|
|
131
|
-
* @param [options] - Options merged with the current snapshot.
|
|
132
|
-
* @returns A like-kind AVLTree built from the iterable.
|
|
133
|
-
*/
|
|
134
|
-
protected _createLike<TK = K, TV = V, TR extends object = R>(iter?: Iterable<TK | AVLTreeNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>, options?: Partial<AVLTreeOptions<TK, TV, TR>>): AVLTree<TK, TV, TR>;
|
|
135
|
-
}
|