data-structure-typed 2.5.2 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/MIGRATION.md +169 -0
- package/README.md +60 -6
- package/README_CN.md +551 -143
- package/SPECIFICATION.md +20 -14
- package/SPECIFICATION.zh-CN.md +20 -14
- package/dist/cjs/binary-tree.cjs +2417 -132
- package/dist/cjs/graph.cjs +248 -14
- package/dist/cjs/hash.cjs +62 -7
- package/dist/cjs/heap.cjs +103 -16
- package/dist/cjs/index.cjs +3046 -124
- package/dist/cjs/linked-list.cjs +219 -0
- package/dist/cjs/matrix.cjs +32 -0
- package/dist/cjs/priority-queue.cjs +101 -14
- package/dist/cjs/queue.cjs +215 -0
- package/dist/cjs/stack.cjs +44 -4
- package/dist/cjs/trie.cjs +44 -0
- package/dist/cjs-legacy/binary-tree.cjs +2406 -123
- package/dist/cjs-legacy/graph.cjs +248 -14
- package/dist/cjs-legacy/hash.cjs +62 -7
- package/dist/cjs-legacy/heap.cjs +103 -16
- package/dist/cjs-legacy/index.cjs +3105 -185
- package/dist/cjs-legacy/linked-list.cjs +219 -0
- package/dist/cjs-legacy/matrix.cjs +32 -0
- package/dist/cjs-legacy/priority-queue.cjs +101 -14
- package/dist/cjs-legacy/queue.cjs +215 -0
- package/dist/cjs-legacy/stack.cjs +44 -4
- package/dist/cjs-legacy/trie.cjs +44 -0
- package/dist/esm/binary-tree.mjs +2417 -132
- package/dist/esm/graph.mjs +248 -14
- package/dist/esm/hash.mjs +62 -7
- package/dist/esm/heap.mjs +103 -16
- package/dist/esm/index.mjs +3046 -124
- package/dist/esm/linked-list.mjs +219 -0
- package/dist/esm/matrix.mjs +32 -0
- package/dist/esm/priority-queue.mjs +101 -14
- package/dist/esm/queue.mjs +215 -0
- package/dist/esm/stack.mjs +44 -4
- package/dist/esm/trie.mjs +44 -0
- package/dist/esm-legacy/binary-tree.mjs +2406 -123
- package/dist/esm-legacy/graph.mjs +248 -14
- package/dist/esm-legacy/hash.mjs +62 -7
- package/dist/esm-legacy/heap.mjs +103 -16
- package/dist/esm-legacy/index.mjs +3105 -185
- package/dist/esm-legacy/linked-list.mjs +219 -0
- package/dist/esm-legacy/matrix.mjs +32 -0
- package/dist/esm-legacy/priority-queue.mjs +101 -14
- package/dist/esm-legacy/queue.mjs +215 -0
- package/dist/esm-legacy/stack.mjs +44 -4
- package/dist/esm-legacy/trie.mjs +44 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
- package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
- package/dist/types/data-structures/heap/heap.d.ts +98 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
- package/dist/types/data-structures/queue/deque.d.ts +82 -0
- package/dist/types/data-structures/queue/queue.d.ts +61 -0
- package/dist/types/data-structures/stack/stack.d.ts +42 -2
- package/dist/types/data-structures/trie/trie.d.ts +48 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/umd/data-structure-typed.js +3105 -185
- package/dist/umd/data-structure-typed.min.js +4 -4
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +188 -200
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +62 -62
- package/docs-site-docusaurus/docs/api/classes/BST.md +183 -195
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +143 -155
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +99 -85
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +73 -73
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +100 -70
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +38 -38
- package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
- package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +48 -48
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +52 -52
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +42 -42
- package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +74 -74
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +73 -73
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
- package/docs-site-docusaurus/docs/api/classes/Queue.md +111 -59
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +200 -212
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +75 -75
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +37 -37
- package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +107 -36
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +43 -43
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +106 -35
- package/docs-site-docusaurus/docs/api/classes/Trie.md +43 -43
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +72 -72
- package/docs-site-docusaurus/docs/guide/architecture.md +75 -7
- package/docs-site-docusaurus/docs/guide/concepts.md +53 -34
- package/docs-site-docusaurus/docs/guide/faq.md +53 -0
- package/docs-site-docusaurus/docs/guide/guides.md +8 -9
- package/docs-site-docusaurus/docs/guide/integrations.md +74 -177
- package/docs-site-docusaurus/docs/guide/overview.md +131 -17
- package/docs-site-docusaurus/src/pages/index.tsx +4 -0
- package/docs-site-docusaurus/typedoc.json +1 -0
- package/package.json +7 -6
- package/src/data-structures/binary-tree/avl-tree.ts +52 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
- package/src/data-structures/binary-tree/binary-tree.ts +167 -81
- package/src/data-structures/binary-tree/bst.ts +101 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
- package/src/data-structures/binary-tree/segment-tree.ts +24 -0
- package/src/data-structures/binary-tree/tree-map.ts +540 -3
- package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
- package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
- package/src/data-structures/binary-tree/tree-set.ts +520 -3
- package/src/data-structures/graph/directed-graph.ts +41 -1
- package/src/data-structures/graph/undirected-graph.ts +37 -1
- package/src/data-structures/hash/hash-map.ts +67 -12
- package/src/data-structures/heap/heap.ts +107 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
- package/src/data-structures/matrix/matrix.ts +32 -0
- package/src/data-structures/queue/deque.ts +85 -0
- package/src/data-structures/queue/queue.ts +73 -0
- package/src/data-structures/stack/stack.ts +45 -5
- package/src/data-structures/trie/trie.ts +48 -0
- package/src/interfaces/binary-tree.ts +1 -9
- package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
- package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
- package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
package/dist/cjs/binary-tree.cjs
CHANGED
|
@@ -797,6 +797,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
797
797
|
|
|
798
798
|
|
|
799
799
|
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
800
804
|
|
|
801
805
|
|
|
802
806
|
|
|
@@ -847,6 +851,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
847
851
|
|
|
848
852
|
|
|
849
853
|
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
850
858
|
|
|
851
859
|
|
|
852
860
|
|
|
@@ -861,6 +869,14 @@ var Queue = class _Queue extends LinearBase {
|
|
|
861
869
|
get first() {
|
|
862
870
|
return this.length > 0 ? this.elements[this._offset] : void 0;
|
|
863
871
|
}
|
|
872
|
+
/**
|
|
873
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
874
|
+
* @remarks Time O(1), Space O(1)
|
|
875
|
+
* @returns Front element or undefined.
|
|
876
|
+
*/
|
|
877
|
+
peek() {
|
|
878
|
+
return this.first;
|
|
879
|
+
}
|
|
864
880
|
/**
|
|
865
881
|
* Get the last element (back) without removing it.
|
|
866
882
|
* @remarks Time O(1), Space O(1)
|
|
@@ -913,6 +929,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
913
929
|
|
|
914
930
|
|
|
915
931
|
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
916
936
|
|
|
917
937
|
|
|
918
938
|
|
|
@@ -975,6 +995,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
975
995
|
|
|
976
996
|
|
|
977
997
|
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
|
|
978
1002
|
|
|
979
1003
|
|
|
980
1004
|
|
|
@@ -1044,6 +1068,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1044
1068
|
|
|
1045
1069
|
|
|
1046
1070
|
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1047
1075
|
|
|
1048
1076
|
|
|
1049
1077
|
|
|
@@ -1103,6 +1131,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1103
1131
|
|
|
1104
1132
|
|
|
1105
1133
|
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1106
1138
|
|
|
1107
1139
|
|
|
1108
1140
|
|
|
@@ -1155,6 +1187,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1155
1187
|
|
|
1156
1188
|
|
|
1157
1189
|
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1158
1194
|
|
|
1159
1195
|
|
|
1160
1196
|
|
|
@@ -1206,6 +1242,21 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1206
1242
|
this._elements[this._offset + index] = newElement;
|
|
1207
1243
|
return true;
|
|
1208
1244
|
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Delete the first element that satisfies a predicate.
|
|
1247
|
+
* @remarks Time O(N), Space O(N)
|
|
1248
|
+
* @param predicate - Function (value, index, queue) → boolean to decide deletion.
|
|
1249
|
+
* @returns True if a match was removed.
|
|
1250
|
+
*/
|
|
1251
|
+
deleteWhere(predicate) {
|
|
1252
|
+
for (let i = 0; i < this.length; i++) {
|
|
1253
|
+
if (predicate(this._elements[this._offset + i], i, this)) {
|
|
1254
|
+
this.deleteAt(i);
|
|
1255
|
+
return true;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
return false;
|
|
1259
|
+
}
|
|
1209
1260
|
/**
|
|
1210
1261
|
* Reverse the queue in-place by compacting then reversing.
|
|
1211
1262
|
* @remarks Time O(N), Space O(N)
|
|
@@ -1248,6 +1299,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1248
1299
|
|
|
1249
1300
|
|
|
1250
1301
|
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
|
|
1251
1306
|
|
|
1252
1307
|
|
|
1253
1308
|
|
|
@@ -1294,6 +1349,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1294
1349
|
|
|
1295
1350
|
|
|
1296
1351
|
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1297
1356
|
|
|
1298
1357
|
|
|
1299
1358
|
|
|
@@ -1363,6 +1422,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1363
1422
|
|
|
1364
1423
|
|
|
1365
1424
|
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1366
1429
|
|
|
1367
1430
|
|
|
1368
1431
|
|
|
@@ -1416,6 +1479,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1416
1479
|
|
|
1417
1480
|
|
|
1418
1481
|
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
|
|
1419
1486
|
|
|
1420
1487
|
|
|
1421
1488
|
|
|
@@ -1473,6 +1540,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1473
1540
|
|
|
1474
1541
|
|
|
1475
1542
|
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
|
|
1476
1547
|
|
|
1477
1548
|
|
|
1478
1549
|
|
|
@@ -1944,7 +2015,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1944
2015
|
}
|
|
1945
2016
|
/**
|
|
1946
2017
|
* Adds a new node to the tree.
|
|
1947
|
-
* @remarks Time O(
|
|
2018
|
+
* @remarks Time O(N) — level-order traversal to find an empty slot. Space O(N) for the BFS queue. BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
|
|
1948
2019
|
*
|
|
1949
2020
|
* @param keyNodeOrEntry - The key, node, or entry to add.
|
|
1950
2021
|
* @returns True if the addition was successful, false otherwise.
|
|
@@ -1973,6 +2044,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1973
2044
|
|
|
1974
2045
|
|
|
1975
2046
|
|
|
2047
|
+
|
|
2048
|
+
|
|
2049
|
+
|
|
2050
|
+
|
|
1976
2051
|
|
|
1977
2052
|
|
|
1978
2053
|
|
|
@@ -1992,7 +2067,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1992
2067
|
}
|
|
1993
2068
|
/**
|
|
1994
2069
|
* Adds or updates a new node to the tree.
|
|
1995
|
-
* @remarks Time O(
|
|
2070
|
+
* @remarks Time O(N) — level-order traversal to find an empty slot. Space O(N) for the BFS queue. BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
|
|
1996
2071
|
*
|
|
1997
2072
|
* @param keyNodeOrEntry - The key, node, or entry to set or update.
|
|
1998
2073
|
* @param [value] - The value, if providing just a key.
|
|
@@ -2027,6 +2102,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2027
2102
|
|
|
2028
2103
|
|
|
2029
2104
|
|
|
2105
|
+
|
|
2106
|
+
|
|
2107
|
+
|
|
2108
|
+
|
|
2030
2109
|
|
|
2031
2110
|
|
|
2032
2111
|
|
|
@@ -2133,6 +2212,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2133
2212
|
|
|
2134
2213
|
|
|
2135
2214
|
|
|
2215
|
+
|
|
2216
|
+
|
|
2217
|
+
|
|
2218
|
+
|
|
2136
2219
|
|
|
2137
2220
|
|
|
2138
2221
|
|
|
@@ -2175,6 +2258,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2175
2258
|
|
|
2176
2259
|
|
|
2177
2260
|
|
|
2261
|
+
|
|
2262
|
+
|
|
2263
|
+
|
|
2264
|
+
|
|
2178
2265
|
|
|
2179
2266
|
|
|
2180
2267
|
|
|
@@ -2238,6 +2325,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2238
2325
|
|
|
2239
2326
|
|
|
2240
2327
|
|
|
2328
|
+
|
|
2329
|
+
|
|
2330
|
+
|
|
2331
|
+
|
|
2241
2332
|
|
|
2242
2333
|
|
|
2243
2334
|
|
|
@@ -2254,22 +2345,66 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2254
2345
|
this.setMany(anotherTree, []);
|
|
2255
2346
|
}
|
|
2256
2347
|
/**
|
|
2257
|
-
*
|
|
2258
|
-
* @remarks Time O(N)
|
|
2348
|
+
* Deletes a node from the tree (internal, returns balancing metadata).
|
|
2349
|
+
* @remarks Time O(N) — O(N) to find the node + O(H) for predecessor swap. Space O(1). BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
|
|
2350
|
+
* @internal Used by AVL/BST subclasses that need balancing metadata after deletion.
|
|
2259
2351
|
*
|
|
2260
|
-
* @param
|
|
2261
|
-
* @
|
|
2352
|
+
* @param keyNodeEntryRawOrPredicate - The node to delete.
|
|
2353
|
+
* @returns An array containing deletion results with balancing metadata.
|
|
2262
2354
|
*/
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
this.
|
|
2355
|
+
_deleteInternal(keyNodeEntryRawOrPredicate) {
|
|
2356
|
+
const deletedResult = [];
|
|
2357
|
+
if (!this._root) return deletedResult;
|
|
2358
|
+
const curr = this.getNode(keyNodeEntryRawOrPredicate);
|
|
2359
|
+
if (!curr) return deletedResult;
|
|
2360
|
+
const parent = curr?.parent;
|
|
2361
|
+
let needBalanced;
|
|
2362
|
+
let orgCurrent = curr;
|
|
2363
|
+
if (!curr.left && !curr.right && !parent) {
|
|
2364
|
+
this._setRoot(void 0);
|
|
2365
|
+
} else if (curr.left) {
|
|
2366
|
+
const leftSubTreeRightMost = this.getRightMost((node) => node, curr.left);
|
|
2367
|
+
if (leftSubTreeRightMost) {
|
|
2368
|
+
const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
|
|
2369
|
+
orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
|
|
2370
|
+
if (this._isMapMode) {
|
|
2371
|
+
this._store.set(curr.key, curr);
|
|
2372
|
+
this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);
|
|
2373
|
+
}
|
|
2374
|
+
if (parentOfLeftSubTreeMax) {
|
|
2375
|
+
if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)
|
|
2376
|
+
parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
|
|
2377
|
+
else parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
|
|
2378
|
+
needBalanced = parentOfLeftSubTreeMax;
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
} else if (parent) {
|
|
2382
|
+
const { familyPosition: fp } = curr;
|
|
2383
|
+
if (fp === "LEFT" || fp === "ROOT_LEFT") {
|
|
2384
|
+
parent.left = curr.right;
|
|
2385
|
+
} else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
|
|
2386
|
+
parent.right = curr.right;
|
|
2387
|
+
}
|
|
2388
|
+
needBalanced = parent;
|
|
2389
|
+
} else {
|
|
2390
|
+
this._setRoot(curr.right);
|
|
2391
|
+
curr.right = void 0;
|
|
2392
|
+
}
|
|
2393
|
+
this._size = this._size - 1;
|
|
2394
|
+
deletedResult.push({ deleted: orgCurrent, needBalanced });
|
|
2395
|
+
if (this._isMapMode && orgCurrent) this._store.delete(orgCurrent.key);
|
|
2396
|
+
return deletedResult;
|
|
2266
2397
|
}
|
|
2267
2398
|
/**
|
|
2268
2399
|
* Deletes a node from the tree.
|
|
2269
|
-
* @remarks Time O(
|
|
2400
|
+
* @remarks Time O(N) — O(N) to find the node + O(H) for predecessor swap. Space O(1). BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
|
|
2270
2401
|
*
|
|
2271
2402
|
* @param keyNodeEntryRawOrPredicate - The node to delete.
|
|
2272
|
-
* @returns
|
|
2403
|
+
* @returns True if the node was found and deleted, false otherwise.
|
|
2404
|
+
|
|
2405
|
+
|
|
2406
|
+
|
|
2407
|
+
|
|
2273
2408
|
|
|
2274
2409
|
|
|
2275
2410
|
|
|
@@ -2313,51 +2448,11 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2313
2448
|
* console.log(tree.size); // 4;
|
|
2314
2449
|
*/
|
|
2315
2450
|
delete(keyNodeEntryRawOrPredicate) {
|
|
2316
|
-
|
|
2317
|
-
if (!this._root) return deletedResult;
|
|
2318
|
-
const curr = this.getNode(keyNodeEntryRawOrPredicate);
|
|
2319
|
-
if (!curr) return deletedResult;
|
|
2320
|
-
const parent = curr?.parent;
|
|
2321
|
-
let needBalanced;
|
|
2322
|
-
let orgCurrent = curr;
|
|
2323
|
-
if (!curr.left && !curr.right && !parent) {
|
|
2324
|
-
this._setRoot(void 0);
|
|
2325
|
-
} else if (curr.left) {
|
|
2326
|
-
const leftSubTreeRightMost = this.getRightMost((node) => node, curr.left);
|
|
2327
|
-
if (leftSubTreeRightMost) {
|
|
2328
|
-
const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
|
|
2329
|
-
orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
|
|
2330
|
-
if (this._isMapMode) {
|
|
2331
|
-
this._store.set(curr.key, curr);
|
|
2332
|
-
this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);
|
|
2333
|
-
}
|
|
2334
|
-
if (parentOfLeftSubTreeMax) {
|
|
2335
|
-
if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)
|
|
2336
|
-
parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
|
|
2337
|
-
else parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
|
|
2338
|
-
needBalanced = parentOfLeftSubTreeMax;
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
} else if (parent) {
|
|
2342
|
-
const { familyPosition: fp } = curr;
|
|
2343
|
-
if (fp === "LEFT" || fp === "ROOT_LEFT") {
|
|
2344
|
-
parent.left = curr.right;
|
|
2345
|
-
} else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
|
|
2346
|
-
parent.right = curr.right;
|
|
2347
|
-
}
|
|
2348
|
-
needBalanced = parent;
|
|
2349
|
-
} else {
|
|
2350
|
-
this._setRoot(curr.right);
|
|
2351
|
-
curr.right = void 0;
|
|
2352
|
-
}
|
|
2353
|
-
this._size = this._size - 1;
|
|
2354
|
-
deletedResult.push({ deleted: orgCurrent, needBalanced });
|
|
2355
|
-
if (this._isMapMode && orgCurrent) this._store.delete(orgCurrent.key);
|
|
2356
|
-
return deletedResult;
|
|
2451
|
+
return this._deleteInternal(keyNodeEntryRawOrPredicate).length > 0;
|
|
2357
2452
|
}
|
|
2358
2453
|
/**
|
|
2359
2454
|
* Searches the tree for nodes matching a predicate.
|
|
2360
|
-
* @remarks Time O(
|
|
2455
|
+
* @remarks Time O(N) — full DFS scan; may visit every node. Space O(H) for call/explicit stack (O(N) worst-case). BST subclasses with key search override to O(log N).
|
|
2361
2456
|
*
|
|
2362
2457
|
* @template C - The type of the callback function.
|
|
2363
2458
|
* @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
|
|
@@ -2406,7 +2501,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2406
2501
|
}
|
|
2407
2502
|
/**
|
|
2408
2503
|
* Gets the first node matching a predicate.
|
|
2409
|
-
* @remarks Time O(
|
|
2504
|
+
* @remarks Time O(N) via `search`. Space O(H) or O(N). BST/Red-Black Tree/AVL Tree subclasses override to O(log N) for key lookups.
|
|
2410
2505
|
*
|
|
2411
2506
|
* @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
|
|
2412
2507
|
* @param [startNode=this._root] - The node to start the search from.
|
|
@@ -2440,6 +2535,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2440
2535
|
|
|
2441
2536
|
|
|
2442
2537
|
|
|
2538
|
+
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2443
2542
|
|
|
2444
2543
|
|
|
2445
2544
|
|
|
@@ -2462,7 +2561,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2462
2561
|
}
|
|
2463
2562
|
/**
|
|
2464
2563
|
* Gets the value associated with a key.
|
|
2465
|
-
* @remarks Time O(
|
|
2564
|
+
* @remarks Time O(1) in Map mode, O(N) otherwise (via `getNode`). Space O(1) in Map mode, O(H) or O(N) otherwise. BST subclasses override non-Map-mode to O(log N).
|
|
2466
2565
|
*
|
|
2467
2566
|
* @param keyNodeEntryOrPredicate - The key, node, or entry to get the value for.
|
|
2468
2567
|
* @param [startNode=this._root] - The node to start searching from (if not in Map mode).
|
|
@@ -2498,6 +2597,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2498
2597
|
|
|
2499
2598
|
|
|
2500
2599
|
|
|
2600
|
+
|
|
2601
|
+
|
|
2602
|
+
|
|
2603
|
+
|
|
2501
2604
|
|
|
2502
2605
|
|
|
2503
2606
|
|
|
@@ -2558,6 +2661,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2558
2661
|
|
|
2559
2662
|
|
|
2560
2663
|
|
|
2664
|
+
|
|
2665
|
+
|
|
2666
|
+
|
|
2667
|
+
|
|
2561
2668
|
|
|
2562
2669
|
|
|
2563
2670
|
|
|
@@ -2606,6 +2713,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2606
2713
|
|
|
2607
2714
|
|
|
2608
2715
|
|
|
2716
|
+
|
|
2717
|
+
|
|
2718
|
+
|
|
2719
|
+
|
|
2609
2720
|
|
|
2610
2721
|
|
|
2611
2722
|
|
|
@@ -2663,6 +2774,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2663
2774
|
|
|
2664
2775
|
|
|
2665
2776
|
|
|
2777
|
+
|
|
2778
|
+
|
|
2779
|
+
|
|
2780
|
+
|
|
2666
2781
|
|
|
2667
2782
|
|
|
2668
2783
|
|
|
@@ -2747,6 +2862,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2747
2862
|
|
|
2748
2863
|
|
|
2749
2864
|
|
|
2865
|
+
|
|
2866
|
+
|
|
2867
|
+
|
|
2868
|
+
|
|
2750
2869
|
|
|
2751
2870
|
|
|
2752
2871
|
|
|
@@ -2808,6 +2927,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2808
2927
|
|
|
2809
2928
|
|
|
2810
2929
|
|
|
2930
|
+
|
|
2931
|
+
|
|
2932
|
+
|
|
2933
|
+
|
|
2811
2934
|
|
|
2812
2935
|
|
|
2813
2936
|
|
|
@@ -3285,6 +3408,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3285
3408
|
|
|
3286
3409
|
|
|
3287
3410
|
|
|
3411
|
+
|
|
3412
|
+
|
|
3413
|
+
|
|
3414
|
+
|
|
3288
3415
|
|
|
3289
3416
|
|
|
3290
3417
|
|
|
@@ -3337,6 +3464,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3337
3464
|
|
|
3338
3465
|
|
|
3339
3466
|
|
|
3467
|
+
|
|
3468
|
+
|
|
3469
|
+
|
|
3470
|
+
|
|
3340
3471
|
|
|
3341
3472
|
|
|
3342
3473
|
|
|
@@ -3393,6 +3524,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3393
3524
|
|
|
3394
3525
|
|
|
3395
3526
|
|
|
3527
|
+
|
|
3528
|
+
|
|
3529
|
+
|
|
3530
|
+
|
|
3396
3531
|
|
|
3397
3532
|
|
|
3398
3533
|
|
|
@@ -3474,6 +3609,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3474
3609
|
|
|
3475
3610
|
|
|
3476
3611
|
|
|
3612
|
+
|
|
3613
|
+
|
|
3614
|
+
|
|
3615
|
+
|
|
3477
3616
|
|
|
3478
3617
|
|
|
3479
3618
|
|
|
@@ -4293,6 +4432,14 @@ var BST = class extends BinaryTree {
|
|
|
4293
4432
|
|
|
4294
4433
|
|
|
4295
4434
|
|
|
4435
|
+
|
|
4436
|
+
|
|
4437
|
+
|
|
4438
|
+
|
|
4439
|
+
|
|
4440
|
+
|
|
4441
|
+
|
|
4442
|
+
|
|
4296
4443
|
|
|
4297
4444
|
|
|
4298
4445
|
|
|
@@ -4625,6 +4772,18 @@ var BST = class extends BinaryTree {
|
|
|
4625
4772
|
|
|
4626
4773
|
|
|
4627
4774
|
|
|
4775
|
+
|
|
4776
|
+
|
|
4777
|
+
|
|
4778
|
+
|
|
4779
|
+
|
|
4780
|
+
|
|
4781
|
+
|
|
4782
|
+
|
|
4783
|
+
|
|
4784
|
+
|
|
4785
|
+
|
|
4786
|
+
|
|
4628
4787
|
|
|
4629
4788
|
|
|
4630
4789
|
|
|
@@ -4744,6 +4903,14 @@ var BST = class extends BinaryTree {
|
|
|
4744
4903
|
|
|
4745
4904
|
|
|
4746
4905
|
|
|
4906
|
+
|
|
4907
|
+
|
|
4908
|
+
|
|
4909
|
+
|
|
4910
|
+
|
|
4911
|
+
|
|
4912
|
+
|
|
4913
|
+
|
|
4747
4914
|
|
|
4748
4915
|
|
|
4749
4916
|
|
|
@@ -5035,6 +5202,10 @@ var BST = class extends BinaryTree {
|
|
|
5035
5202
|
|
|
5036
5203
|
|
|
5037
5204
|
|
|
5205
|
+
|
|
5206
|
+
|
|
5207
|
+
|
|
5208
|
+
|
|
5038
5209
|
|
|
5039
5210
|
|
|
5040
5211
|
|
|
@@ -5104,6 +5275,10 @@ var BST = class extends BinaryTree {
|
|
|
5104
5275
|
|
|
5105
5276
|
|
|
5106
5277
|
|
|
5278
|
+
|
|
5279
|
+
|
|
5280
|
+
|
|
5281
|
+
|
|
5107
5282
|
|
|
5108
5283
|
|
|
5109
5284
|
|
|
@@ -5222,6 +5397,14 @@ var BST = class extends BinaryTree {
|
|
|
5222
5397
|
|
|
5223
5398
|
|
|
5224
5399
|
|
|
5400
|
+
|
|
5401
|
+
|
|
5402
|
+
|
|
5403
|
+
|
|
5404
|
+
|
|
5405
|
+
|
|
5406
|
+
|
|
5407
|
+
|
|
5225
5408
|
|
|
5226
5409
|
|
|
5227
5410
|
|
|
@@ -5283,12 +5466,11 @@ var BST = class extends BinaryTree {
|
|
|
5283
5466
|
*/
|
|
5284
5467
|
deleteWhere(keyNodeEntryOrPredicate, onlyOne = false, startNode = this._root, iterationType = this.iterationType) {
|
|
5285
5468
|
const toDelete = this.search(keyNodeEntryOrPredicate, onlyOne, (node) => node, startNode, iterationType);
|
|
5286
|
-
let
|
|
5469
|
+
let deleted = false;
|
|
5287
5470
|
for (const node of toDelete) {
|
|
5288
|
-
|
|
5289
|
-
results = results.concat(deleteInfo);
|
|
5471
|
+
if (this.delete(node)) deleted = true;
|
|
5290
5472
|
}
|
|
5291
|
-
return
|
|
5473
|
+
return deleted;
|
|
5292
5474
|
}
|
|
5293
5475
|
/**
|
|
5294
5476
|
* (Protected) Creates the default comparator function for keys that don't have a custom comparator.
|
|
@@ -5915,6 +6097,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
5915
6097
|
|
|
5916
6098
|
|
|
5917
6099
|
|
|
6100
|
+
|
|
6101
|
+
|
|
6102
|
+
|
|
6103
|
+
|
|
6104
|
+
|
|
6105
|
+
|
|
6106
|
+
|
|
6107
|
+
|
|
5918
6108
|
|
|
5919
6109
|
|
|
5920
6110
|
|
|
@@ -5991,6 +6181,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
5991
6181
|
|
|
5992
6182
|
|
|
5993
6183
|
|
|
6184
|
+
|
|
6185
|
+
|
|
6186
|
+
|
|
6187
|
+
|
|
6188
|
+
|
|
6189
|
+
|
|
6190
|
+
|
|
6191
|
+
|
|
5994
6192
|
|
|
5995
6193
|
|
|
5996
6194
|
|
|
@@ -6067,6 +6265,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6067
6265
|
|
|
6068
6266
|
|
|
6069
6267
|
|
|
6268
|
+
|
|
6269
|
+
|
|
6270
|
+
|
|
6271
|
+
|
|
6272
|
+
|
|
6273
|
+
|
|
6274
|
+
|
|
6275
|
+
|
|
6070
6276
|
|
|
6071
6277
|
|
|
6072
6278
|
|
|
@@ -6143,6 +6349,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6143
6349
|
|
|
6144
6350
|
|
|
6145
6351
|
|
|
6352
|
+
|
|
6353
|
+
|
|
6354
|
+
|
|
6355
|
+
|
|
6356
|
+
|
|
6357
|
+
|
|
6358
|
+
|
|
6359
|
+
|
|
6146
6360
|
|
|
6147
6361
|
|
|
6148
6362
|
|
|
@@ -6217,6 +6431,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6217
6431
|
|
|
6218
6432
|
|
|
6219
6433
|
|
|
6434
|
+
|
|
6435
|
+
|
|
6436
|
+
|
|
6437
|
+
|
|
6438
|
+
|
|
6439
|
+
|
|
6440
|
+
|
|
6441
|
+
|
|
6220
6442
|
|
|
6221
6443
|
|
|
6222
6444
|
|
|
@@ -6298,6 +6520,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6298
6520
|
|
|
6299
6521
|
|
|
6300
6522
|
|
|
6523
|
+
|
|
6524
|
+
|
|
6525
|
+
|
|
6526
|
+
|
|
6527
|
+
|
|
6528
|
+
|
|
6529
|
+
|
|
6530
|
+
|
|
6301
6531
|
|
|
6302
6532
|
|
|
6303
6533
|
|
|
@@ -6352,6 +6582,10 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6352
6582
|
|
|
6353
6583
|
|
|
6354
6584
|
|
|
6585
|
+
|
|
6586
|
+
|
|
6587
|
+
|
|
6588
|
+
|
|
6355
6589
|
|
|
6356
6590
|
|
|
6357
6591
|
|
|
@@ -6413,6 +6647,10 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6413
6647
|
|
|
6414
6648
|
|
|
6415
6649
|
|
|
6650
|
+
|
|
6651
|
+
|
|
6652
|
+
|
|
6653
|
+
|
|
6416
6654
|
|
|
6417
6655
|
|
|
6418
6656
|
|
|
@@ -6577,6 +6815,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6577
6815
|
|
|
6578
6816
|
|
|
6579
6817
|
|
|
6818
|
+
|
|
6819
|
+
|
|
6820
|
+
|
|
6821
|
+
|
|
6580
6822
|
|
|
6581
6823
|
|
|
6582
6824
|
|
|
@@ -6649,6 +6891,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6649
6891
|
|
|
6650
6892
|
|
|
6651
6893
|
|
|
6894
|
+
|
|
6895
|
+
|
|
6896
|
+
|
|
6897
|
+
|
|
6652
6898
|
|
|
6653
6899
|
|
|
6654
6900
|
|
|
@@ -6715,6 +6961,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6715
6961
|
|
|
6716
6962
|
|
|
6717
6963
|
|
|
6964
|
+
|
|
6965
|
+
|
|
6966
|
+
|
|
6967
|
+
|
|
6718
6968
|
|
|
6719
6969
|
|
|
6720
6970
|
|
|
@@ -6788,6 +7038,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6788
7038
|
|
|
6789
7039
|
|
|
6790
7040
|
|
|
7041
|
+
|
|
7042
|
+
|
|
7043
|
+
|
|
7044
|
+
|
|
6791
7045
|
|
|
6792
7046
|
|
|
6793
7047
|
|
|
@@ -6839,6 +7093,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6839
7093
|
|
|
6840
7094
|
|
|
6841
7095
|
|
|
7096
|
+
|
|
7097
|
+
|
|
7098
|
+
|
|
7099
|
+
|
|
6842
7100
|
|
|
6843
7101
|
|
|
6844
7102
|
|
|
@@ -6916,6 +7174,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6916
7174
|
|
|
6917
7175
|
|
|
6918
7176
|
|
|
7177
|
+
|
|
7178
|
+
|
|
7179
|
+
|
|
7180
|
+
|
|
6919
7181
|
|
|
6920
7182
|
|
|
6921
7183
|
|
|
@@ -7301,6 +7563,22 @@ var AVLTree = class extends BST {
|
|
|
7301
7563
|
|
|
7302
7564
|
|
|
7303
7565
|
|
|
7566
|
+
|
|
7567
|
+
|
|
7568
|
+
|
|
7569
|
+
|
|
7570
|
+
|
|
7571
|
+
|
|
7572
|
+
|
|
7573
|
+
|
|
7574
|
+
|
|
7575
|
+
|
|
7576
|
+
|
|
7577
|
+
|
|
7578
|
+
|
|
7579
|
+
|
|
7580
|
+
|
|
7581
|
+
|
|
7304
7582
|
|
|
7305
7583
|
|
|
7306
7584
|
|
|
@@ -7429,6 +7707,18 @@ var AVLTree = class extends BST {
|
|
|
7429
7707
|
|
|
7430
7708
|
|
|
7431
7709
|
|
|
7710
|
+
|
|
7711
|
+
|
|
7712
|
+
|
|
7713
|
+
|
|
7714
|
+
|
|
7715
|
+
|
|
7716
|
+
|
|
7717
|
+
|
|
7718
|
+
|
|
7719
|
+
|
|
7720
|
+
|
|
7721
|
+
|
|
7432
7722
|
|
|
7433
7723
|
|
|
7434
7724
|
|
|
@@ -7450,13 +7740,13 @@ var AVLTree = class extends BST {
|
|
|
7450
7740
|
* console.log(avl.size); // 6;
|
|
7451
7741
|
*/
|
|
7452
7742
|
delete(keyNodeOrEntry) {
|
|
7453
|
-
const deletedResults =
|
|
7743
|
+
const deletedResults = this._deleteInternal(keyNodeOrEntry);
|
|
7454
7744
|
for (const { needBalanced } of deletedResults) {
|
|
7455
7745
|
if (needBalanced) {
|
|
7456
7746
|
this._balancePath(needBalanced);
|
|
7457
7747
|
}
|
|
7458
7748
|
}
|
|
7459
|
-
return deletedResults;
|
|
7749
|
+
return deletedResults.length > 0;
|
|
7460
7750
|
}
|
|
7461
7751
|
/**
|
|
7462
7752
|
* Rebuilds the tree to be perfectly balanced.
|
|
@@ -7516,6 +7806,14 @@ var AVLTree = class extends BST {
|
|
|
7516
7806
|
|
|
7517
7807
|
|
|
7518
7808
|
|
|
7809
|
+
|
|
7810
|
+
|
|
7811
|
+
|
|
7812
|
+
|
|
7813
|
+
|
|
7814
|
+
|
|
7815
|
+
|
|
7816
|
+
|
|
7519
7817
|
|
|
7520
7818
|
|
|
7521
7819
|
|
|
@@ -7648,6 +7946,18 @@ var AVLTree = class extends BST {
|
|
|
7648
7946
|
|
|
7649
7947
|
|
|
7650
7948
|
|
|
7949
|
+
|
|
7950
|
+
|
|
7951
|
+
|
|
7952
|
+
|
|
7953
|
+
|
|
7954
|
+
|
|
7955
|
+
|
|
7956
|
+
|
|
7957
|
+
|
|
7958
|
+
|
|
7959
|
+
|
|
7960
|
+
|
|
7651
7961
|
|
|
7652
7962
|
|
|
7653
7963
|
|
|
@@ -8150,13 +8460,24 @@ var RedBlackTree = class extends BST {
|
|
|
8150
8460
|
return keyNodeOrEntry instanceof RedBlackTreeNode;
|
|
8151
8461
|
}
|
|
8152
8462
|
/**
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8463
|
+
* Remove all nodes, clear the key→value store (if in map mode) and internal caches.
|
|
8464
|
+
* @remarks Time O(n), Space O(1)
|
|
8465
|
+
|
|
8466
|
+
|
|
8467
|
+
|
|
8468
|
+
|
|
8469
|
+
|
|
8470
|
+
|
|
8471
|
+
|
|
8472
|
+
|
|
8473
|
+
|
|
8474
|
+
|
|
8475
|
+
|
|
8476
|
+
|
|
8477
|
+
|
|
8478
|
+
|
|
8479
|
+
|
|
8480
|
+
|
|
8160
8481
|
|
|
8161
8482
|
|
|
8162
8483
|
|
|
@@ -8746,6 +9067,22 @@ var RedBlackTree = class extends BST {
|
|
|
8746
9067
|
|
|
8747
9068
|
|
|
8748
9069
|
|
|
9070
|
+
|
|
9071
|
+
|
|
9072
|
+
|
|
9073
|
+
|
|
9074
|
+
|
|
9075
|
+
|
|
9076
|
+
|
|
9077
|
+
|
|
9078
|
+
|
|
9079
|
+
|
|
9080
|
+
|
|
9081
|
+
|
|
9082
|
+
|
|
9083
|
+
|
|
9084
|
+
|
|
9085
|
+
|
|
8749
9086
|
|
|
8750
9087
|
|
|
8751
9088
|
|
|
@@ -8945,6 +9282,22 @@ var RedBlackTree = class extends BST {
|
|
|
8945
9282
|
|
|
8946
9283
|
|
|
8947
9284
|
|
|
9285
|
+
|
|
9286
|
+
|
|
9287
|
+
|
|
9288
|
+
|
|
9289
|
+
|
|
9290
|
+
|
|
9291
|
+
|
|
9292
|
+
|
|
9293
|
+
|
|
9294
|
+
|
|
9295
|
+
|
|
9296
|
+
|
|
9297
|
+
|
|
9298
|
+
|
|
9299
|
+
|
|
9300
|
+
|
|
8948
9301
|
|
|
8949
9302
|
|
|
8950
9303
|
|
|
@@ -8970,13 +9323,12 @@ var RedBlackTree = class extends BST {
|
|
|
8970
9323
|
* console.log(rbt.size); // 4;
|
|
8971
9324
|
*/
|
|
8972
9325
|
delete(keyNodeEntryRawOrPredicate) {
|
|
8973
|
-
if (keyNodeEntryRawOrPredicate === null) return
|
|
8974
|
-
const results = [];
|
|
9326
|
+
if (keyNodeEntryRawOrPredicate === null) return false;
|
|
8975
9327
|
let nodeToDelete;
|
|
8976
9328
|
if (this._isPredicate(keyNodeEntryRawOrPredicate)) nodeToDelete = this.getNode(keyNodeEntryRawOrPredicate);
|
|
8977
9329
|
else nodeToDelete = this.isRealNode(keyNodeEntryRawOrPredicate) ? keyNodeEntryRawOrPredicate : this.getNode(keyNodeEntryRawOrPredicate);
|
|
8978
9330
|
if (!nodeToDelete) {
|
|
8979
|
-
return
|
|
9331
|
+
return false;
|
|
8980
9332
|
}
|
|
8981
9333
|
const willDeleteMin = nodeToDelete === this._minNode;
|
|
8982
9334
|
const willDeleteMax = nodeToDelete === this._maxNode;
|
|
@@ -9032,8 +9384,7 @@ var RedBlackTree = class extends BST {
|
|
|
9032
9384
|
if (originalColor === "BLACK") {
|
|
9033
9385
|
this._deleteFixup(replacementNode);
|
|
9034
9386
|
}
|
|
9035
|
-
|
|
9036
|
-
return results;
|
|
9387
|
+
return true;
|
|
9037
9388
|
}
|
|
9038
9389
|
/**
|
|
9039
9390
|
* Transform entries into a like-kind red-black tree with possibly different key/value types.
|
|
@@ -9134,6 +9485,18 @@ var RedBlackTree = class extends BST {
|
|
|
9134
9485
|
|
|
9135
9486
|
|
|
9136
9487
|
|
|
9488
|
+
|
|
9489
|
+
|
|
9490
|
+
|
|
9491
|
+
|
|
9492
|
+
|
|
9493
|
+
|
|
9494
|
+
|
|
9495
|
+
|
|
9496
|
+
|
|
9497
|
+
|
|
9498
|
+
|
|
9499
|
+
|
|
9137
9500
|
|
|
9138
9501
|
|
|
9139
9502
|
|
|
@@ -9282,6 +9645,22 @@ var RedBlackTree = class extends BST {
|
|
|
9282
9645
|
|
|
9283
9646
|
|
|
9284
9647
|
|
|
9648
|
+
|
|
9649
|
+
|
|
9650
|
+
|
|
9651
|
+
|
|
9652
|
+
|
|
9653
|
+
|
|
9654
|
+
|
|
9655
|
+
|
|
9656
|
+
|
|
9657
|
+
|
|
9658
|
+
|
|
9659
|
+
|
|
9660
|
+
|
|
9661
|
+
|
|
9662
|
+
|
|
9663
|
+
|
|
9285
9664
|
|
|
9286
9665
|
|
|
9287
9666
|
|
|
@@ -9795,6 +10174,26 @@ var TreeSet = class _TreeSet {
|
|
|
9795
10174
|
|
|
9796
10175
|
|
|
9797
10176
|
|
|
10177
|
+
|
|
10178
|
+
|
|
10179
|
+
|
|
10180
|
+
|
|
10181
|
+
|
|
10182
|
+
|
|
10183
|
+
|
|
10184
|
+
|
|
10185
|
+
|
|
10186
|
+
|
|
10187
|
+
|
|
10188
|
+
|
|
10189
|
+
|
|
10190
|
+
|
|
10191
|
+
|
|
10192
|
+
|
|
10193
|
+
|
|
10194
|
+
|
|
10195
|
+
|
|
10196
|
+
|
|
9798
10197
|
|
|
9799
10198
|
|
|
9800
10199
|
|
|
@@ -10000,28 +10399,103 @@ var TreeSet = class _TreeSet {
|
|
|
10000
10399
|
|
|
10001
10400
|
|
|
10002
10401
|
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10402
|
+
|
|
10403
|
+
|
|
10404
|
+
|
|
10405
|
+
|
|
10406
|
+
|
|
10407
|
+
|
|
10408
|
+
|
|
10409
|
+
|
|
10410
|
+
|
|
10411
|
+
|
|
10412
|
+
|
|
10413
|
+
|
|
10414
|
+
|
|
10415
|
+
|
|
10416
|
+
|
|
10417
|
+
|
|
10418
|
+
|
|
10419
|
+
|
|
10420
|
+
|
|
10421
|
+
|
|
10422
|
+
* @example
|
|
10423
|
+
* // Unique tags with sorted order
|
|
10424
|
+
* const tags = new TreeSet<string>(['javascript', 'typescript', 'react', 'typescript', 'node']);
|
|
10425
|
+
*
|
|
10426
|
+
* // Duplicates removed, sorted alphabetically
|
|
10427
|
+
* console.log([...tags]); // ['javascript', 'node', 'react', 'typescript'];
|
|
10428
|
+
* console.log(tags.size); // 4;
|
|
10429
|
+
*
|
|
10430
|
+
* tags.add('angular');
|
|
10431
|
+
* console.log(tags.first()); // 'angular';
|
|
10432
|
+
* console.log(tags.last()); // 'typescript';
|
|
10433
|
+
*/
|
|
10434
|
+
add(key) {
|
|
10435
|
+
this._validateKey(key);
|
|
10436
|
+
this.#core.set(key, void 0);
|
|
10437
|
+
return this;
|
|
10438
|
+
}
|
|
10439
|
+
/**
|
|
10440
|
+
* Add multiple keys at once.
|
|
10441
|
+
* @remarks Expected time O(m log n), where m is the number of keys.
|
|
10442
|
+
* @param keys - Iterable of keys to add.
|
|
10443
|
+
* @returns Array of booleans indicating whether each key was newly added.
|
|
10444
|
+
|
|
10445
|
+
|
|
10446
|
+
|
|
10447
|
+
|
|
10448
|
+
|
|
10449
|
+
|
|
10450
|
+
|
|
10451
|
+
|
|
10452
|
+
|
|
10453
|
+
|
|
10454
|
+
|
|
10455
|
+
|
|
10456
|
+
|
|
10457
|
+
|
|
10458
|
+
|
|
10459
|
+
|
|
10460
|
+
* @example
|
|
10461
|
+
* // Add multiple keys
|
|
10462
|
+
* const ts = new TreeSet<number>();
|
|
10463
|
+
* ts.addMany([5, 3, 7, 1, 9]);
|
|
10464
|
+
* console.log(ts.size); // 5;
|
|
10465
|
+
*/
|
|
10466
|
+
addMany(keys) {
|
|
10467
|
+
const results = [];
|
|
10468
|
+
for (const key of keys) {
|
|
10469
|
+
this._validateKey(key);
|
|
10470
|
+
results.push(this.#core.set(key, void 0));
|
|
10471
|
+
}
|
|
10472
|
+
return results;
|
|
10473
|
+
}
|
|
10474
|
+
/**
|
|
10475
|
+
* Test whether a key exists.
|
|
10476
|
+
* @remarks Expected time O(log n)
|
|
10477
|
+
|
|
10478
|
+
|
|
10479
|
+
|
|
10480
|
+
|
|
10481
|
+
|
|
10482
|
+
|
|
10483
|
+
|
|
10484
|
+
|
|
10485
|
+
|
|
10486
|
+
|
|
10487
|
+
|
|
10488
|
+
|
|
10489
|
+
|
|
10490
|
+
|
|
10491
|
+
|
|
10492
|
+
|
|
10493
|
+
|
|
10494
|
+
|
|
10495
|
+
|
|
10496
|
+
|
|
10497
|
+
|
|
10498
|
+
|
|
10025
10499
|
|
|
10026
10500
|
|
|
10027
10501
|
|
|
@@ -10352,6 +10826,26 @@ var TreeSet = class _TreeSet {
|
|
|
10352
10826
|
|
|
10353
10827
|
|
|
10354
10828
|
|
|
10829
|
+
|
|
10830
|
+
|
|
10831
|
+
|
|
10832
|
+
|
|
10833
|
+
|
|
10834
|
+
|
|
10835
|
+
|
|
10836
|
+
|
|
10837
|
+
|
|
10838
|
+
|
|
10839
|
+
|
|
10840
|
+
|
|
10841
|
+
|
|
10842
|
+
|
|
10843
|
+
|
|
10844
|
+
|
|
10845
|
+
|
|
10846
|
+
|
|
10847
|
+
|
|
10848
|
+
|
|
10355
10849
|
|
|
10356
10850
|
|
|
10357
10851
|
|
|
@@ -10383,8 +10877,24 @@ var TreeSet = class _TreeSet {
|
|
|
10383
10877
|
*/
|
|
10384
10878
|
delete(key) {
|
|
10385
10879
|
this._validateKey(key);
|
|
10386
|
-
|
|
10387
|
-
|
|
10880
|
+
return this.#core.delete(key);
|
|
10881
|
+
}
|
|
10882
|
+
/**
|
|
10883
|
+
* Delete all keys matching a predicate.
|
|
10884
|
+
* @remarks Time O(N), Space O(N)
|
|
10885
|
+
* @param predicate - Function (key, index, set) → boolean; return true to delete.
|
|
10886
|
+
* @returns True if at least one key was deleted.
|
|
10887
|
+
*/
|
|
10888
|
+
deleteWhere(predicate) {
|
|
10889
|
+
let deleted = false;
|
|
10890
|
+
let index = 0;
|
|
10891
|
+
for (const key of this) {
|
|
10892
|
+
if (predicate(key, index++, this)) {
|
|
10893
|
+
this.delete(key);
|
|
10894
|
+
deleted = true;
|
|
10895
|
+
}
|
|
10896
|
+
}
|
|
10897
|
+
return deleted;
|
|
10388
10898
|
}
|
|
10389
10899
|
/**
|
|
10390
10900
|
* Remove all keys.
|
|
@@ -10525,6 +11035,26 @@ var TreeSet = class _TreeSet {
|
|
|
10525
11035
|
|
|
10526
11036
|
|
|
10527
11037
|
|
|
11038
|
+
|
|
11039
|
+
|
|
11040
|
+
|
|
11041
|
+
|
|
11042
|
+
|
|
11043
|
+
|
|
11044
|
+
|
|
11045
|
+
|
|
11046
|
+
|
|
11047
|
+
|
|
11048
|
+
|
|
11049
|
+
|
|
11050
|
+
|
|
11051
|
+
|
|
11052
|
+
|
|
11053
|
+
|
|
11054
|
+
|
|
11055
|
+
|
|
11056
|
+
|
|
11057
|
+
|
|
10528
11058
|
|
|
10529
11059
|
|
|
10530
11060
|
|
|
@@ -10694,6 +11224,26 @@ var TreeSet = class _TreeSet {
|
|
|
10694
11224
|
|
|
10695
11225
|
|
|
10696
11226
|
|
|
11227
|
+
|
|
11228
|
+
|
|
11229
|
+
|
|
11230
|
+
|
|
11231
|
+
|
|
11232
|
+
|
|
11233
|
+
|
|
11234
|
+
|
|
11235
|
+
|
|
11236
|
+
|
|
11237
|
+
|
|
11238
|
+
|
|
11239
|
+
|
|
11240
|
+
|
|
11241
|
+
|
|
11242
|
+
|
|
11243
|
+
|
|
11244
|
+
|
|
11245
|
+
|
|
11246
|
+
|
|
10697
11247
|
|
|
10698
11248
|
|
|
10699
11249
|
|
|
@@ -10864,6 +11414,26 @@ var TreeSet = class _TreeSet {
|
|
|
10864
11414
|
|
|
10865
11415
|
|
|
10866
11416
|
|
|
11417
|
+
|
|
11418
|
+
|
|
11419
|
+
|
|
11420
|
+
|
|
11421
|
+
|
|
11422
|
+
|
|
11423
|
+
|
|
11424
|
+
|
|
11425
|
+
|
|
11426
|
+
|
|
11427
|
+
|
|
11428
|
+
|
|
11429
|
+
|
|
11430
|
+
|
|
11431
|
+
|
|
11432
|
+
|
|
11433
|
+
|
|
11434
|
+
|
|
11435
|
+
|
|
11436
|
+
|
|
10867
11437
|
|
|
10868
11438
|
|
|
10869
11439
|
|
|
@@ -11034,6 +11604,26 @@ var TreeSet = class _TreeSet {
|
|
|
11034
11604
|
|
|
11035
11605
|
|
|
11036
11606
|
|
|
11607
|
+
|
|
11608
|
+
|
|
11609
|
+
|
|
11610
|
+
|
|
11611
|
+
|
|
11612
|
+
|
|
11613
|
+
|
|
11614
|
+
|
|
11615
|
+
|
|
11616
|
+
|
|
11617
|
+
|
|
11618
|
+
|
|
11619
|
+
|
|
11620
|
+
|
|
11621
|
+
|
|
11622
|
+
|
|
11623
|
+
|
|
11624
|
+
|
|
11625
|
+
|
|
11626
|
+
|
|
11037
11627
|
|
|
11038
11628
|
|
|
11039
11629
|
|
|
@@ -11207,6 +11797,26 @@ var TreeSet = class _TreeSet {
|
|
|
11207
11797
|
|
|
11208
11798
|
|
|
11209
11799
|
|
|
11800
|
+
|
|
11801
|
+
|
|
11802
|
+
|
|
11803
|
+
|
|
11804
|
+
|
|
11805
|
+
|
|
11806
|
+
|
|
11807
|
+
|
|
11808
|
+
|
|
11809
|
+
|
|
11810
|
+
|
|
11811
|
+
|
|
11812
|
+
|
|
11813
|
+
|
|
11814
|
+
|
|
11815
|
+
|
|
11816
|
+
|
|
11817
|
+
|
|
11818
|
+
|
|
11819
|
+
|
|
11210
11820
|
|
|
11211
11821
|
|
|
11212
11822
|
|
|
@@ -11380,6 +11990,26 @@ var TreeSet = class _TreeSet {
|
|
|
11380
11990
|
|
|
11381
11991
|
|
|
11382
11992
|
|
|
11993
|
+
|
|
11994
|
+
|
|
11995
|
+
|
|
11996
|
+
|
|
11997
|
+
|
|
11998
|
+
|
|
11999
|
+
|
|
12000
|
+
|
|
12001
|
+
|
|
12002
|
+
|
|
12003
|
+
|
|
12004
|
+
|
|
12005
|
+
|
|
12006
|
+
|
|
12007
|
+
|
|
12008
|
+
|
|
12009
|
+
|
|
12010
|
+
|
|
12011
|
+
|
|
12012
|
+
|
|
11383
12013
|
|
|
11384
12014
|
|
|
11385
12015
|
|
|
@@ -11556,6 +12186,26 @@ var TreeSet = class _TreeSet {
|
|
|
11556
12186
|
|
|
11557
12187
|
|
|
11558
12188
|
|
|
12189
|
+
|
|
12190
|
+
|
|
12191
|
+
|
|
12192
|
+
|
|
12193
|
+
|
|
12194
|
+
|
|
12195
|
+
|
|
12196
|
+
|
|
12197
|
+
|
|
12198
|
+
|
|
12199
|
+
|
|
12200
|
+
|
|
12201
|
+
|
|
12202
|
+
|
|
12203
|
+
|
|
12204
|
+
|
|
12205
|
+
|
|
12206
|
+
|
|
12207
|
+
|
|
12208
|
+
|
|
11559
12209
|
|
|
11560
12210
|
|
|
11561
12211
|
|
|
@@ -11732,6 +12382,26 @@ var TreeSet = class _TreeSet {
|
|
|
11732
12382
|
|
|
11733
12383
|
|
|
11734
12384
|
|
|
12385
|
+
|
|
12386
|
+
|
|
12387
|
+
|
|
12388
|
+
|
|
12389
|
+
|
|
12390
|
+
|
|
12391
|
+
|
|
12392
|
+
|
|
12393
|
+
|
|
12394
|
+
|
|
12395
|
+
|
|
12396
|
+
|
|
12397
|
+
|
|
12398
|
+
|
|
12399
|
+
|
|
12400
|
+
|
|
12401
|
+
|
|
12402
|
+
|
|
12403
|
+
|
|
12404
|
+
|
|
11735
12405
|
|
|
11736
12406
|
|
|
11737
12407
|
|
|
@@ -11903,6 +12573,26 @@ var TreeSet = class _TreeSet {
|
|
|
11903
12573
|
|
|
11904
12574
|
|
|
11905
12575
|
|
|
12576
|
+
|
|
12577
|
+
|
|
12578
|
+
|
|
12579
|
+
|
|
12580
|
+
|
|
12581
|
+
|
|
12582
|
+
|
|
12583
|
+
|
|
12584
|
+
|
|
12585
|
+
|
|
12586
|
+
|
|
12587
|
+
|
|
12588
|
+
|
|
12589
|
+
|
|
12590
|
+
|
|
12591
|
+
|
|
12592
|
+
|
|
12593
|
+
|
|
12594
|
+
|
|
12595
|
+
|
|
11906
12596
|
|
|
11907
12597
|
|
|
11908
12598
|
|
|
@@ -12075,6 +12765,26 @@ var TreeSet = class _TreeSet {
|
|
|
12075
12765
|
|
|
12076
12766
|
|
|
12077
12767
|
|
|
12768
|
+
|
|
12769
|
+
|
|
12770
|
+
|
|
12771
|
+
|
|
12772
|
+
|
|
12773
|
+
|
|
12774
|
+
|
|
12775
|
+
|
|
12776
|
+
|
|
12777
|
+
|
|
12778
|
+
|
|
12779
|
+
|
|
12780
|
+
|
|
12781
|
+
|
|
12782
|
+
|
|
12783
|
+
|
|
12784
|
+
|
|
12785
|
+
|
|
12786
|
+
|
|
12787
|
+
|
|
12078
12788
|
|
|
12079
12789
|
|
|
12080
12790
|
|
|
@@ -12268,23 +12978,83 @@ var TreeSet = class _TreeSet {
|
|
|
12268
12978
|
|
|
12269
12979
|
|
|
12270
12980
|
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12981
|
+
|
|
12982
|
+
|
|
12983
|
+
|
|
12984
|
+
|
|
12985
|
+
|
|
12986
|
+
|
|
12987
|
+
|
|
12988
|
+
|
|
12989
|
+
|
|
12990
|
+
|
|
12991
|
+
|
|
12992
|
+
|
|
12993
|
+
|
|
12994
|
+
|
|
12995
|
+
|
|
12996
|
+
|
|
12997
|
+
|
|
12998
|
+
|
|
12999
|
+
|
|
13000
|
+
|
|
13001
|
+
* @example
|
|
13002
|
+
* // Find entry
|
|
13003
|
+
* const ts = new TreeSet<number>([1, 2, 3]);
|
|
13004
|
+
* const found = ts.find(k => k === 2);
|
|
13005
|
+
* console.log(found); // 2;
|
|
13006
|
+
*/
|
|
13007
|
+
find(callbackfn, thisArg) {
|
|
13008
|
+
let index = 0;
|
|
13009
|
+
for (const v of this) {
|
|
13010
|
+
const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
|
|
13011
|
+
if (ok) return v;
|
|
13012
|
+
}
|
|
13013
|
+
return void 0;
|
|
13014
|
+
}
|
|
13015
|
+
/**
|
|
13016
|
+
* Materialize the set into an array of keys.
|
|
13017
|
+
* @remarks Time O(n), Space O(n)
|
|
13018
|
+
|
|
13019
|
+
|
|
13020
|
+
|
|
13021
|
+
|
|
13022
|
+
|
|
13023
|
+
|
|
13024
|
+
|
|
13025
|
+
|
|
13026
|
+
|
|
13027
|
+
|
|
13028
|
+
|
|
13029
|
+
|
|
13030
|
+
|
|
13031
|
+
|
|
13032
|
+
|
|
13033
|
+
|
|
13034
|
+
|
|
13035
|
+
|
|
13036
|
+
|
|
13037
|
+
|
|
13038
|
+
|
|
13039
|
+
|
|
13040
|
+
|
|
13041
|
+
|
|
13042
|
+
|
|
13043
|
+
|
|
13044
|
+
|
|
13045
|
+
|
|
13046
|
+
|
|
13047
|
+
|
|
13048
|
+
|
|
13049
|
+
|
|
13050
|
+
|
|
13051
|
+
|
|
13052
|
+
|
|
13053
|
+
|
|
13054
|
+
|
|
13055
|
+
|
|
13056
|
+
|
|
13057
|
+
|
|
12288
13058
|
|
|
12289
13059
|
|
|
12290
13060
|
|
|
@@ -12423,6 +13193,17 @@ var TreeSet = class _TreeSet {
|
|
|
12423
13193
|
|
|
12424
13194
|
|
|
12425
13195
|
|
|
13196
|
+
* @example
|
|
13197
|
+
* // Convert to array
|
|
13198
|
+
* const ts = new TreeSet<number>([3, 1, 2]);
|
|
13199
|
+
* console.log(ts.toArray()); // [1, 2, 3];
|
|
13200
|
+
*/
|
|
13201
|
+
toArray() {
|
|
13202
|
+
return [...this];
|
|
13203
|
+
}
|
|
13204
|
+
/**
|
|
13205
|
+
* Print a human-friendly representation.
|
|
13206
|
+
* @remarks Time O(n), Space O(n)
|
|
12426
13207
|
|
|
12427
13208
|
|
|
12428
13209
|
|
|
@@ -12443,17 +13224,6 @@ var TreeSet = class _TreeSet {
|
|
|
12443
13224
|
|
|
12444
13225
|
|
|
12445
13226
|
|
|
12446
|
-
* @example
|
|
12447
|
-
* // Convert to array
|
|
12448
|
-
* const ts = new TreeSet<number>([3, 1, 2]);
|
|
12449
|
-
* console.log(ts.toArray()); // [1, 2, 3];
|
|
12450
|
-
*/
|
|
12451
|
-
toArray() {
|
|
12452
|
-
return [...this];
|
|
12453
|
-
}
|
|
12454
|
-
/**
|
|
12455
|
-
* Print a human-friendly representation.
|
|
12456
|
-
* @remarks Time O(n), Space O(n)
|
|
12457
13227
|
|
|
12458
13228
|
|
|
12459
13229
|
|
|
@@ -12653,6 +13423,10 @@ var TreeSet = class _TreeSet {
|
|
|
12653
13423
|
|
|
12654
13424
|
|
|
12655
13425
|
|
|
13426
|
+
|
|
13427
|
+
|
|
13428
|
+
|
|
13429
|
+
|
|
12656
13430
|
|
|
12657
13431
|
|
|
12658
13432
|
|
|
@@ -12721,6 +13495,10 @@ var TreeSet = class _TreeSet {
|
|
|
12721
13495
|
|
|
12722
13496
|
|
|
12723
13497
|
|
|
13498
|
+
|
|
13499
|
+
|
|
13500
|
+
|
|
13501
|
+
|
|
12724
13502
|
|
|
12725
13503
|
|
|
12726
13504
|
|
|
@@ -12767,6 +13545,10 @@ var TreeSet = class _TreeSet {
|
|
|
12767
13545
|
|
|
12768
13546
|
|
|
12769
13547
|
|
|
13548
|
+
|
|
13549
|
+
|
|
13550
|
+
|
|
13551
|
+
|
|
12770
13552
|
|
|
12771
13553
|
|
|
12772
13554
|
|
|
@@ -12818,6 +13600,10 @@ var TreeSet = class _TreeSet {
|
|
|
12818
13600
|
|
|
12819
13601
|
|
|
12820
13602
|
|
|
13603
|
+
|
|
13604
|
+
|
|
13605
|
+
|
|
13606
|
+
|
|
12821
13607
|
|
|
12822
13608
|
|
|
12823
13609
|
|
|
@@ -12955,6 +13741,22 @@ var TreeSet = class _TreeSet {
|
|
|
12955
13741
|
|
|
12956
13742
|
|
|
12957
13743
|
|
|
13744
|
+
|
|
13745
|
+
|
|
13746
|
+
|
|
13747
|
+
|
|
13748
|
+
|
|
13749
|
+
|
|
13750
|
+
|
|
13751
|
+
|
|
13752
|
+
|
|
13753
|
+
|
|
13754
|
+
|
|
13755
|
+
|
|
13756
|
+
|
|
13757
|
+
|
|
13758
|
+
|
|
13759
|
+
|
|
12958
13760
|
|
|
12959
13761
|
|
|
12960
13762
|
|
|
@@ -13112,6 +13914,22 @@ var TreeSet = class _TreeSet {
|
|
|
13112
13914
|
|
|
13113
13915
|
|
|
13114
13916
|
|
|
13917
|
+
|
|
13918
|
+
|
|
13919
|
+
|
|
13920
|
+
|
|
13921
|
+
|
|
13922
|
+
|
|
13923
|
+
|
|
13924
|
+
|
|
13925
|
+
|
|
13926
|
+
|
|
13927
|
+
|
|
13928
|
+
|
|
13929
|
+
|
|
13930
|
+
|
|
13931
|
+
|
|
13932
|
+
|
|
13115
13933
|
|
|
13116
13934
|
|
|
13117
13935
|
|
|
@@ -13261,6 +14079,22 @@ var TreeSet = class _TreeSet {
|
|
|
13261
14079
|
|
|
13262
14080
|
|
|
13263
14081
|
|
|
14082
|
+
|
|
14083
|
+
|
|
14084
|
+
|
|
14085
|
+
|
|
14086
|
+
|
|
14087
|
+
|
|
14088
|
+
|
|
14089
|
+
|
|
14090
|
+
|
|
14091
|
+
|
|
14092
|
+
|
|
14093
|
+
|
|
14094
|
+
|
|
14095
|
+
|
|
14096
|
+
|
|
14097
|
+
|
|
13264
14098
|
|
|
13265
14099
|
|
|
13266
14100
|
|
|
@@ -13408,6 +14242,22 @@ var TreeSet = class _TreeSet {
|
|
|
13408
14242
|
|
|
13409
14243
|
|
|
13410
14244
|
|
|
14245
|
+
|
|
14246
|
+
|
|
14247
|
+
|
|
14248
|
+
|
|
14249
|
+
|
|
14250
|
+
|
|
14251
|
+
|
|
14252
|
+
|
|
14253
|
+
|
|
14254
|
+
|
|
14255
|
+
|
|
14256
|
+
|
|
14257
|
+
|
|
14258
|
+
|
|
14259
|
+
|
|
14260
|
+
|
|
13411
14261
|
|
|
13412
14262
|
|
|
13413
14263
|
|
|
@@ -13558,6 +14408,22 @@ var TreeSet = class _TreeSet {
|
|
|
13558
14408
|
|
|
13559
14409
|
|
|
13560
14410
|
|
|
14411
|
+
|
|
14412
|
+
|
|
14413
|
+
|
|
14414
|
+
|
|
14415
|
+
|
|
14416
|
+
|
|
14417
|
+
|
|
14418
|
+
|
|
14419
|
+
|
|
14420
|
+
|
|
14421
|
+
|
|
14422
|
+
|
|
14423
|
+
|
|
14424
|
+
|
|
14425
|
+
|
|
14426
|
+
|
|
13561
14427
|
|
|
13562
14428
|
|
|
13563
14429
|
|
|
@@ -13647,8 +14513,16 @@ var TreeSet = class _TreeSet {
|
|
|
13647
14513
|
* Returns elements by rank range (0-indexed, inclusive on both ends).
|
|
13648
14514
|
* @remarks Time O(log n + k). Requires `enableOrderStatistic: true`.
|
|
13649
14515
|
|
|
14516
|
+
|
|
14517
|
+
|
|
14518
|
+
|
|
14519
|
+
|
|
14520
|
+
|
|
14521
|
+
|
|
14522
|
+
|
|
14523
|
+
|
|
13650
14524
|
* @example
|
|
13651
|
-
* // Pagination
|
|
14525
|
+
* // Pagination by position in tree order
|
|
13652
14526
|
* const tree = new TreeSet<number>(
|
|
13653
14527
|
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
13654
14528
|
* { enableOrderStatistic: true }
|
|
@@ -13806,6 +14680,26 @@ var TreeSet = class _TreeSet {
|
|
|
13806
14680
|
|
|
13807
14681
|
|
|
13808
14682
|
|
|
14683
|
+
|
|
14684
|
+
|
|
14685
|
+
|
|
14686
|
+
|
|
14687
|
+
|
|
14688
|
+
|
|
14689
|
+
|
|
14690
|
+
|
|
14691
|
+
|
|
14692
|
+
|
|
14693
|
+
|
|
14694
|
+
|
|
14695
|
+
|
|
14696
|
+
|
|
14697
|
+
|
|
14698
|
+
|
|
14699
|
+
|
|
14700
|
+
|
|
14701
|
+
|
|
14702
|
+
|
|
13809
14703
|
|
|
13810
14704
|
|
|
13811
14705
|
|
|
@@ -14056,6 +14950,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14056
14950
|
|
|
14057
14951
|
|
|
14058
14952
|
|
|
14953
|
+
|
|
14954
|
+
|
|
14955
|
+
|
|
14956
|
+
|
|
14957
|
+
|
|
14958
|
+
|
|
14959
|
+
|
|
14960
|
+
|
|
14961
|
+
|
|
14962
|
+
|
|
14963
|
+
|
|
14964
|
+
|
|
14965
|
+
|
|
14966
|
+
|
|
14967
|
+
|
|
14968
|
+
|
|
14969
|
+
|
|
14970
|
+
|
|
14971
|
+
|
|
14972
|
+
|
|
14059
14973
|
|
|
14060
14974
|
|
|
14061
14975
|
|
|
@@ -14224,6 +15138,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14224
15138
|
|
|
14225
15139
|
|
|
14226
15140
|
|
|
15141
|
+
|
|
15142
|
+
|
|
15143
|
+
|
|
15144
|
+
|
|
15145
|
+
|
|
15146
|
+
|
|
15147
|
+
|
|
15148
|
+
|
|
15149
|
+
|
|
15150
|
+
|
|
15151
|
+
|
|
15152
|
+
|
|
15153
|
+
|
|
15154
|
+
|
|
15155
|
+
|
|
15156
|
+
|
|
15157
|
+
|
|
15158
|
+
|
|
15159
|
+
|
|
15160
|
+
|
|
14227
15161
|
|
|
14228
15162
|
|
|
14229
15163
|
|
|
@@ -14279,6 +15213,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14279
15213
|
|
|
14280
15214
|
|
|
14281
15215
|
|
|
15216
|
+
|
|
15217
|
+
|
|
15218
|
+
|
|
15219
|
+
|
|
14282
15220
|
|
|
14283
15221
|
|
|
14284
15222
|
|
|
@@ -14319,6 +15257,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14319
15257
|
|
|
14320
15258
|
|
|
14321
15259
|
|
|
15260
|
+
|
|
15261
|
+
|
|
15262
|
+
|
|
15263
|
+
|
|
14322
15264
|
|
|
14323
15265
|
|
|
14324
15266
|
|
|
@@ -14515,6 +15457,30 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14515
15457
|
|
|
14516
15458
|
|
|
14517
15459
|
|
|
15460
|
+
|
|
15461
|
+
|
|
15462
|
+
|
|
15463
|
+
|
|
15464
|
+
|
|
15465
|
+
|
|
15466
|
+
|
|
15467
|
+
|
|
15468
|
+
|
|
15469
|
+
|
|
15470
|
+
|
|
15471
|
+
|
|
15472
|
+
|
|
15473
|
+
|
|
15474
|
+
|
|
15475
|
+
|
|
15476
|
+
|
|
15477
|
+
|
|
15478
|
+
|
|
15479
|
+
|
|
15480
|
+
|
|
15481
|
+
|
|
15482
|
+
|
|
15483
|
+
|
|
14518
15484
|
|
|
14519
15485
|
|
|
14520
15486
|
|
|
@@ -14725,6 +15691,30 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14725
15691
|
|
|
14726
15692
|
|
|
14727
15693
|
|
|
15694
|
+
|
|
15695
|
+
|
|
15696
|
+
|
|
15697
|
+
|
|
15698
|
+
|
|
15699
|
+
|
|
15700
|
+
|
|
15701
|
+
|
|
15702
|
+
|
|
15703
|
+
|
|
15704
|
+
|
|
15705
|
+
|
|
15706
|
+
|
|
15707
|
+
|
|
15708
|
+
|
|
15709
|
+
|
|
15710
|
+
|
|
15711
|
+
|
|
15712
|
+
|
|
15713
|
+
|
|
15714
|
+
|
|
15715
|
+
|
|
15716
|
+
|
|
15717
|
+
|
|
14728
15718
|
|
|
14729
15719
|
|
|
14730
15720
|
|
|
@@ -14891,6 +15881,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14891
15881
|
|
|
14892
15882
|
|
|
14893
15883
|
|
|
15884
|
+
|
|
15885
|
+
|
|
15886
|
+
|
|
15887
|
+
|
|
15888
|
+
|
|
15889
|
+
|
|
15890
|
+
|
|
15891
|
+
|
|
15892
|
+
|
|
15893
|
+
|
|
15894
|
+
|
|
15895
|
+
|
|
15896
|
+
|
|
15897
|
+
|
|
15898
|
+
|
|
15899
|
+
|
|
15900
|
+
|
|
15901
|
+
|
|
15902
|
+
|
|
15903
|
+
|
|
14894
15904
|
|
|
14895
15905
|
|
|
14896
15906
|
|
|
@@ -15126,6 +16136,30 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15126
16136
|
|
|
15127
16137
|
|
|
15128
16138
|
|
|
16139
|
+
|
|
16140
|
+
|
|
16141
|
+
|
|
16142
|
+
|
|
16143
|
+
|
|
16144
|
+
|
|
16145
|
+
|
|
16146
|
+
|
|
16147
|
+
|
|
16148
|
+
|
|
16149
|
+
|
|
16150
|
+
|
|
16151
|
+
|
|
16152
|
+
|
|
16153
|
+
|
|
16154
|
+
|
|
16155
|
+
|
|
16156
|
+
|
|
16157
|
+
|
|
16158
|
+
|
|
16159
|
+
|
|
16160
|
+
|
|
16161
|
+
|
|
16162
|
+
|
|
15129
16163
|
|
|
15130
16164
|
|
|
15131
16165
|
|
|
@@ -15157,7 +16191,7 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15157
16191
|
*/
|
|
15158
16192
|
delete(key) {
|
|
15159
16193
|
this._validateKey(key);
|
|
15160
|
-
return this.#core.delete(key)
|
|
16194
|
+
return this.#core.delete(key);
|
|
15161
16195
|
}
|
|
15162
16196
|
/**
|
|
15163
16197
|
* Check if a specific value exists in a key's bucket.
|
|
@@ -15183,6 +16217,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15183
16217
|
|
|
15184
16218
|
|
|
15185
16219
|
|
|
16220
|
+
|
|
16221
|
+
|
|
16222
|
+
|
|
16223
|
+
|
|
15186
16224
|
|
|
15187
16225
|
|
|
15188
16226
|
|
|
@@ -15224,6 +16262,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15224
16262
|
|
|
15225
16263
|
|
|
15226
16264
|
|
|
16265
|
+
|
|
16266
|
+
|
|
16267
|
+
|
|
16268
|
+
|
|
15227
16269
|
|
|
15228
16270
|
|
|
15229
16271
|
|
|
@@ -15270,6 +16312,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15270
16312
|
|
|
15271
16313
|
|
|
15272
16314
|
|
|
16315
|
+
|
|
16316
|
+
|
|
16317
|
+
|
|
16318
|
+
|
|
15273
16319
|
|
|
15274
16320
|
|
|
15275
16321
|
|
|
@@ -15448,6 +16494,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15448
16494
|
|
|
15449
16495
|
|
|
15450
16496
|
|
|
16497
|
+
|
|
16498
|
+
|
|
16499
|
+
|
|
16500
|
+
|
|
16501
|
+
|
|
16502
|
+
|
|
16503
|
+
|
|
16504
|
+
|
|
16505
|
+
|
|
16506
|
+
|
|
16507
|
+
|
|
16508
|
+
|
|
16509
|
+
|
|
16510
|
+
|
|
16511
|
+
|
|
16512
|
+
|
|
16513
|
+
|
|
16514
|
+
|
|
16515
|
+
|
|
16516
|
+
|
|
15451
16517
|
|
|
15452
16518
|
|
|
15453
16519
|
|
|
@@ -15619,6 +16685,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15619
16685
|
|
|
15620
16686
|
|
|
15621
16687
|
|
|
16688
|
+
|
|
16689
|
+
|
|
16690
|
+
|
|
16691
|
+
|
|
16692
|
+
|
|
16693
|
+
|
|
16694
|
+
|
|
16695
|
+
|
|
16696
|
+
|
|
16697
|
+
|
|
16698
|
+
|
|
16699
|
+
|
|
16700
|
+
|
|
16701
|
+
|
|
16702
|
+
|
|
16703
|
+
|
|
16704
|
+
|
|
16705
|
+
|
|
16706
|
+
|
|
16707
|
+
|
|
15622
16708
|
|
|
15623
16709
|
|
|
15624
16710
|
|
|
@@ -15675,6 +16761,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15675
16761
|
|
|
15676
16762
|
|
|
15677
16763
|
|
|
16764
|
+
|
|
16765
|
+
|
|
16766
|
+
|
|
16767
|
+
|
|
15678
16768
|
|
|
15679
16769
|
|
|
15680
16770
|
|
|
@@ -15716,6 +16806,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15716
16806
|
|
|
15717
16807
|
|
|
15718
16808
|
|
|
16809
|
+
|
|
16810
|
+
|
|
16811
|
+
|
|
16812
|
+
|
|
15719
16813
|
|
|
15720
16814
|
|
|
15721
16815
|
|
|
@@ -15757,6 +16851,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15757
16851
|
|
|
15758
16852
|
|
|
15759
16853
|
|
|
16854
|
+
|
|
16855
|
+
|
|
16856
|
+
|
|
16857
|
+
|
|
15760
16858
|
|
|
15761
16859
|
|
|
15762
16860
|
|
|
@@ -15832,6 +16930,14 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15832
16930
|
|
|
15833
16931
|
|
|
15834
16932
|
|
|
16933
|
+
|
|
16934
|
+
|
|
16935
|
+
|
|
16936
|
+
|
|
16937
|
+
|
|
16938
|
+
|
|
16939
|
+
|
|
16940
|
+
|
|
15835
16941
|
|
|
15836
16942
|
|
|
15837
16943
|
|
|
@@ -15913,6 +17019,14 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15913
17019
|
|
|
15914
17020
|
|
|
15915
17021
|
|
|
17022
|
+
|
|
17023
|
+
|
|
17024
|
+
|
|
17025
|
+
|
|
17026
|
+
|
|
17027
|
+
|
|
17028
|
+
|
|
17029
|
+
|
|
15916
17030
|
|
|
15917
17031
|
|
|
15918
17032
|
|
|
@@ -15963,6 +17077,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15963
17077
|
|
|
15964
17078
|
|
|
15965
17079
|
|
|
17080
|
+
|
|
17081
|
+
|
|
17082
|
+
|
|
17083
|
+
|
|
15966
17084
|
|
|
15967
17085
|
|
|
15968
17086
|
|
|
@@ -16008,6 +17126,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16008
17126
|
|
|
16009
17127
|
|
|
16010
17128
|
|
|
17129
|
+
|
|
17130
|
+
|
|
17131
|
+
|
|
17132
|
+
|
|
16011
17133
|
|
|
16012
17134
|
|
|
16013
17135
|
|
|
@@ -16170,6 +17292,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16170
17292
|
|
|
16171
17293
|
|
|
16172
17294
|
|
|
17295
|
+
|
|
17296
|
+
|
|
17297
|
+
|
|
17298
|
+
|
|
17299
|
+
|
|
17300
|
+
|
|
17301
|
+
|
|
17302
|
+
|
|
17303
|
+
|
|
17304
|
+
|
|
17305
|
+
|
|
17306
|
+
|
|
17307
|
+
|
|
17308
|
+
|
|
17309
|
+
|
|
17310
|
+
|
|
17311
|
+
|
|
17312
|
+
|
|
17313
|
+
|
|
17314
|
+
|
|
16173
17315
|
|
|
16174
17316
|
|
|
16175
17317
|
|
|
@@ -16352,6 +17494,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16352
17494
|
|
|
16353
17495
|
|
|
16354
17496
|
|
|
17497
|
+
|
|
17498
|
+
|
|
17499
|
+
|
|
17500
|
+
|
|
17501
|
+
|
|
17502
|
+
|
|
17503
|
+
|
|
17504
|
+
|
|
17505
|
+
|
|
17506
|
+
|
|
17507
|
+
|
|
17508
|
+
|
|
17509
|
+
|
|
17510
|
+
|
|
17511
|
+
|
|
17512
|
+
|
|
17513
|
+
|
|
17514
|
+
|
|
17515
|
+
|
|
17516
|
+
|
|
16355
17517
|
|
|
16356
17518
|
|
|
16357
17519
|
|
|
@@ -16503,6 +17665,22 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16503
17665
|
|
|
16504
17666
|
|
|
16505
17667
|
|
|
17668
|
+
|
|
17669
|
+
|
|
17670
|
+
|
|
17671
|
+
|
|
17672
|
+
|
|
17673
|
+
|
|
17674
|
+
|
|
17675
|
+
|
|
17676
|
+
|
|
17677
|
+
|
|
17678
|
+
|
|
17679
|
+
|
|
17680
|
+
|
|
17681
|
+
|
|
17682
|
+
|
|
17683
|
+
|
|
16506
17684
|
|
|
16507
17685
|
|
|
16508
17686
|
|
|
@@ -16649,6 +17827,22 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16649
17827
|
|
|
16650
17828
|
|
|
16651
17829
|
|
|
17830
|
+
|
|
17831
|
+
|
|
17832
|
+
|
|
17833
|
+
|
|
17834
|
+
|
|
17835
|
+
|
|
17836
|
+
|
|
17837
|
+
|
|
17838
|
+
|
|
17839
|
+
|
|
17840
|
+
|
|
17841
|
+
|
|
17842
|
+
|
|
17843
|
+
|
|
17844
|
+
|
|
17845
|
+
|
|
16652
17846
|
|
|
16653
17847
|
|
|
16654
17848
|
|
|
@@ -16824,6 +18018,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16824
18018
|
|
|
16825
18019
|
|
|
16826
18020
|
|
|
18021
|
+
|
|
18022
|
+
|
|
18023
|
+
|
|
18024
|
+
|
|
18025
|
+
|
|
18026
|
+
|
|
18027
|
+
|
|
18028
|
+
|
|
18029
|
+
|
|
18030
|
+
|
|
18031
|
+
|
|
18032
|
+
|
|
18033
|
+
|
|
18034
|
+
|
|
18035
|
+
|
|
18036
|
+
|
|
18037
|
+
|
|
18038
|
+
|
|
18039
|
+
|
|
18040
|
+
|
|
16827
18041
|
|
|
16828
18042
|
|
|
16829
18043
|
|
|
@@ -16994,6 +18208,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16994
18208
|
|
|
16995
18209
|
|
|
16996
18210
|
|
|
18211
|
+
|
|
18212
|
+
|
|
18213
|
+
|
|
18214
|
+
|
|
18215
|
+
|
|
18216
|
+
|
|
18217
|
+
|
|
18218
|
+
|
|
18219
|
+
|
|
18220
|
+
|
|
18221
|
+
|
|
18222
|
+
|
|
18223
|
+
|
|
18224
|
+
|
|
18225
|
+
|
|
18226
|
+
|
|
18227
|
+
|
|
18228
|
+
|
|
18229
|
+
|
|
18230
|
+
|
|
16997
18231
|
|
|
16998
18232
|
|
|
16999
18233
|
|
|
@@ -17169,6 +18403,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17169
18403
|
|
|
17170
18404
|
|
|
17171
18405
|
|
|
18406
|
+
|
|
18407
|
+
|
|
18408
|
+
|
|
18409
|
+
|
|
18410
|
+
|
|
18411
|
+
|
|
18412
|
+
|
|
18413
|
+
|
|
18414
|
+
|
|
18415
|
+
|
|
18416
|
+
|
|
18417
|
+
|
|
18418
|
+
|
|
18419
|
+
|
|
18420
|
+
|
|
18421
|
+
|
|
18422
|
+
|
|
18423
|
+
|
|
18424
|
+
|
|
18425
|
+
|
|
17172
18426
|
|
|
17173
18427
|
|
|
17174
18428
|
|
|
@@ -17346,6 +18600,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17346
18600
|
|
|
17347
18601
|
|
|
17348
18602
|
|
|
18603
|
+
|
|
18604
|
+
|
|
18605
|
+
|
|
18606
|
+
|
|
18607
|
+
|
|
18608
|
+
|
|
18609
|
+
|
|
18610
|
+
|
|
18611
|
+
|
|
18612
|
+
|
|
18613
|
+
|
|
18614
|
+
|
|
18615
|
+
|
|
18616
|
+
|
|
18617
|
+
|
|
18618
|
+
|
|
18619
|
+
|
|
18620
|
+
|
|
18621
|
+
|
|
18622
|
+
|
|
17349
18623
|
|
|
17350
18624
|
|
|
17351
18625
|
|
|
@@ -17521,6 +18795,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17521
18795
|
|
|
17522
18796
|
|
|
17523
18797
|
|
|
18798
|
+
|
|
18799
|
+
|
|
18800
|
+
|
|
18801
|
+
|
|
18802
|
+
|
|
18803
|
+
|
|
18804
|
+
|
|
18805
|
+
|
|
18806
|
+
|
|
18807
|
+
|
|
18808
|
+
|
|
18809
|
+
|
|
18810
|
+
|
|
18811
|
+
|
|
18812
|
+
|
|
18813
|
+
|
|
18814
|
+
|
|
18815
|
+
|
|
18816
|
+
|
|
18817
|
+
|
|
17524
18818
|
|
|
17525
18819
|
|
|
17526
18820
|
|
|
@@ -17689,6 +18983,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17689
18983
|
|
|
17690
18984
|
|
|
17691
18985
|
|
|
18986
|
+
|
|
18987
|
+
|
|
18988
|
+
|
|
18989
|
+
|
|
18990
|
+
|
|
18991
|
+
|
|
18992
|
+
|
|
18993
|
+
|
|
18994
|
+
|
|
18995
|
+
|
|
18996
|
+
|
|
18997
|
+
|
|
18998
|
+
|
|
18999
|
+
|
|
19000
|
+
|
|
19001
|
+
|
|
19002
|
+
|
|
19003
|
+
|
|
19004
|
+
|
|
19005
|
+
|
|
17692
19006
|
|
|
17693
19007
|
|
|
17694
19008
|
|
|
@@ -17835,6 +19149,22 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17835
19149
|
|
|
17836
19150
|
|
|
17837
19151
|
|
|
19152
|
+
|
|
19153
|
+
|
|
19154
|
+
|
|
19155
|
+
|
|
19156
|
+
|
|
19157
|
+
|
|
19158
|
+
|
|
19159
|
+
|
|
19160
|
+
|
|
19161
|
+
|
|
19162
|
+
|
|
19163
|
+
|
|
19164
|
+
|
|
19165
|
+
|
|
19166
|
+
|
|
19167
|
+
|
|
17838
19168
|
|
|
17839
19169
|
|
|
17840
19170
|
|
|
@@ -18055,8 +19385,16 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
18055
19385
|
/**
|
|
18056
19386
|
* Get elements by rank range
|
|
18057
19387
|
|
|
19388
|
+
|
|
19389
|
+
|
|
19390
|
+
|
|
19391
|
+
|
|
19392
|
+
|
|
19393
|
+
|
|
19394
|
+
|
|
19395
|
+
|
|
18058
19396
|
* @example
|
|
18059
|
-
* // Pagination
|
|
19397
|
+
* // Pagination by position in tree order
|
|
18060
19398
|
* const tree = new TreeMultiMap<number>(
|
|
18061
19399
|
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
18062
19400
|
* { enableOrderStatistic: true }
|
|
@@ -18079,6 +19417,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
18079
19417
|
|
|
18080
19418
|
|
|
18081
19419
|
|
|
19420
|
+
|
|
19421
|
+
|
|
19422
|
+
|
|
19423
|
+
|
|
19424
|
+
|
|
19425
|
+
|
|
19426
|
+
|
|
19427
|
+
|
|
19428
|
+
|
|
19429
|
+
|
|
19430
|
+
|
|
19431
|
+
|
|
19432
|
+
|
|
19433
|
+
|
|
19434
|
+
|
|
19435
|
+
|
|
19436
|
+
|
|
19437
|
+
|
|
19438
|
+
|
|
19439
|
+
|
|
18082
19440
|
|
|
18083
19441
|
* @example
|
|
18084
19442
|
* // Deep clone
|
|
@@ -18332,6 +19690,26 @@ var TreeMap = class _TreeMap {
|
|
|
18332
19690
|
|
|
18333
19691
|
|
|
18334
19692
|
|
|
19693
|
+
|
|
19694
|
+
|
|
19695
|
+
|
|
19696
|
+
|
|
19697
|
+
|
|
19698
|
+
|
|
19699
|
+
|
|
19700
|
+
|
|
19701
|
+
|
|
19702
|
+
|
|
19703
|
+
|
|
19704
|
+
|
|
19705
|
+
|
|
19706
|
+
|
|
19707
|
+
|
|
19708
|
+
|
|
19709
|
+
|
|
19710
|
+
|
|
19711
|
+
|
|
19712
|
+
|
|
18335
19713
|
|
|
18336
19714
|
|
|
18337
19715
|
|
|
@@ -18509,6 +19887,26 @@ var TreeMap = class _TreeMap {
|
|
|
18509
19887
|
|
|
18510
19888
|
|
|
18511
19889
|
|
|
19890
|
+
|
|
19891
|
+
|
|
19892
|
+
|
|
19893
|
+
|
|
19894
|
+
|
|
19895
|
+
|
|
19896
|
+
|
|
19897
|
+
|
|
19898
|
+
|
|
19899
|
+
|
|
19900
|
+
|
|
19901
|
+
|
|
19902
|
+
|
|
19903
|
+
|
|
19904
|
+
|
|
19905
|
+
|
|
19906
|
+
|
|
19907
|
+
|
|
19908
|
+
|
|
19909
|
+
|
|
18512
19910
|
|
|
18513
19911
|
|
|
18514
19912
|
|
|
@@ -18556,6 +19954,41 @@ var TreeMap = class _TreeMap {
|
|
|
18556
19954
|
this.#core.set(key, value);
|
|
18557
19955
|
return this;
|
|
18558
19956
|
}
|
|
19957
|
+
/**
|
|
19958
|
+
* Set multiple key-value pairs at once.
|
|
19959
|
+
* @remarks Expected time O(m log n), where m is the number of entries.
|
|
19960
|
+
* @param entries - Iterable of `[key, value]` tuples.
|
|
19961
|
+
* @returns Array of booleans indicating whether each entry was successfully set.
|
|
19962
|
+
|
|
19963
|
+
|
|
19964
|
+
|
|
19965
|
+
|
|
19966
|
+
|
|
19967
|
+
|
|
19968
|
+
|
|
19969
|
+
|
|
19970
|
+
|
|
19971
|
+
|
|
19972
|
+
|
|
19973
|
+
|
|
19974
|
+
|
|
19975
|
+
|
|
19976
|
+
|
|
19977
|
+
|
|
19978
|
+
* @example
|
|
19979
|
+
* // Set multiple key-value pairs
|
|
19980
|
+
* const tm = new TreeMap<number, string>();
|
|
19981
|
+
* tm.setMany([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
19982
|
+
* console.log(tm.size); // 3;
|
|
19983
|
+
*/
|
|
19984
|
+
setMany(entries) {
|
|
19985
|
+
const results = [];
|
|
19986
|
+
for (const [key, value] of entries) {
|
|
19987
|
+
this._validateKey(key);
|
|
19988
|
+
results.push(this.#core.set(key, value));
|
|
19989
|
+
}
|
|
19990
|
+
return results;
|
|
19991
|
+
}
|
|
18559
19992
|
/**
|
|
18560
19993
|
* Get the value under a key.
|
|
18561
19994
|
* @remarks Expected time O(log n)
|
|
@@ -18707,6 +20140,26 @@ var TreeMap = class _TreeMap {
|
|
|
18707
20140
|
|
|
18708
20141
|
|
|
18709
20142
|
|
|
20143
|
+
|
|
20144
|
+
|
|
20145
|
+
|
|
20146
|
+
|
|
20147
|
+
|
|
20148
|
+
|
|
20149
|
+
|
|
20150
|
+
|
|
20151
|
+
|
|
20152
|
+
|
|
20153
|
+
|
|
20154
|
+
|
|
20155
|
+
|
|
20156
|
+
|
|
20157
|
+
|
|
20158
|
+
|
|
20159
|
+
|
|
20160
|
+
|
|
20161
|
+
|
|
20162
|
+
|
|
18710
20163
|
|
|
18711
20164
|
|
|
18712
20165
|
|
|
@@ -18895,6 +20348,26 @@ var TreeMap = class _TreeMap {
|
|
|
18895
20348
|
|
|
18896
20349
|
|
|
18897
20350
|
|
|
20351
|
+
|
|
20352
|
+
|
|
20353
|
+
|
|
20354
|
+
|
|
20355
|
+
|
|
20356
|
+
|
|
20357
|
+
|
|
20358
|
+
|
|
20359
|
+
|
|
20360
|
+
|
|
20361
|
+
|
|
20362
|
+
|
|
20363
|
+
|
|
20364
|
+
|
|
20365
|
+
|
|
20366
|
+
|
|
20367
|
+
|
|
20368
|
+
|
|
20369
|
+
|
|
20370
|
+
|
|
18898
20371
|
|
|
18899
20372
|
|
|
18900
20373
|
|
|
@@ -19083,6 +20556,26 @@ var TreeMap = class _TreeMap {
|
|
|
19083
20556
|
|
|
19084
20557
|
|
|
19085
20558
|
|
|
20559
|
+
|
|
20560
|
+
|
|
20561
|
+
|
|
20562
|
+
|
|
20563
|
+
|
|
20564
|
+
|
|
20565
|
+
|
|
20566
|
+
|
|
20567
|
+
|
|
20568
|
+
|
|
20569
|
+
|
|
20570
|
+
|
|
20571
|
+
|
|
20572
|
+
|
|
20573
|
+
|
|
20574
|
+
|
|
20575
|
+
|
|
20576
|
+
|
|
20577
|
+
|
|
20578
|
+
|
|
19086
20579
|
|
|
19087
20580
|
|
|
19088
20581
|
|
|
@@ -19119,8 +20612,24 @@ var TreeMap = class _TreeMap {
|
|
|
19119
20612
|
*/
|
|
19120
20613
|
delete(key) {
|
|
19121
20614
|
this._validateKey(key);
|
|
19122
|
-
|
|
19123
|
-
|
|
20615
|
+
return this.#core.delete(key);
|
|
20616
|
+
}
|
|
20617
|
+
/**
|
|
20618
|
+
* Delete all entries matching a predicate.
|
|
20619
|
+
* @remarks Time O(N), Space O(N)
|
|
20620
|
+
* @param predicate - Function (key, value, index, map) → boolean; return true to delete.
|
|
20621
|
+
* @returns True if at least one entry was deleted.
|
|
20622
|
+
*/
|
|
20623
|
+
deleteWhere(predicate) {
|
|
20624
|
+
let deleted = false;
|
|
20625
|
+
let index = 0;
|
|
20626
|
+
for (const [key, value] of this) {
|
|
20627
|
+
if (predicate(key, value, index++, this)) {
|
|
20628
|
+
this.delete(key);
|
|
20629
|
+
deleted = true;
|
|
20630
|
+
}
|
|
20631
|
+
}
|
|
20632
|
+
return deleted;
|
|
19124
20633
|
}
|
|
19125
20634
|
/**
|
|
19126
20635
|
* Remove all entries.
|
|
@@ -19261,6 +20770,26 @@ var TreeMap = class _TreeMap {
|
|
|
19261
20770
|
|
|
19262
20771
|
|
|
19263
20772
|
|
|
20773
|
+
|
|
20774
|
+
|
|
20775
|
+
|
|
20776
|
+
|
|
20777
|
+
|
|
20778
|
+
|
|
20779
|
+
|
|
20780
|
+
|
|
20781
|
+
|
|
20782
|
+
|
|
20783
|
+
|
|
20784
|
+
|
|
20785
|
+
|
|
20786
|
+
|
|
20787
|
+
|
|
20788
|
+
|
|
20789
|
+
|
|
20790
|
+
|
|
20791
|
+
|
|
20792
|
+
|
|
19264
20793
|
|
|
19265
20794
|
|
|
19266
20795
|
|
|
@@ -19430,6 +20959,26 @@ var TreeMap = class _TreeMap {
|
|
|
19430
20959
|
|
|
19431
20960
|
|
|
19432
20961
|
|
|
20962
|
+
|
|
20963
|
+
|
|
20964
|
+
|
|
20965
|
+
|
|
20966
|
+
|
|
20967
|
+
|
|
20968
|
+
|
|
20969
|
+
|
|
20970
|
+
|
|
20971
|
+
|
|
20972
|
+
|
|
20973
|
+
|
|
20974
|
+
|
|
20975
|
+
|
|
20976
|
+
|
|
20977
|
+
|
|
20978
|
+
|
|
20979
|
+
|
|
20980
|
+
|
|
20981
|
+
|
|
19433
20982
|
|
|
19434
20983
|
|
|
19435
20984
|
|
|
@@ -19603,6 +21152,26 @@ var TreeMap = class _TreeMap {
|
|
|
19603
21152
|
|
|
19604
21153
|
|
|
19605
21154
|
|
|
21155
|
+
|
|
21156
|
+
|
|
21157
|
+
|
|
21158
|
+
|
|
21159
|
+
|
|
21160
|
+
|
|
21161
|
+
|
|
21162
|
+
|
|
21163
|
+
|
|
21164
|
+
|
|
21165
|
+
|
|
21166
|
+
|
|
21167
|
+
|
|
21168
|
+
|
|
21169
|
+
|
|
21170
|
+
|
|
21171
|
+
|
|
21172
|
+
|
|
21173
|
+
|
|
21174
|
+
|
|
19606
21175
|
|
|
19607
21176
|
|
|
19608
21177
|
|
|
@@ -19773,6 +21342,26 @@ var TreeMap = class _TreeMap {
|
|
|
19773
21342
|
|
|
19774
21343
|
|
|
19775
21344
|
|
|
21345
|
+
|
|
21346
|
+
|
|
21347
|
+
|
|
21348
|
+
|
|
21349
|
+
|
|
21350
|
+
|
|
21351
|
+
|
|
21352
|
+
|
|
21353
|
+
|
|
21354
|
+
|
|
21355
|
+
|
|
21356
|
+
|
|
21357
|
+
|
|
21358
|
+
|
|
21359
|
+
|
|
21360
|
+
|
|
21361
|
+
|
|
21362
|
+
|
|
21363
|
+
|
|
21364
|
+
|
|
19776
21365
|
|
|
19777
21366
|
|
|
19778
21367
|
|
|
@@ -19946,6 +21535,26 @@ var TreeMap = class _TreeMap {
|
|
|
19946
21535
|
|
|
19947
21536
|
|
|
19948
21537
|
|
|
21538
|
+
|
|
21539
|
+
|
|
21540
|
+
|
|
21541
|
+
|
|
21542
|
+
|
|
21543
|
+
|
|
21544
|
+
|
|
21545
|
+
|
|
21546
|
+
|
|
21547
|
+
|
|
21548
|
+
|
|
21549
|
+
|
|
21550
|
+
|
|
21551
|
+
|
|
21552
|
+
|
|
21553
|
+
|
|
21554
|
+
|
|
21555
|
+
|
|
21556
|
+
|
|
21557
|
+
|
|
19949
21558
|
|
|
19950
21559
|
|
|
19951
21560
|
|
|
@@ -20119,6 +21728,26 @@ var TreeMap = class _TreeMap {
|
|
|
20119
21728
|
|
|
20120
21729
|
|
|
20121
21730
|
|
|
21731
|
+
|
|
21732
|
+
|
|
21733
|
+
|
|
21734
|
+
|
|
21735
|
+
|
|
21736
|
+
|
|
21737
|
+
|
|
21738
|
+
|
|
21739
|
+
|
|
21740
|
+
|
|
21741
|
+
|
|
21742
|
+
|
|
21743
|
+
|
|
21744
|
+
|
|
21745
|
+
|
|
21746
|
+
|
|
21747
|
+
|
|
21748
|
+
|
|
21749
|
+
|
|
21750
|
+
|
|
20122
21751
|
|
|
20123
21752
|
|
|
20124
21753
|
|
|
@@ -20295,6 +21924,26 @@ var TreeMap = class _TreeMap {
|
|
|
20295
21924
|
|
|
20296
21925
|
|
|
20297
21926
|
|
|
21927
|
+
|
|
21928
|
+
|
|
21929
|
+
|
|
21930
|
+
|
|
21931
|
+
|
|
21932
|
+
|
|
21933
|
+
|
|
21934
|
+
|
|
21935
|
+
|
|
21936
|
+
|
|
21937
|
+
|
|
21938
|
+
|
|
21939
|
+
|
|
21940
|
+
|
|
21941
|
+
|
|
21942
|
+
|
|
21943
|
+
|
|
21944
|
+
|
|
21945
|
+
|
|
21946
|
+
|
|
20298
21947
|
|
|
20299
21948
|
|
|
20300
21949
|
|
|
@@ -20471,6 +22120,26 @@ var TreeMap = class _TreeMap {
|
|
|
20471
22120
|
|
|
20472
22121
|
|
|
20473
22122
|
|
|
22123
|
+
|
|
22124
|
+
|
|
22125
|
+
|
|
22126
|
+
|
|
22127
|
+
|
|
22128
|
+
|
|
22129
|
+
|
|
22130
|
+
|
|
22131
|
+
|
|
22132
|
+
|
|
22133
|
+
|
|
22134
|
+
|
|
22135
|
+
|
|
22136
|
+
|
|
22137
|
+
|
|
22138
|
+
|
|
22139
|
+
|
|
22140
|
+
|
|
22141
|
+
|
|
22142
|
+
|
|
20474
22143
|
|
|
20475
22144
|
|
|
20476
22145
|
|
|
@@ -20641,6 +22310,26 @@ var TreeMap = class _TreeMap {
|
|
|
20641
22310
|
|
|
20642
22311
|
|
|
20643
22312
|
|
|
22313
|
+
|
|
22314
|
+
|
|
22315
|
+
|
|
22316
|
+
|
|
22317
|
+
|
|
22318
|
+
|
|
22319
|
+
|
|
22320
|
+
|
|
22321
|
+
|
|
22322
|
+
|
|
22323
|
+
|
|
22324
|
+
|
|
22325
|
+
|
|
22326
|
+
|
|
22327
|
+
|
|
22328
|
+
|
|
22329
|
+
|
|
22330
|
+
|
|
22331
|
+
|
|
22332
|
+
|
|
20644
22333
|
|
|
20645
22334
|
|
|
20646
22335
|
|
|
@@ -20813,6 +22502,26 @@ var TreeMap = class _TreeMap {
|
|
|
20813
22502
|
|
|
20814
22503
|
|
|
20815
22504
|
|
|
22505
|
+
|
|
22506
|
+
|
|
22507
|
+
|
|
22508
|
+
|
|
22509
|
+
|
|
22510
|
+
|
|
22511
|
+
|
|
22512
|
+
|
|
22513
|
+
|
|
22514
|
+
|
|
22515
|
+
|
|
22516
|
+
|
|
22517
|
+
|
|
22518
|
+
|
|
22519
|
+
|
|
22520
|
+
|
|
22521
|
+
|
|
22522
|
+
|
|
22523
|
+
|
|
22524
|
+
|
|
20816
22525
|
|
|
20817
22526
|
|
|
20818
22527
|
|
|
@@ -20986,6 +22695,26 @@ var TreeMap = class _TreeMap {
|
|
|
20986
22695
|
|
|
20987
22696
|
|
|
20988
22697
|
|
|
22698
|
+
|
|
22699
|
+
|
|
22700
|
+
|
|
22701
|
+
|
|
22702
|
+
|
|
22703
|
+
|
|
22704
|
+
|
|
22705
|
+
|
|
22706
|
+
|
|
22707
|
+
|
|
22708
|
+
|
|
22709
|
+
|
|
22710
|
+
|
|
22711
|
+
|
|
22712
|
+
|
|
22713
|
+
|
|
22714
|
+
|
|
22715
|
+
|
|
22716
|
+
|
|
22717
|
+
|
|
20989
22718
|
|
|
20990
22719
|
|
|
20991
22720
|
|
|
@@ -21160,6 +22889,26 @@ var TreeMap = class _TreeMap {
|
|
|
21160
22889
|
|
|
21161
22890
|
|
|
21162
22891
|
|
|
22892
|
+
|
|
22893
|
+
|
|
22894
|
+
|
|
22895
|
+
|
|
22896
|
+
|
|
22897
|
+
|
|
22898
|
+
|
|
22899
|
+
|
|
22900
|
+
|
|
22901
|
+
|
|
22902
|
+
|
|
22903
|
+
|
|
22904
|
+
|
|
22905
|
+
|
|
22906
|
+
|
|
22907
|
+
|
|
22908
|
+
|
|
22909
|
+
|
|
22910
|
+
|
|
22911
|
+
|
|
21163
22912
|
|
|
21164
22913
|
|
|
21165
22914
|
|
|
@@ -21329,6 +23078,26 @@ var TreeMap = class _TreeMap {
|
|
|
21329
23078
|
|
|
21330
23079
|
|
|
21331
23080
|
|
|
23081
|
+
|
|
23082
|
+
|
|
23083
|
+
|
|
23084
|
+
|
|
23085
|
+
|
|
23086
|
+
|
|
23087
|
+
|
|
23088
|
+
|
|
23089
|
+
|
|
23090
|
+
|
|
23091
|
+
|
|
23092
|
+
|
|
23093
|
+
|
|
23094
|
+
|
|
23095
|
+
|
|
23096
|
+
|
|
23097
|
+
|
|
23098
|
+
|
|
23099
|
+
|
|
23100
|
+
|
|
21332
23101
|
|
|
21333
23102
|
|
|
21334
23103
|
|
|
@@ -21392,6 +23161,10 @@ var TreeMap = class _TreeMap {
|
|
|
21392
23161
|
|
|
21393
23162
|
|
|
21394
23163
|
|
|
23164
|
+
|
|
23165
|
+
|
|
23166
|
+
|
|
23167
|
+
|
|
21395
23168
|
|
|
21396
23169
|
|
|
21397
23170
|
|
|
@@ -21460,6 +23233,10 @@ var TreeMap = class _TreeMap {
|
|
|
21460
23233
|
|
|
21461
23234
|
|
|
21462
23235
|
|
|
23236
|
+
|
|
23237
|
+
|
|
23238
|
+
|
|
23239
|
+
|
|
21463
23240
|
|
|
21464
23241
|
|
|
21465
23242
|
|
|
@@ -21512,6 +23289,10 @@ var TreeMap = class _TreeMap {
|
|
|
21512
23289
|
|
|
21513
23290
|
|
|
21514
23291
|
|
|
23292
|
+
|
|
23293
|
+
|
|
23294
|
+
|
|
23295
|
+
|
|
21515
23296
|
|
|
21516
23297
|
|
|
21517
23298
|
|
|
@@ -21568,6 +23349,10 @@ var TreeMap = class _TreeMap {
|
|
|
21568
23349
|
|
|
21569
23350
|
|
|
21570
23351
|
|
|
23352
|
+
|
|
23353
|
+
|
|
23354
|
+
|
|
23355
|
+
|
|
21571
23356
|
|
|
21572
23357
|
|
|
21573
23358
|
|
|
@@ -21711,6 +23496,22 @@ var TreeMap = class _TreeMap {
|
|
|
21711
23496
|
|
|
21712
23497
|
|
|
21713
23498
|
|
|
23499
|
+
|
|
23500
|
+
|
|
23501
|
+
|
|
23502
|
+
|
|
23503
|
+
|
|
23504
|
+
|
|
23505
|
+
|
|
23506
|
+
|
|
23507
|
+
|
|
23508
|
+
|
|
23509
|
+
|
|
23510
|
+
|
|
23511
|
+
|
|
23512
|
+
|
|
23513
|
+
|
|
23514
|
+
|
|
21714
23515
|
|
|
21715
23516
|
|
|
21716
23517
|
|
|
@@ -21884,6 +23685,22 @@ var TreeMap = class _TreeMap {
|
|
|
21884
23685
|
|
|
21885
23686
|
|
|
21886
23687
|
|
|
23688
|
+
|
|
23689
|
+
|
|
23690
|
+
|
|
23691
|
+
|
|
23692
|
+
|
|
23693
|
+
|
|
23694
|
+
|
|
23695
|
+
|
|
23696
|
+
|
|
23697
|
+
|
|
23698
|
+
|
|
23699
|
+
|
|
23700
|
+
|
|
23701
|
+
|
|
23702
|
+
|
|
23703
|
+
|
|
21887
23704
|
|
|
21888
23705
|
|
|
21889
23706
|
|
|
@@ -22041,6 +23858,22 @@ var TreeMap = class _TreeMap {
|
|
|
22041
23858
|
|
|
22042
23859
|
|
|
22043
23860
|
|
|
23861
|
+
|
|
23862
|
+
|
|
23863
|
+
|
|
23864
|
+
|
|
23865
|
+
|
|
23866
|
+
|
|
23867
|
+
|
|
23868
|
+
|
|
23869
|
+
|
|
23870
|
+
|
|
23871
|
+
|
|
23872
|
+
|
|
23873
|
+
|
|
23874
|
+
|
|
23875
|
+
|
|
23876
|
+
|
|
22044
23877
|
|
|
22045
23878
|
|
|
22046
23879
|
|
|
@@ -22198,6 +24031,22 @@ var TreeMap = class _TreeMap {
|
|
|
22198
24031
|
|
|
22199
24032
|
|
|
22200
24033
|
|
|
24034
|
+
|
|
24035
|
+
|
|
24036
|
+
|
|
24037
|
+
|
|
24038
|
+
|
|
24039
|
+
|
|
24040
|
+
|
|
24041
|
+
|
|
24042
|
+
|
|
24043
|
+
|
|
24044
|
+
|
|
24045
|
+
|
|
24046
|
+
|
|
24047
|
+
|
|
24048
|
+
|
|
24049
|
+
|
|
22201
24050
|
|
|
22202
24051
|
|
|
22203
24052
|
|
|
@@ -22356,6 +24205,22 @@ var TreeMap = class _TreeMap {
|
|
|
22356
24205
|
|
|
22357
24206
|
|
|
22358
24207
|
|
|
24208
|
+
|
|
24209
|
+
|
|
24210
|
+
|
|
24211
|
+
|
|
24212
|
+
|
|
24213
|
+
|
|
24214
|
+
|
|
24215
|
+
|
|
24216
|
+
|
|
24217
|
+
|
|
24218
|
+
|
|
24219
|
+
|
|
24220
|
+
|
|
24221
|
+
|
|
24222
|
+
|
|
24223
|
+
|
|
22359
24224
|
|
|
22360
24225
|
|
|
22361
24226
|
|
|
@@ -22463,8 +24328,16 @@ var TreeMap = class _TreeMap {
|
|
|
22463
24328
|
* Returns keys by rank range (0-indexed, inclusive on both ends).
|
|
22464
24329
|
* @remarks Time O(log n + k). Requires `enableOrderStatistic: true`.
|
|
22465
24330
|
|
|
24331
|
+
|
|
24332
|
+
|
|
24333
|
+
|
|
24334
|
+
|
|
24335
|
+
|
|
24336
|
+
|
|
24337
|
+
|
|
24338
|
+
|
|
22466
24339
|
* @example
|
|
22467
|
-
* // Pagination
|
|
24340
|
+
* // Pagination by position in tree order
|
|
22468
24341
|
* const tree = new TreeMap<number>(
|
|
22469
24342
|
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
22470
24343
|
* { enableOrderStatistic: true }
|
|
@@ -22623,6 +24496,26 @@ var TreeMap = class _TreeMap {
|
|
|
22623
24496
|
|
|
22624
24497
|
|
|
22625
24498
|
|
|
24499
|
+
|
|
24500
|
+
|
|
24501
|
+
|
|
24502
|
+
|
|
24503
|
+
|
|
24504
|
+
|
|
24505
|
+
|
|
24506
|
+
|
|
24507
|
+
|
|
24508
|
+
|
|
24509
|
+
|
|
24510
|
+
|
|
24511
|
+
|
|
24512
|
+
|
|
24513
|
+
|
|
24514
|
+
|
|
24515
|
+
|
|
24516
|
+
|
|
24517
|
+
|
|
24518
|
+
|
|
22626
24519
|
|
|
22627
24520
|
|
|
22628
24521
|
|
|
@@ -22746,6 +24639,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
22746
24639
|
|
|
22747
24640
|
|
|
22748
24641
|
|
|
24642
|
+
|
|
24643
|
+
|
|
24644
|
+
|
|
24645
|
+
|
|
22749
24646
|
|
|
22750
24647
|
|
|
22751
24648
|
|
|
@@ -22901,6 +24798,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
22901
24798
|
|
|
22902
24799
|
|
|
22903
24800
|
|
|
24801
|
+
|
|
24802
|
+
|
|
24803
|
+
|
|
24804
|
+
|
|
24805
|
+
|
|
24806
|
+
|
|
24807
|
+
|
|
24808
|
+
|
|
24809
|
+
|
|
24810
|
+
|
|
24811
|
+
|
|
24812
|
+
|
|
24813
|
+
|
|
24814
|
+
|
|
24815
|
+
|
|
24816
|
+
|
|
24817
|
+
|
|
24818
|
+
|
|
24819
|
+
|
|
24820
|
+
|
|
22904
24821
|
|
|
22905
24822
|
|
|
22906
24823
|
|
|
@@ -23072,6 +24989,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23072
24989
|
|
|
23073
24990
|
|
|
23074
24991
|
|
|
24992
|
+
|
|
24993
|
+
|
|
24994
|
+
|
|
24995
|
+
|
|
24996
|
+
|
|
24997
|
+
|
|
24998
|
+
|
|
24999
|
+
|
|
25000
|
+
|
|
25001
|
+
|
|
25002
|
+
|
|
25003
|
+
|
|
25004
|
+
|
|
25005
|
+
|
|
25006
|
+
|
|
25007
|
+
|
|
25008
|
+
|
|
25009
|
+
|
|
25010
|
+
|
|
25011
|
+
|
|
23075
25012
|
|
|
23076
25013
|
|
|
23077
25014
|
|
|
@@ -23128,6 +25065,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23128
25065
|
|
|
23129
25066
|
|
|
23130
25067
|
|
|
25068
|
+
|
|
25069
|
+
|
|
25070
|
+
|
|
25071
|
+
|
|
23131
25072
|
|
|
23132
25073
|
|
|
23133
25074
|
|
|
@@ -23278,6 +25219,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23278
25219
|
|
|
23279
25220
|
|
|
23280
25221
|
|
|
25222
|
+
|
|
25223
|
+
|
|
25224
|
+
|
|
25225
|
+
|
|
25226
|
+
|
|
25227
|
+
|
|
25228
|
+
|
|
25229
|
+
|
|
25230
|
+
|
|
25231
|
+
|
|
25232
|
+
|
|
25233
|
+
|
|
25234
|
+
|
|
25235
|
+
|
|
25236
|
+
|
|
25237
|
+
|
|
25238
|
+
|
|
25239
|
+
|
|
25240
|
+
|
|
25241
|
+
|
|
23281
25242
|
|
|
23282
25243
|
|
|
23283
25244
|
|
|
@@ -23343,6 +25304,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23343
25304
|
|
|
23344
25305
|
|
|
23345
25306
|
|
|
25307
|
+
|
|
25308
|
+
|
|
25309
|
+
|
|
25310
|
+
|
|
23346
25311
|
|
|
23347
25312
|
|
|
23348
25313
|
|
|
@@ -23511,6 +25476,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23511
25476
|
|
|
23512
25477
|
|
|
23513
25478
|
|
|
25479
|
+
|
|
25480
|
+
|
|
25481
|
+
|
|
25482
|
+
|
|
25483
|
+
|
|
25484
|
+
|
|
25485
|
+
|
|
25486
|
+
|
|
25487
|
+
|
|
25488
|
+
|
|
25489
|
+
|
|
25490
|
+
|
|
25491
|
+
|
|
25492
|
+
|
|
25493
|
+
|
|
25494
|
+
|
|
25495
|
+
|
|
25496
|
+
|
|
25497
|
+
|
|
25498
|
+
|
|
23514
25499
|
|
|
23515
25500
|
|
|
23516
25501
|
|
|
@@ -23577,6 +25562,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23577
25562
|
|
|
23578
25563
|
|
|
23579
25564
|
|
|
25565
|
+
|
|
25566
|
+
|
|
25567
|
+
|
|
25568
|
+
|
|
23580
25569
|
|
|
23581
25570
|
|
|
23582
25571
|
|
|
@@ -23621,6 +25610,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23621
25610
|
|
|
23622
25611
|
|
|
23623
25612
|
|
|
25613
|
+
|
|
25614
|
+
|
|
25615
|
+
|
|
25616
|
+
|
|
23624
25617
|
|
|
23625
25618
|
|
|
23626
25619
|
|
|
@@ -23776,6 +25769,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23776
25769
|
|
|
23777
25770
|
|
|
23778
25771
|
|
|
25772
|
+
|
|
25773
|
+
|
|
25774
|
+
|
|
25775
|
+
|
|
25776
|
+
|
|
25777
|
+
|
|
25778
|
+
|
|
25779
|
+
|
|
25780
|
+
|
|
25781
|
+
|
|
25782
|
+
|
|
25783
|
+
|
|
25784
|
+
|
|
25785
|
+
|
|
25786
|
+
|
|
25787
|
+
|
|
25788
|
+
|
|
25789
|
+
|
|
25790
|
+
|
|
25791
|
+
|
|
23779
25792
|
|
|
23780
25793
|
|
|
23781
25794
|
|
|
@@ -23957,6 +25970,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23957
25970
|
|
|
23958
25971
|
|
|
23959
25972
|
|
|
25973
|
+
|
|
25974
|
+
|
|
25975
|
+
|
|
25976
|
+
|
|
25977
|
+
|
|
25978
|
+
|
|
25979
|
+
|
|
25980
|
+
|
|
25981
|
+
|
|
25982
|
+
|
|
25983
|
+
|
|
25984
|
+
|
|
25985
|
+
|
|
25986
|
+
|
|
25987
|
+
|
|
25988
|
+
|
|
25989
|
+
|
|
25990
|
+
|
|
25991
|
+
|
|
25992
|
+
|
|
23960
25993
|
|
|
23961
25994
|
|
|
23962
25995
|
|
|
@@ -24012,6 +26045,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24012
26045
|
|
|
24013
26046
|
|
|
24014
26047
|
|
|
26048
|
+
|
|
26049
|
+
|
|
26050
|
+
|
|
26051
|
+
|
|
24015
26052
|
|
|
24016
26053
|
|
|
24017
26054
|
|
|
@@ -24051,6 +26088,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24051
26088
|
|
|
24052
26089
|
|
|
24053
26090
|
|
|
26091
|
+
|
|
26092
|
+
|
|
26093
|
+
|
|
26094
|
+
|
|
24054
26095
|
|
|
24055
26096
|
|
|
24056
26097
|
|
|
@@ -24215,6 +26256,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24215
26256
|
|
|
24216
26257
|
|
|
24217
26258
|
|
|
26259
|
+
|
|
26260
|
+
|
|
26261
|
+
|
|
26262
|
+
|
|
26263
|
+
|
|
26264
|
+
|
|
26265
|
+
|
|
26266
|
+
|
|
26267
|
+
|
|
26268
|
+
|
|
26269
|
+
|
|
26270
|
+
|
|
26271
|
+
|
|
26272
|
+
|
|
26273
|
+
|
|
26274
|
+
|
|
26275
|
+
|
|
26276
|
+
|
|
26277
|
+
|
|
26278
|
+
|
|
24218
26279
|
|
|
24219
26280
|
|
|
24220
26281
|
|
|
@@ -24273,6 +26334,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24273
26334
|
|
|
24274
26335
|
|
|
24275
26336
|
|
|
26337
|
+
|
|
26338
|
+
|
|
26339
|
+
|
|
26340
|
+
|
|
24276
26341
|
|
|
24277
26342
|
|
|
24278
26343
|
|
|
@@ -24313,6 +26378,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24313
26378
|
|
|
24314
26379
|
|
|
24315
26380
|
|
|
26381
|
+
|
|
26382
|
+
|
|
26383
|
+
|
|
26384
|
+
|
|
24316
26385
|
|
|
24317
26386
|
|
|
24318
26387
|
|
|
@@ -24353,6 +26422,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24353
26422
|
|
|
24354
26423
|
|
|
24355
26424
|
|
|
26425
|
+
|
|
26426
|
+
|
|
26427
|
+
|
|
26428
|
+
|
|
24356
26429
|
|
|
24357
26430
|
|
|
24358
26431
|
|
|
@@ -24397,6 +26470,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24397
26470
|
|
|
24398
26471
|
|
|
24399
26472
|
|
|
26473
|
+
|
|
26474
|
+
|
|
26475
|
+
|
|
26476
|
+
|
|
24400
26477
|
|
|
24401
26478
|
|
|
24402
26479
|
|
|
@@ -24527,6 +26604,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24527
26604
|
|
|
24528
26605
|
|
|
24529
26606
|
|
|
26607
|
+
|
|
26608
|
+
|
|
26609
|
+
|
|
26610
|
+
|
|
26611
|
+
|
|
26612
|
+
|
|
26613
|
+
|
|
26614
|
+
|
|
26615
|
+
|
|
26616
|
+
|
|
26617
|
+
|
|
26618
|
+
|
|
26619
|
+
|
|
26620
|
+
|
|
26621
|
+
|
|
26622
|
+
|
|
24530
26623
|
|
|
24531
26624
|
|
|
24532
26625
|
|
|
@@ -24668,6 +26761,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24668
26761
|
|
|
24669
26762
|
|
|
24670
26763
|
|
|
26764
|
+
|
|
26765
|
+
|
|
26766
|
+
|
|
26767
|
+
|
|
26768
|
+
|
|
26769
|
+
|
|
26770
|
+
|
|
26771
|
+
|
|
26772
|
+
|
|
26773
|
+
|
|
26774
|
+
|
|
26775
|
+
|
|
26776
|
+
|
|
26777
|
+
|
|
26778
|
+
|
|
26779
|
+
|
|
24671
26780
|
|
|
24672
26781
|
|
|
24673
26782
|
|
|
@@ -24809,6 +26918,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24809
26918
|
|
|
24810
26919
|
|
|
24811
26920
|
|
|
26921
|
+
|
|
26922
|
+
|
|
26923
|
+
|
|
26924
|
+
|
|
26925
|
+
|
|
26926
|
+
|
|
26927
|
+
|
|
26928
|
+
|
|
26929
|
+
|
|
26930
|
+
|
|
26931
|
+
|
|
26932
|
+
|
|
26933
|
+
|
|
26934
|
+
|
|
26935
|
+
|
|
26936
|
+
|
|
24812
26937
|
|
|
24813
26938
|
|
|
24814
26939
|
|
|
@@ -24949,6 +27074,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24949
27074
|
|
|
24950
27075
|
|
|
24951
27076
|
|
|
27077
|
+
|
|
27078
|
+
|
|
27079
|
+
|
|
27080
|
+
|
|
27081
|
+
|
|
27082
|
+
|
|
27083
|
+
|
|
27084
|
+
|
|
27085
|
+
|
|
27086
|
+
|
|
27087
|
+
|
|
27088
|
+
|
|
27089
|
+
|
|
27090
|
+
|
|
27091
|
+
|
|
27092
|
+
|
|
24952
27093
|
|
|
24953
27094
|
|
|
24954
27095
|
|
|
@@ -25119,6 +27260,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25119
27260
|
|
|
25120
27261
|
|
|
25121
27262
|
|
|
27263
|
+
|
|
27264
|
+
|
|
27265
|
+
|
|
27266
|
+
|
|
27267
|
+
|
|
27268
|
+
|
|
27269
|
+
|
|
27270
|
+
|
|
27271
|
+
|
|
27272
|
+
|
|
27273
|
+
|
|
27274
|
+
|
|
27275
|
+
|
|
27276
|
+
|
|
27277
|
+
|
|
27278
|
+
|
|
27279
|
+
|
|
27280
|
+
|
|
27281
|
+
|
|
27282
|
+
|
|
25122
27283
|
|
|
25123
27284
|
|
|
25124
27285
|
|
|
@@ -25295,6 +27456,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25295
27456
|
|
|
25296
27457
|
|
|
25297
27458
|
|
|
27459
|
+
|
|
27460
|
+
|
|
27461
|
+
|
|
27462
|
+
|
|
27463
|
+
|
|
27464
|
+
|
|
27465
|
+
|
|
27466
|
+
|
|
27467
|
+
|
|
27468
|
+
|
|
27469
|
+
|
|
27470
|
+
|
|
27471
|
+
|
|
27472
|
+
|
|
27473
|
+
|
|
27474
|
+
|
|
27475
|
+
|
|
27476
|
+
|
|
27477
|
+
|
|
27478
|
+
|
|
25298
27479
|
|
|
25299
27480
|
|
|
25300
27481
|
|
|
@@ -25478,6 +27659,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25478
27659
|
|
|
25479
27660
|
|
|
25480
27661
|
|
|
27662
|
+
|
|
27663
|
+
|
|
27664
|
+
|
|
27665
|
+
|
|
27666
|
+
|
|
27667
|
+
|
|
27668
|
+
|
|
27669
|
+
|
|
27670
|
+
|
|
27671
|
+
|
|
27672
|
+
|
|
27673
|
+
|
|
27674
|
+
|
|
27675
|
+
|
|
27676
|
+
|
|
27677
|
+
|
|
27678
|
+
|
|
27679
|
+
|
|
27680
|
+
|
|
27681
|
+
|
|
25481
27682
|
|
|
25482
27683
|
|
|
25483
27684
|
|
|
@@ -25656,6 +27857,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25656
27857
|
|
|
25657
27858
|
|
|
25658
27859
|
|
|
27860
|
+
|
|
27861
|
+
|
|
27862
|
+
|
|
27863
|
+
|
|
27864
|
+
|
|
27865
|
+
|
|
27866
|
+
|
|
27867
|
+
|
|
27868
|
+
|
|
27869
|
+
|
|
27870
|
+
|
|
27871
|
+
|
|
27872
|
+
|
|
27873
|
+
|
|
27874
|
+
|
|
27875
|
+
|
|
27876
|
+
|
|
27877
|
+
|
|
27878
|
+
|
|
27879
|
+
|
|
25659
27880
|
|
|
25660
27881
|
|
|
25661
27882
|
|
|
@@ -25886,8 +28107,16 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25886
28107
|
/**
|
|
25887
28108
|
* Get elements by rank range
|
|
25888
28109
|
|
|
28110
|
+
|
|
28111
|
+
|
|
28112
|
+
|
|
28113
|
+
|
|
28114
|
+
|
|
28115
|
+
|
|
28116
|
+
|
|
28117
|
+
|
|
25889
28118
|
* @example
|
|
25890
|
-
* // Pagination
|
|
28119
|
+
* // Pagination by position in tree order
|
|
25891
28120
|
* const tree = new TreeMultiSet<number>(
|
|
25892
28121
|
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
25893
28122
|
* { enableOrderStatistic: true }
|
|
@@ -25909,6 +28138,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25909
28138
|
|
|
25910
28139
|
|
|
25911
28140
|
|
|
28141
|
+
|
|
28142
|
+
|
|
28143
|
+
|
|
28144
|
+
|
|
28145
|
+
|
|
28146
|
+
|
|
28147
|
+
|
|
28148
|
+
|
|
28149
|
+
|
|
28150
|
+
|
|
28151
|
+
|
|
28152
|
+
|
|
28153
|
+
|
|
28154
|
+
|
|
28155
|
+
|
|
28156
|
+
|
|
28157
|
+
|
|
28158
|
+
|
|
28159
|
+
|
|
28160
|
+
|
|
25912
28161
|
|
|
25913
28162
|
* @example
|
|
25914
28163
|
* // Deep clone
|
|
@@ -26041,6 +28290,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
26041
28290
|
|
|
26042
28291
|
|
|
26043
28292
|
|
|
28293
|
+
|
|
28294
|
+
|
|
28295
|
+
|
|
28296
|
+
|
|
28297
|
+
|
|
28298
|
+
|
|
28299
|
+
|
|
28300
|
+
|
|
28301
|
+
|
|
28302
|
+
|
|
28303
|
+
|
|
28304
|
+
|
|
28305
|
+
|
|
28306
|
+
|
|
28307
|
+
|
|
28308
|
+
|
|
26044
28309
|
|
|
26045
28310
|
|
|
26046
28311
|
|
|
@@ -26212,6 +28477,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
26212
28477
|
|
|
26213
28478
|
|
|
26214
28479
|
|
|
28480
|
+
|
|
28481
|
+
|
|
28482
|
+
|
|
28483
|
+
|
|
28484
|
+
|
|
28485
|
+
|
|
28486
|
+
|
|
28487
|
+
|
|
28488
|
+
|
|
28489
|
+
|
|
28490
|
+
|
|
28491
|
+
|
|
28492
|
+
|
|
28493
|
+
|
|
28494
|
+
|
|
28495
|
+
|
|
28496
|
+
|
|
28497
|
+
|
|
28498
|
+
|
|
28499
|
+
|
|
26215
28500
|
|
|
26216
28501
|
|
|
26217
28502
|
|