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/esm/binary-tree.mjs
CHANGED
|
@@ -795,6 +795,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
795
795
|
|
|
796
796
|
|
|
797
797
|
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
|
|
798
802
|
|
|
799
803
|
|
|
800
804
|
|
|
@@ -845,6 +849,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
845
849
|
|
|
846
850
|
|
|
847
851
|
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
|
|
848
856
|
|
|
849
857
|
|
|
850
858
|
|
|
@@ -859,6 +867,14 @@ var Queue = class _Queue extends LinearBase {
|
|
|
859
867
|
get first() {
|
|
860
868
|
return this.length > 0 ? this.elements[this._offset] : void 0;
|
|
861
869
|
}
|
|
870
|
+
/**
|
|
871
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
872
|
+
* @remarks Time O(1), Space O(1)
|
|
873
|
+
* @returns Front element or undefined.
|
|
874
|
+
*/
|
|
875
|
+
peek() {
|
|
876
|
+
return this.first;
|
|
877
|
+
}
|
|
862
878
|
/**
|
|
863
879
|
* Get the last element (back) without removing it.
|
|
864
880
|
* @remarks Time O(1), Space O(1)
|
|
@@ -911,6 +927,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
911
927
|
|
|
912
928
|
|
|
913
929
|
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
914
934
|
|
|
915
935
|
|
|
916
936
|
|
|
@@ -973,6 +993,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
973
993
|
|
|
974
994
|
|
|
975
995
|
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
|
|
976
1000
|
|
|
977
1001
|
|
|
978
1002
|
|
|
@@ -1042,6 +1066,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1042
1066
|
|
|
1043
1067
|
|
|
1044
1068
|
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1045
1073
|
|
|
1046
1074
|
|
|
1047
1075
|
|
|
@@ -1101,6 +1129,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1101
1129
|
|
|
1102
1130
|
|
|
1103
1131
|
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
1104
1136
|
|
|
1105
1137
|
|
|
1106
1138
|
|
|
@@ -1153,6 +1185,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1153
1185
|
|
|
1154
1186
|
|
|
1155
1187
|
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1156
1192
|
|
|
1157
1193
|
|
|
1158
1194
|
|
|
@@ -1204,6 +1240,21 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1204
1240
|
this._elements[this._offset + index] = newElement;
|
|
1205
1241
|
return true;
|
|
1206
1242
|
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Delete the first element that satisfies a predicate.
|
|
1245
|
+
* @remarks Time O(N), Space O(N)
|
|
1246
|
+
* @param predicate - Function (value, index, queue) → boolean to decide deletion.
|
|
1247
|
+
* @returns True if a match was removed.
|
|
1248
|
+
*/
|
|
1249
|
+
deleteWhere(predicate) {
|
|
1250
|
+
for (let i = 0; i < this.length; i++) {
|
|
1251
|
+
if (predicate(this._elements[this._offset + i], i, this)) {
|
|
1252
|
+
this.deleteAt(i);
|
|
1253
|
+
return true;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
return false;
|
|
1257
|
+
}
|
|
1207
1258
|
/**
|
|
1208
1259
|
* Reverse the queue in-place by compacting then reversing.
|
|
1209
1260
|
* @remarks Time O(N), Space O(N)
|
|
@@ -1246,6 +1297,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1246
1297
|
|
|
1247
1298
|
|
|
1248
1299
|
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
|
|
1249
1304
|
|
|
1250
1305
|
|
|
1251
1306
|
|
|
@@ -1292,6 +1347,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1292
1347
|
|
|
1293
1348
|
|
|
1294
1349
|
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1295
1354
|
|
|
1296
1355
|
|
|
1297
1356
|
|
|
@@ -1361,6 +1420,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1361
1420
|
|
|
1362
1421
|
|
|
1363
1422
|
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1364
1427
|
|
|
1365
1428
|
|
|
1366
1429
|
|
|
@@ -1414,6 +1477,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1414
1477
|
|
|
1415
1478
|
|
|
1416
1479
|
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
|
|
1417
1484
|
|
|
1418
1485
|
|
|
1419
1486
|
|
|
@@ -1471,6 +1538,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1471
1538
|
|
|
1472
1539
|
|
|
1473
1540
|
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
|
|
1474
1545
|
|
|
1475
1546
|
|
|
1476
1547
|
|
|
@@ -1942,7 +2013,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1942
2013
|
}
|
|
1943
2014
|
/**
|
|
1944
2015
|
* Adds a new node to the tree.
|
|
1945
|
-
* @remarks Time O(
|
|
2016
|
+
* @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).
|
|
1946
2017
|
*
|
|
1947
2018
|
* @param keyNodeOrEntry - The key, node, or entry to add.
|
|
1948
2019
|
* @returns True if the addition was successful, false otherwise.
|
|
@@ -1971,6 +2042,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1971
2042
|
|
|
1972
2043
|
|
|
1973
2044
|
|
|
2045
|
+
|
|
2046
|
+
|
|
2047
|
+
|
|
2048
|
+
|
|
1974
2049
|
|
|
1975
2050
|
|
|
1976
2051
|
|
|
@@ -1990,7 +2065,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1990
2065
|
}
|
|
1991
2066
|
/**
|
|
1992
2067
|
* Adds or updates a new node to the tree.
|
|
1993
|
-
* @remarks Time O(
|
|
2068
|
+
* @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).
|
|
1994
2069
|
*
|
|
1995
2070
|
* @param keyNodeOrEntry - The key, node, or entry to set or update.
|
|
1996
2071
|
* @param [value] - The value, if providing just a key.
|
|
@@ -2025,6 +2100,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2025
2100
|
|
|
2026
2101
|
|
|
2027
2102
|
|
|
2103
|
+
|
|
2104
|
+
|
|
2105
|
+
|
|
2106
|
+
|
|
2028
2107
|
|
|
2029
2108
|
|
|
2030
2109
|
|
|
@@ -2131,6 +2210,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2131
2210
|
|
|
2132
2211
|
|
|
2133
2212
|
|
|
2213
|
+
|
|
2214
|
+
|
|
2215
|
+
|
|
2216
|
+
|
|
2134
2217
|
|
|
2135
2218
|
|
|
2136
2219
|
|
|
@@ -2173,6 +2256,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2173
2256
|
|
|
2174
2257
|
|
|
2175
2258
|
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
|
|
2262
|
+
|
|
2176
2263
|
|
|
2177
2264
|
|
|
2178
2265
|
|
|
@@ -2236,6 +2323,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2236
2323
|
|
|
2237
2324
|
|
|
2238
2325
|
|
|
2326
|
+
|
|
2327
|
+
|
|
2328
|
+
|
|
2329
|
+
|
|
2239
2330
|
|
|
2240
2331
|
|
|
2241
2332
|
|
|
@@ -2252,22 +2343,66 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2252
2343
|
this.setMany(anotherTree, []);
|
|
2253
2344
|
}
|
|
2254
2345
|
/**
|
|
2255
|
-
*
|
|
2256
|
-
* @remarks Time O(N)
|
|
2346
|
+
* Deletes a node from the tree (internal, returns balancing metadata).
|
|
2347
|
+
* @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).
|
|
2348
|
+
* @internal Used by AVL/BST subclasses that need balancing metadata after deletion.
|
|
2257
2349
|
*
|
|
2258
|
-
* @param
|
|
2259
|
-
* @
|
|
2350
|
+
* @param keyNodeEntryRawOrPredicate - The node to delete.
|
|
2351
|
+
* @returns An array containing deletion results with balancing metadata.
|
|
2260
2352
|
*/
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
this.
|
|
2353
|
+
_deleteInternal(keyNodeEntryRawOrPredicate) {
|
|
2354
|
+
const deletedResult = [];
|
|
2355
|
+
if (!this._root) return deletedResult;
|
|
2356
|
+
const curr = this.getNode(keyNodeEntryRawOrPredicate);
|
|
2357
|
+
if (!curr) return deletedResult;
|
|
2358
|
+
const parent = curr?.parent;
|
|
2359
|
+
let needBalanced;
|
|
2360
|
+
let orgCurrent = curr;
|
|
2361
|
+
if (!curr.left && !curr.right && !parent) {
|
|
2362
|
+
this._setRoot(void 0);
|
|
2363
|
+
} else if (curr.left) {
|
|
2364
|
+
const leftSubTreeRightMost = this.getRightMost((node) => node, curr.left);
|
|
2365
|
+
if (leftSubTreeRightMost) {
|
|
2366
|
+
const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
|
|
2367
|
+
orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
|
|
2368
|
+
if (this._isMapMode) {
|
|
2369
|
+
this._store.set(curr.key, curr);
|
|
2370
|
+
this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);
|
|
2371
|
+
}
|
|
2372
|
+
if (parentOfLeftSubTreeMax) {
|
|
2373
|
+
if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)
|
|
2374
|
+
parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
|
|
2375
|
+
else parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
|
|
2376
|
+
needBalanced = parentOfLeftSubTreeMax;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
} else if (parent) {
|
|
2380
|
+
const { familyPosition: fp } = curr;
|
|
2381
|
+
if (fp === "LEFT" || fp === "ROOT_LEFT") {
|
|
2382
|
+
parent.left = curr.right;
|
|
2383
|
+
} else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
|
|
2384
|
+
parent.right = curr.right;
|
|
2385
|
+
}
|
|
2386
|
+
needBalanced = parent;
|
|
2387
|
+
} else {
|
|
2388
|
+
this._setRoot(curr.right);
|
|
2389
|
+
curr.right = void 0;
|
|
2390
|
+
}
|
|
2391
|
+
this._size = this._size - 1;
|
|
2392
|
+
deletedResult.push({ deleted: orgCurrent, needBalanced });
|
|
2393
|
+
if (this._isMapMode && orgCurrent) this._store.delete(orgCurrent.key);
|
|
2394
|
+
return deletedResult;
|
|
2264
2395
|
}
|
|
2265
2396
|
/**
|
|
2266
2397
|
* Deletes a node from the tree.
|
|
2267
|
-
* @remarks Time O(
|
|
2398
|
+
* @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).
|
|
2268
2399
|
*
|
|
2269
2400
|
* @param keyNodeEntryRawOrPredicate - The node to delete.
|
|
2270
|
-
* @returns
|
|
2401
|
+
* @returns True if the node was found and deleted, false otherwise.
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
|
|
2405
|
+
|
|
2271
2406
|
|
|
2272
2407
|
|
|
2273
2408
|
|
|
@@ -2311,51 +2446,11 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2311
2446
|
* console.log(tree.size); // 4;
|
|
2312
2447
|
*/
|
|
2313
2448
|
delete(keyNodeEntryRawOrPredicate) {
|
|
2314
|
-
|
|
2315
|
-
if (!this._root) return deletedResult;
|
|
2316
|
-
const curr = this.getNode(keyNodeEntryRawOrPredicate);
|
|
2317
|
-
if (!curr) return deletedResult;
|
|
2318
|
-
const parent = curr?.parent;
|
|
2319
|
-
let needBalanced;
|
|
2320
|
-
let orgCurrent = curr;
|
|
2321
|
-
if (!curr.left && !curr.right && !parent) {
|
|
2322
|
-
this._setRoot(void 0);
|
|
2323
|
-
} else if (curr.left) {
|
|
2324
|
-
const leftSubTreeRightMost = this.getRightMost((node) => node, curr.left);
|
|
2325
|
-
if (leftSubTreeRightMost) {
|
|
2326
|
-
const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
|
|
2327
|
-
orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
|
|
2328
|
-
if (this._isMapMode) {
|
|
2329
|
-
this._store.set(curr.key, curr);
|
|
2330
|
-
this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);
|
|
2331
|
-
}
|
|
2332
|
-
if (parentOfLeftSubTreeMax) {
|
|
2333
|
-
if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)
|
|
2334
|
-
parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
|
|
2335
|
-
else parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
|
|
2336
|
-
needBalanced = parentOfLeftSubTreeMax;
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2339
|
-
} else if (parent) {
|
|
2340
|
-
const { familyPosition: fp } = curr;
|
|
2341
|
-
if (fp === "LEFT" || fp === "ROOT_LEFT") {
|
|
2342
|
-
parent.left = curr.right;
|
|
2343
|
-
} else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
|
|
2344
|
-
parent.right = curr.right;
|
|
2345
|
-
}
|
|
2346
|
-
needBalanced = parent;
|
|
2347
|
-
} else {
|
|
2348
|
-
this._setRoot(curr.right);
|
|
2349
|
-
curr.right = void 0;
|
|
2350
|
-
}
|
|
2351
|
-
this._size = this._size - 1;
|
|
2352
|
-
deletedResult.push({ deleted: orgCurrent, needBalanced });
|
|
2353
|
-
if (this._isMapMode && orgCurrent) this._store.delete(orgCurrent.key);
|
|
2354
|
-
return deletedResult;
|
|
2449
|
+
return this._deleteInternal(keyNodeEntryRawOrPredicate).length > 0;
|
|
2355
2450
|
}
|
|
2356
2451
|
/**
|
|
2357
2452
|
* Searches the tree for nodes matching a predicate.
|
|
2358
|
-
* @remarks Time O(
|
|
2453
|
+
* @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).
|
|
2359
2454
|
*
|
|
2360
2455
|
* @template C - The type of the callback function.
|
|
2361
2456
|
* @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
|
|
@@ -2404,7 +2499,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2404
2499
|
}
|
|
2405
2500
|
/**
|
|
2406
2501
|
* Gets the first node matching a predicate.
|
|
2407
|
-
* @remarks Time O(
|
|
2502
|
+
* @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.
|
|
2408
2503
|
*
|
|
2409
2504
|
* @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
|
|
2410
2505
|
* @param [startNode=this._root] - The node to start the search from.
|
|
@@ -2438,6 +2533,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2438
2533
|
|
|
2439
2534
|
|
|
2440
2535
|
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2441
2540
|
|
|
2442
2541
|
|
|
2443
2542
|
|
|
@@ -2460,7 +2559,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2460
2559
|
}
|
|
2461
2560
|
/**
|
|
2462
2561
|
* Gets the value associated with a key.
|
|
2463
|
-
* @remarks Time O(
|
|
2562
|
+
* @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).
|
|
2464
2563
|
*
|
|
2465
2564
|
* @param keyNodeEntryOrPredicate - The key, node, or entry to get the value for.
|
|
2466
2565
|
* @param [startNode=this._root] - The node to start searching from (if not in Map mode).
|
|
@@ -2496,6 +2595,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2496
2595
|
|
|
2497
2596
|
|
|
2498
2597
|
|
|
2598
|
+
|
|
2599
|
+
|
|
2600
|
+
|
|
2601
|
+
|
|
2499
2602
|
|
|
2500
2603
|
|
|
2501
2604
|
|
|
@@ -2556,6 +2659,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2556
2659
|
|
|
2557
2660
|
|
|
2558
2661
|
|
|
2662
|
+
|
|
2663
|
+
|
|
2664
|
+
|
|
2665
|
+
|
|
2559
2666
|
|
|
2560
2667
|
|
|
2561
2668
|
|
|
@@ -2604,6 +2711,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2604
2711
|
|
|
2605
2712
|
|
|
2606
2713
|
|
|
2714
|
+
|
|
2715
|
+
|
|
2716
|
+
|
|
2717
|
+
|
|
2607
2718
|
|
|
2608
2719
|
|
|
2609
2720
|
|
|
@@ -2661,6 +2772,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2661
2772
|
|
|
2662
2773
|
|
|
2663
2774
|
|
|
2775
|
+
|
|
2776
|
+
|
|
2777
|
+
|
|
2778
|
+
|
|
2664
2779
|
|
|
2665
2780
|
|
|
2666
2781
|
|
|
@@ -2745,6 +2860,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2745
2860
|
|
|
2746
2861
|
|
|
2747
2862
|
|
|
2863
|
+
|
|
2864
|
+
|
|
2865
|
+
|
|
2866
|
+
|
|
2748
2867
|
|
|
2749
2868
|
|
|
2750
2869
|
|
|
@@ -2806,6 +2925,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2806
2925
|
|
|
2807
2926
|
|
|
2808
2927
|
|
|
2928
|
+
|
|
2929
|
+
|
|
2930
|
+
|
|
2931
|
+
|
|
2809
2932
|
|
|
2810
2933
|
|
|
2811
2934
|
|
|
@@ -3283,6 +3406,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3283
3406
|
|
|
3284
3407
|
|
|
3285
3408
|
|
|
3409
|
+
|
|
3410
|
+
|
|
3411
|
+
|
|
3412
|
+
|
|
3286
3413
|
|
|
3287
3414
|
|
|
3288
3415
|
|
|
@@ -3335,6 +3462,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3335
3462
|
|
|
3336
3463
|
|
|
3337
3464
|
|
|
3465
|
+
|
|
3466
|
+
|
|
3467
|
+
|
|
3468
|
+
|
|
3338
3469
|
|
|
3339
3470
|
|
|
3340
3471
|
|
|
@@ -3391,6 +3522,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3391
3522
|
|
|
3392
3523
|
|
|
3393
3524
|
|
|
3525
|
+
|
|
3526
|
+
|
|
3527
|
+
|
|
3528
|
+
|
|
3394
3529
|
|
|
3395
3530
|
|
|
3396
3531
|
|
|
@@ -3472,6 +3607,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3472
3607
|
|
|
3473
3608
|
|
|
3474
3609
|
|
|
3610
|
+
|
|
3611
|
+
|
|
3612
|
+
|
|
3613
|
+
|
|
3475
3614
|
|
|
3476
3615
|
|
|
3477
3616
|
|
|
@@ -4291,6 +4430,14 @@ var BST = class extends BinaryTree {
|
|
|
4291
4430
|
|
|
4292
4431
|
|
|
4293
4432
|
|
|
4433
|
+
|
|
4434
|
+
|
|
4435
|
+
|
|
4436
|
+
|
|
4437
|
+
|
|
4438
|
+
|
|
4439
|
+
|
|
4440
|
+
|
|
4294
4441
|
|
|
4295
4442
|
|
|
4296
4443
|
|
|
@@ -4623,6 +4770,18 @@ var BST = class extends BinaryTree {
|
|
|
4623
4770
|
|
|
4624
4771
|
|
|
4625
4772
|
|
|
4773
|
+
|
|
4774
|
+
|
|
4775
|
+
|
|
4776
|
+
|
|
4777
|
+
|
|
4778
|
+
|
|
4779
|
+
|
|
4780
|
+
|
|
4781
|
+
|
|
4782
|
+
|
|
4783
|
+
|
|
4784
|
+
|
|
4626
4785
|
|
|
4627
4786
|
|
|
4628
4787
|
|
|
@@ -4742,6 +4901,14 @@ var BST = class extends BinaryTree {
|
|
|
4742
4901
|
|
|
4743
4902
|
|
|
4744
4903
|
|
|
4904
|
+
|
|
4905
|
+
|
|
4906
|
+
|
|
4907
|
+
|
|
4908
|
+
|
|
4909
|
+
|
|
4910
|
+
|
|
4911
|
+
|
|
4745
4912
|
|
|
4746
4913
|
|
|
4747
4914
|
|
|
@@ -5033,6 +5200,10 @@ var BST = class extends BinaryTree {
|
|
|
5033
5200
|
|
|
5034
5201
|
|
|
5035
5202
|
|
|
5203
|
+
|
|
5204
|
+
|
|
5205
|
+
|
|
5206
|
+
|
|
5036
5207
|
|
|
5037
5208
|
|
|
5038
5209
|
|
|
@@ -5102,6 +5273,10 @@ var BST = class extends BinaryTree {
|
|
|
5102
5273
|
|
|
5103
5274
|
|
|
5104
5275
|
|
|
5276
|
+
|
|
5277
|
+
|
|
5278
|
+
|
|
5279
|
+
|
|
5105
5280
|
|
|
5106
5281
|
|
|
5107
5282
|
|
|
@@ -5220,6 +5395,14 @@ var BST = class extends BinaryTree {
|
|
|
5220
5395
|
|
|
5221
5396
|
|
|
5222
5397
|
|
|
5398
|
+
|
|
5399
|
+
|
|
5400
|
+
|
|
5401
|
+
|
|
5402
|
+
|
|
5403
|
+
|
|
5404
|
+
|
|
5405
|
+
|
|
5223
5406
|
|
|
5224
5407
|
|
|
5225
5408
|
|
|
@@ -5281,12 +5464,11 @@ var BST = class extends BinaryTree {
|
|
|
5281
5464
|
*/
|
|
5282
5465
|
deleteWhere(keyNodeEntryOrPredicate, onlyOne = false, startNode = this._root, iterationType = this.iterationType) {
|
|
5283
5466
|
const toDelete = this.search(keyNodeEntryOrPredicate, onlyOne, (node) => node, startNode, iterationType);
|
|
5284
|
-
let
|
|
5467
|
+
let deleted = false;
|
|
5285
5468
|
for (const node of toDelete) {
|
|
5286
|
-
|
|
5287
|
-
results = results.concat(deleteInfo);
|
|
5469
|
+
if (this.delete(node)) deleted = true;
|
|
5288
5470
|
}
|
|
5289
|
-
return
|
|
5471
|
+
return deleted;
|
|
5290
5472
|
}
|
|
5291
5473
|
/**
|
|
5292
5474
|
* (Protected) Creates the default comparator function for keys that don't have a custom comparator.
|
|
@@ -5913,6 +6095,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
5913
6095
|
|
|
5914
6096
|
|
|
5915
6097
|
|
|
6098
|
+
|
|
6099
|
+
|
|
6100
|
+
|
|
6101
|
+
|
|
6102
|
+
|
|
6103
|
+
|
|
6104
|
+
|
|
6105
|
+
|
|
5916
6106
|
|
|
5917
6107
|
|
|
5918
6108
|
|
|
@@ -5989,6 +6179,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
5989
6179
|
|
|
5990
6180
|
|
|
5991
6181
|
|
|
6182
|
+
|
|
6183
|
+
|
|
6184
|
+
|
|
6185
|
+
|
|
6186
|
+
|
|
6187
|
+
|
|
6188
|
+
|
|
6189
|
+
|
|
5992
6190
|
|
|
5993
6191
|
|
|
5994
6192
|
|
|
@@ -6065,6 +6263,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6065
6263
|
|
|
6066
6264
|
|
|
6067
6265
|
|
|
6266
|
+
|
|
6267
|
+
|
|
6268
|
+
|
|
6269
|
+
|
|
6270
|
+
|
|
6271
|
+
|
|
6272
|
+
|
|
6273
|
+
|
|
6068
6274
|
|
|
6069
6275
|
|
|
6070
6276
|
|
|
@@ -6141,6 +6347,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6141
6347
|
|
|
6142
6348
|
|
|
6143
6349
|
|
|
6350
|
+
|
|
6351
|
+
|
|
6352
|
+
|
|
6353
|
+
|
|
6354
|
+
|
|
6355
|
+
|
|
6356
|
+
|
|
6357
|
+
|
|
6144
6358
|
|
|
6145
6359
|
|
|
6146
6360
|
|
|
@@ -6215,6 +6429,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6215
6429
|
|
|
6216
6430
|
|
|
6217
6431
|
|
|
6432
|
+
|
|
6433
|
+
|
|
6434
|
+
|
|
6435
|
+
|
|
6436
|
+
|
|
6437
|
+
|
|
6438
|
+
|
|
6439
|
+
|
|
6218
6440
|
|
|
6219
6441
|
|
|
6220
6442
|
|
|
@@ -6296,6 +6518,14 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6296
6518
|
|
|
6297
6519
|
|
|
6298
6520
|
|
|
6521
|
+
|
|
6522
|
+
|
|
6523
|
+
|
|
6524
|
+
|
|
6525
|
+
|
|
6526
|
+
|
|
6527
|
+
|
|
6528
|
+
|
|
6299
6529
|
|
|
6300
6530
|
|
|
6301
6531
|
|
|
@@ -6350,6 +6580,10 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6350
6580
|
|
|
6351
6581
|
|
|
6352
6582
|
|
|
6583
|
+
|
|
6584
|
+
|
|
6585
|
+
|
|
6586
|
+
|
|
6353
6587
|
|
|
6354
6588
|
|
|
6355
6589
|
|
|
@@ -6411,6 +6645,10 @@ var BinaryIndexedTree = class _BinaryIndexedTree {
|
|
|
6411
6645
|
|
|
6412
6646
|
|
|
6413
6647
|
|
|
6648
|
+
|
|
6649
|
+
|
|
6650
|
+
|
|
6651
|
+
|
|
6414
6652
|
|
|
6415
6653
|
|
|
6416
6654
|
|
|
@@ -6575,6 +6813,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6575
6813
|
|
|
6576
6814
|
|
|
6577
6815
|
|
|
6816
|
+
|
|
6817
|
+
|
|
6818
|
+
|
|
6819
|
+
|
|
6578
6820
|
|
|
6579
6821
|
|
|
6580
6822
|
|
|
@@ -6647,6 +6889,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6647
6889
|
|
|
6648
6890
|
|
|
6649
6891
|
|
|
6892
|
+
|
|
6893
|
+
|
|
6894
|
+
|
|
6895
|
+
|
|
6650
6896
|
|
|
6651
6897
|
|
|
6652
6898
|
|
|
@@ -6713,6 +6959,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6713
6959
|
|
|
6714
6960
|
|
|
6715
6961
|
|
|
6962
|
+
|
|
6963
|
+
|
|
6964
|
+
|
|
6965
|
+
|
|
6716
6966
|
|
|
6717
6967
|
|
|
6718
6968
|
|
|
@@ -6786,6 +7036,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6786
7036
|
|
|
6787
7037
|
|
|
6788
7038
|
|
|
7039
|
+
|
|
7040
|
+
|
|
7041
|
+
|
|
7042
|
+
|
|
6789
7043
|
|
|
6790
7044
|
|
|
6791
7045
|
|
|
@@ -6837,6 +7091,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6837
7091
|
|
|
6838
7092
|
|
|
6839
7093
|
|
|
7094
|
+
|
|
7095
|
+
|
|
7096
|
+
|
|
7097
|
+
|
|
6840
7098
|
|
|
6841
7099
|
|
|
6842
7100
|
|
|
@@ -6914,6 +7172,10 @@ var SegmentTree = class _SegmentTree {
|
|
|
6914
7172
|
|
|
6915
7173
|
|
|
6916
7174
|
|
|
7175
|
+
|
|
7176
|
+
|
|
7177
|
+
|
|
7178
|
+
|
|
6917
7179
|
|
|
6918
7180
|
|
|
6919
7181
|
|
|
@@ -7299,6 +7561,22 @@ var AVLTree = class extends BST {
|
|
|
7299
7561
|
|
|
7300
7562
|
|
|
7301
7563
|
|
|
7564
|
+
|
|
7565
|
+
|
|
7566
|
+
|
|
7567
|
+
|
|
7568
|
+
|
|
7569
|
+
|
|
7570
|
+
|
|
7571
|
+
|
|
7572
|
+
|
|
7573
|
+
|
|
7574
|
+
|
|
7575
|
+
|
|
7576
|
+
|
|
7577
|
+
|
|
7578
|
+
|
|
7579
|
+
|
|
7302
7580
|
|
|
7303
7581
|
|
|
7304
7582
|
|
|
@@ -7427,6 +7705,18 @@ var AVLTree = class extends BST {
|
|
|
7427
7705
|
|
|
7428
7706
|
|
|
7429
7707
|
|
|
7708
|
+
|
|
7709
|
+
|
|
7710
|
+
|
|
7711
|
+
|
|
7712
|
+
|
|
7713
|
+
|
|
7714
|
+
|
|
7715
|
+
|
|
7716
|
+
|
|
7717
|
+
|
|
7718
|
+
|
|
7719
|
+
|
|
7430
7720
|
|
|
7431
7721
|
|
|
7432
7722
|
|
|
@@ -7448,13 +7738,13 @@ var AVLTree = class extends BST {
|
|
|
7448
7738
|
* console.log(avl.size); // 6;
|
|
7449
7739
|
*/
|
|
7450
7740
|
delete(keyNodeOrEntry) {
|
|
7451
|
-
const deletedResults =
|
|
7741
|
+
const deletedResults = this._deleteInternal(keyNodeOrEntry);
|
|
7452
7742
|
for (const { needBalanced } of deletedResults) {
|
|
7453
7743
|
if (needBalanced) {
|
|
7454
7744
|
this._balancePath(needBalanced);
|
|
7455
7745
|
}
|
|
7456
7746
|
}
|
|
7457
|
-
return deletedResults;
|
|
7747
|
+
return deletedResults.length > 0;
|
|
7458
7748
|
}
|
|
7459
7749
|
/**
|
|
7460
7750
|
* Rebuilds the tree to be perfectly balanced.
|
|
@@ -7514,6 +7804,14 @@ var AVLTree = class extends BST {
|
|
|
7514
7804
|
|
|
7515
7805
|
|
|
7516
7806
|
|
|
7807
|
+
|
|
7808
|
+
|
|
7809
|
+
|
|
7810
|
+
|
|
7811
|
+
|
|
7812
|
+
|
|
7813
|
+
|
|
7814
|
+
|
|
7517
7815
|
|
|
7518
7816
|
|
|
7519
7817
|
|
|
@@ -7646,6 +7944,18 @@ var AVLTree = class extends BST {
|
|
|
7646
7944
|
|
|
7647
7945
|
|
|
7648
7946
|
|
|
7947
|
+
|
|
7948
|
+
|
|
7949
|
+
|
|
7950
|
+
|
|
7951
|
+
|
|
7952
|
+
|
|
7953
|
+
|
|
7954
|
+
|
|
7955
|
+
|
|
7956
|
+
|
|
7957
|
+
|
|
7958
|
+
|
|
7649
7959
|
|
|
7650
7960
|
|
|
7651
7961
|
|
|
@@ -8148,13 +8458,24 @@ var RedBlackTree = class extends BST {
|
|
|
8148
8458
|
return keyNodeOrEntry instanceof RedBlackTreeNode;
|
|
8149
8459
|
}
|
|
8150
8460
|
/**
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8461
|
+
* Remove all nodes, clear the key→value store (if in map mode) and internal caches.
|
|
8462
|
+
* @remarks Time O(n), Space O(1)
|
|
8463
|
+
|
|
8464
|
+
|
|
8465
|
+
|
|
8466
|
+
|
|
8467
|
+
|
|
8468
|
+
|
|
8469
|
+
|
|
8470
|
+
|
|
8471
|
+
|
|
8472
|
+
|
|
8473
|
+
|
|
8474
|
+
|
|
8475
|
+
|
|
8476
|
+
|
|
8477
|
+
|
|
8478
|
+
|
|
8158
8479
|
|
|
8159
8480
|
|
|
8160
8481
|
|
|
@@ -8744,6 +9065,22 @@ var RedBlackTree = class extends BST {
|
|
|
8744
9065
|
|
|
8745
9066
|
|
|
8746
9067
|
|
|
9068
|
+
|
|
9069
|
+
|
|
9070
|
+
|
|
9071
|
+
|
|
9072
|
+
|
|
9073
|
+
|
|
9074
|
+
|
|
9075
|
+
|
|
9076
|
+
|
|
9077
|
+
|
|
9078
|
+
|
|
9079
|
+
|
|
9080
|
+
|
|
9081
|
+
|
|
9082
|
+
|
|
9083
|
+
|
|
8747
9084
|
|
|
8748
9085
|
|
|
8749
9086
|
|
|
@@ -8943,6 +9280,22 @@ var RedBlackTree = class extends BST {
|
|
|
8943
9280
|
|
|
8944
9281
|
|
|
8945
9282
|
|
|
9283
|
+
|
|
9284
|
+
|
|
9285
|
+
|
|
9286
|
+
|
|
9287
|
+
|
|
9288
|
+
|
|
9289
|
+
|
|
9290
|
+
|
|
9291
|
+
|
|
9292
|
+
|
|
9293
|
+
|
|
9294
|
+
|
|
9295
|
+
|
|
9296
|
+
|
|
9297
|
+
|
|
9298
|
+
|
|
8946
9299
|
|
|
8947
9300
|
|
|
8948
9301
|
|
|
@@ -8968,13 +9321,12 @@ var RedBlackTree = class extends BST {
|
|
|
8968
9321
|
* console.log(rbt.size); // 4;
|
|
8969
9322
|
*/
|
|
8970
9323
|
delete(keyNodeEntryRawOrPredicate) {
|
|
8971
|
-
if (keyNodeEntryRawOrPredicate === null) return
|
|
8972
|
-
const results = [];
|
|
9324
|
+
if (keyNodeEntryRawOrPredicate === null) return false;
|
|
8973
9325
|
let nodeToDelete;
|
|
8974
9326
|
if (this._isPredicate(keyNodeEntryRawOrPredicate)) nodeToDelete = this.getNode(keyNodeEntryRawOrPredicate);
|
|
8975
9327
|
else nodeToDelete = this.isRealNode(keyNodeEntryRawOrPredicate) ? keyNodeEntryRawOrPredicate : this.getNode(keyNodeEntryRawOrPredicate);
|
|
8976
9328
|
if (!nodeToDelete) {
|
|
8977
|
-
return
|
|
9329
|
+
return false;
|
|
8978
9330
|
}
|
|
8979
9331
|
const willDeleteMin = nodeToDelete === this._minNode;
|
|
8980
9332
|
const willDeleteMax = nodeToDelete === this._maxNode;
|
|
@@ -9030,8 +9382,7 @@ var RedBlackTree = class extends BST {
|
|
|
9030
9382
|
if (originalColor === "BLACK") {
|
|
9031
9383
|
this._deleteFixup(replacementNode);
|
|
9032
9384
|
}
|
|
9033
|
-
|
|
9034
|
-
return results;
|
|
9385
|
+
return true;
|
|
9035
9386
|
}
|
|
9036
9387
|
/**
|
|
9037
9388
|
* Transform entries into a like-kind red-black tree with possibly different key/value types.
|
|
@@ -9132,6 +9483,18 @@ var RedBlackTree = class extends BST {
|
|
|
9132
9483
|
|
|
9133
9484
|
|
|
9134
9485
|
|
|
9486
|
+
|
|
9487
|
+
|
|
9488
|
+
|
|
9489
|
+
|
|
9490
|
+
|
|
9491
|
+
|
|
9492
|
+
|
|
9493
|
+
|
|
9494
|
+
|
|
9495
|
+
|
|
9496
|
+
|
|
9497
|
+
|
|
9135
9498
|
|
|
9136
9499
|
|
|
9137
9500
|
|
|
@@ -9280,6 +9643,22 @@ var RedBlackTree = class extends BST {
|
|
|
9280
9643
|
|
|
9281
9644
|
|
|
9282
9645
|
|
|
9646
|
+
|
|
9647
|
+
|
|
9648
|
+
|
|
9649
|
+
|
|
9650
|
+
|
|
9651
|
+
|
|
9652
|
+
|
|
9653
|
+
|
|
9654
|
+
|
|
9655
|
+
|
|
9656
|
+
|
|
9657
|
+
|
|
9658
|
+
|
|
9659
|
+
|
|
9660
|
+
|
|
9661
|
+
|
|
9283
9662
|
|
|
9284
9663
|
|
|
9285
9664
|
|
|
@@ -9793,6 +10172,26 @@ var TreeSet = class _TreeSet {
|
|
|
9793
10172
|
|
|
9794
10173
|
|
|
9795
10174
|
|
|
10175
|
+
|
|
10176
|
+
|
|
10177
|
+
|
|
10178
|
+
|
|
10179
|
+
|
|
10180
|
+
|
|
10181
|
+
|
|
10182
|
+
|
|
10183
|
+
|
|
10184
|
+
|
|
10185
|
+
|
|
10186
|
+
|
|
10187
|
+
|
|
10188
|
+
|
|
10189
|
+
|
|
10190
|
+
|
|
10191
|
+
|
|
10192
|
+
|
|
10193
|
+
|
|
10194
|
+
|
|
9796
10195
|
|
|
9797
10196
|
|
|
9798
10197
|
|
|
@@ -9998,28 +10397,103 @@ var TreeSet = class _TreeSet {
|
|
|
9998
10397
|
|
|
9999
10398
|
|
|
10000
10399
|
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10400
|
+
|
|
10401
|
+
|
|
10402
|
+
|
|
10403
|
+
|
|
10404
|
+
|
|
10405
|
+
|
|
10406
|
+
|
|
10407
|
+
|
|
10408
|
+
|
|
10409
|
+
|
|
10410
|
+
|
|
10411
|
+
|
|
10412
|
+
|
|
10413
|
+
|
|
10414
|
+
|
|
10415
|
+
|
|
10416
|
+
|
|
10417
|
+
|
|
10418
|
+
|
|
10419
|
+
|
|
10420
|
+
* @example
|
|
10421
|
+
* // Unique tags with sorted order
|
|
10422
|
+
* const tags = new TreeSet<string>(['javascript', 'typescript', 'react', 'typescript', 'node']);
|
|
10423
|
+
*
|
|
10424
|
+
* // Duplicates removed, sorted alphabetically
|
|
10425
|
+
* console.log([...tags]); // ['javascript', 'node', 'react', 'typescript'];
|
|
10426
|
+
* console.log(tags.size); // 4;
|
|
10427
|
+
*
|
|
10428
|
+
* tags.add('angular');
|
|
10429
|
+
* console.log(tags.first()); // 'angular';
|
|
10430
|
+
* console.log(tags.last()); // 'typescript';
|
|
10431
|
+
*/
|
|
10432
|
+
add(key) {
|
|
10433
|
+
this._validateKey(key);
|
|
10434
|
+
this.#core.set(key, void 0);
|
|
10435
|
+
return this;
|
|
10436
|
+
}
|
|
10437
|
+
/**
|
|
10438
|
+
* Add multiple keys at once.
|
|
10439
|
+
* @remarks Expected time O(m log n), where m is the number of keys.
|
|
10440
|
+
* @param keys - Iterable of keys to add.
|
|
10441
|
+
* @returns Array of booleans indicating whether each key was newly added.
|
|
10442
|
+
|
|
10443
|
+
|
|
10444
|
+
|
|
10445
|
+
|
|
10446
|
+
|
|
10447
|
+
|
|
10448
|
+
|
|
10449
|
+
|
|
10450
|
+
|
|
10451
|
+
|
|
10452
|
+
|
|
10453
|
+
|
|
10454
|
+
|
|
10455
|
+
|
|
10456
|
+
|
|
10457
|
+
|
|
10458
|
+
* @example
|
|
10459
|
+
* // Add multiple keys
|
|
10460
|
+
* const ts = new TreeSet<number>();
|
|
10461
|
+
* ts.addMany([5, 3, 7, 1, 9]);
|
|
10462
|
+
* console.log(ts.size); // 5;
|
|
10463
|
+
*/
|
|
10464
|
+
addMany(keys) {
|
|
10465
|
+
const results = [];
|
|
10466
|
+
for (const key of keys) {
|
|
10467
|
+
this._validateKey(key);
|
|
10468
|
+
results.push(this.#core.set(key, void 0));
|
|
10469
|
+
}
|
|
10470
|
+
return results;
|
|
10471
|
+
}
|
|
10472
|
+
/**
|
|
10473
|
+
* Test whether a key exists.
|
|
10474
|
+
* @remarks Expected time O(log n)
|
|
10475
|
+
|
|
10476
|
+
|
|
10477
|
+
|
|
10478
|
+
|
|
10479
|
+
|
|
10480
|
+
|
|
10481
|
+
|
|
10482
|
+
|
|
10483
|
+
|
|
10484
|
+
|
|
10485
|
+
|
|
10486
|
+
|
|
10487
|
+
|
|
10488
|
+
|
|
10489
|
+
|
|
10490
|
+
|
|
10491
|
+
|
|
10492
|
+
|
|
10493
|
+
|
|
10494
|
+
|
|
10495
|
+
|
|
10496
|
+
|
|
10023
10497
|
|
|
10024
10498
|
|
|
10025
10499
|
|
|
@@ -10350,6 +10824,26 @@ var TreeSet = class _TreeSet {
|
|
|
10350
10824
|
|
|
10351
10825
|
|
|
10352
10826
|
|
|
10827
|
+
|
|
10828
|
+
|
|
10829
|
+
|
|
10830
|
+
|
|
10831
|
+
|
|
10832
|
+
|
|
10833
|
+
|
|
10834
|
+
|
|
10835
|
+
|
|
10836
|
+
|
|
10837
|
+
|
|
10838
|
+
|
|
10839
|
+
|
|
10840
|
+
|
|
10841
|
+
|
|
10842
|
+
|
|
10843
|
+
|
|
10844
|
+
|
|
10845
|
+
|
|
10846
|
+
|
|
10353
10847
|
|
|
10354
10848
|
|
|
10355
10849
|
|
|
@@ -10381,8 +10875,24 @@ var TreeSet = class _TreeSet {
|
|
|
10381
10875
|
*/
|
|
10382
10876
|
delete(key) {
|
|
10383
10877
|
this._validateKey(key);
|
|
10384
|
-
|
|
10385
|
-
|
|
10878
|
+
return this.#core.delete(key);
|
|
10879
|
+
}
|
|
10880
|
+
/**
|
|
10881
|
+
* Delete all keys matching a predicate.
|
|
10882
|
+
* @remarks Time O(N), Space O(N)
|
|
10883
|
+
* @param predicate - Function (key, index, set) → boolean; return true to delete.
|
|
10884
|
+
* @returns True if at least one key was deleted.
|
|
10885
|
+
*/
|
|
10886
|
+
deleteWhere(predicate) {
|
|
10887
|
+
let deleted = false;
|
|
10888
|
+
let index = 0;
|
|
10889
|
+
for (const key of this) {
|
|
10890
|
+
if (predicate(key, index++, this)) {
|
|
10891
|
+
this.delete(key);
|
|
10892
|
+
deleted = true;
|
|
10893
|
+
}
|
|
10894
|
+
}
|
|
10895
|
+
return deleted;
|
|
10386
10896
|
}
|
|
10387
10897
|
/**
|
|
10388
10898
|
* Remove all keys.
|
|
@@ -10523,6 +11033,26 @@ var TreeSet = class _TreeSet {
|
|
|
10523
11033
|
|
|
10524
11034
|
|
|
10525
11035
|
|
|
11036
|
+
|
|
11037
|
+
|
|
11038
|
+
|
|
11039
|
+
|
|
11040
|
+
|
|
11041
|
+
|
|
11042
|
+
|
|
11043
|
+
|
|
11044
|
+
|
|
11045
|
+
|
|
11046
|
+
|
|
11047
|
+
|
|
11048
|
+
|
|
11049
|
+
|
|
11050
|
+
|
|
11051
|
+
|
|
11052
|
+
|
|
11053
|
+
|
|
11054
|
+
|
|
11055
|
+
|
|
10526
11056
|
|
|
10527
11057
|
|
|
10528
11058
|
|
|
@@ -10692,6 +11222,26 @@ var TreeSet = class _TreeSet {
|
|
|
10692
11222
|
|
|
10693
11223
|
|
|
10694
11224
|
|
|
11225
|
+
|
|
11226
|
+
|
|
11227
|
+
|
|
11228
|
+
|
|
11229
|
+
|
|
11230
|
+
|
|
11231
|
+
|
|
11232
|
+
|
|
11233
|
+
|
|
11234
|
+
|
|
11235
|
+
|
|
11236
|
+
|
|
11237
|
+
|
|
11238
|
+
|
|
11239
|
+
|
|
11240
|
+
|
|
11241
|
+
|
|
11242
|
+
|
|
11243
|
+
|
|
11244
|
+
|
|
10695
11245
|
|
|
10696
11246
|
|
|
10697
11247
|
|
|
@@ -10862,6 +11412,26 @@ var TreeSet = class _TreeSet {
|
|
|
10862
11412
|
|
|
10863
11413
|
|
|
10864
11414
|
|
|
11415
|
+
|
|
11416
|
+
|
|
11417
|
+
|
|
11418
|
+
|
|
11419
|
+
|
|
11420
|
+
|
|
11421
|
+
|
|
11422
|
+
|
|
11423
|
+
|
|
11424
|
+
|
|
11425
|
+
|
|
11426
|
+
|
|
11427
|
+
|
|
11428
|
+
|
|
11429
|
+
|
|
11430
|
+
|
|
11431
|
+
|
|
11432
|
+
|
|
11433
|
+
|
|
11434
|
+
|
|
10865
11435
|
|
|
10866
11436
|
|
|
10867
11437
|
|
|
@@ -11032,6 +11602,26 @@ var TreeSet = class _TreeSet {
|
|
|
11032
11602
|
|
|
11033
11603
|
|
|
11034
11604
|
|
|
11605
|
+
|
|
11606
|
+
|
|
11607
|
+
|
|
11608
|
+
|
|
11609
|
+
|
|
11610
|
+
|
|
11611
|
+
|
|
11612
|
+
|
|
11613
|
+
|
|
11614
|
+
|
|
11615
|
+
|
|
11616
|
+
|
|
11617
|
+
|
|
11618
|
+
|
|
11619
|
+
|
|
11620
|
+
|
|
11621
|
+
|
|
11622
|
+
|
|
11623
|
+
|
|
11624
|
+
|
|
11035
11625
|
|
|
11036
11626
|
|
|
11037
11627
|
|
|
@@ -11205,6 +11795,26 @@ var TreeSet = class _TreeSet {
|
|
|
11205
11795
|
|
|
11206
11796
|
|
|
11207
11797
|
|
|
11798
|
+
|
|
11799
|
+
|
|
11800
|
+
|
|
11801
|
+
|
|
11802
|
+
|
|
11803
|
+
|
|
11804
|
+
|
|
11805
|
+
|
|
11806
|
+
|
|
11807
|
+
|
|
11808
|
+
|
|
11809
|
+
|
|
11810
|
+
|
|
11811
|
+
|
|
11812
|
+
|
|
11813
|
+
|
|
11814
|
+
|
|
11815
|
+
|
|
11816
|
+
|
|
11817
|
+
|
|
11208
11818
|
|
|
11209
11819
|
|
|
11210
11820
|
|
|
@@ -11378,6 +11988,26 @@ var TreeSet = class _TreeSet {
|
|
|
11378
11988
|
|
|
11379
11989
|
|
|
11380
11990
|
|
|
11991
|
+
|
|
11992
|
+
|
|
11993
|
+
|
|
11994
|
+
|
|
11995
|
+
|
|
11996
|
+
|
|
11997
|
+
|
|
11998
|
+
|
|
11999
|
+
|
|
12000
|
+
|
|
12001
|
+
|
|
12002
|
+
|
|
12003
|
+
|
|
12004
|
+
|
|
12005
|
+
|
|
12006
|
+
|
|
12007
|
+
|
|
12008
|
+
|
|
12009
|
+
|
|
12010
|
+
|
|
11381
12011
|
|
|
11382
12012
|
|
|
11383
12013
|
|
|
@@ -11554,6 +12184,26 @@ var TreeSet = class _TreeSet {
|
|
|
11554
12184
|
|
|
11555
12185
|
|
|
11556
12186
|
|
|
12187
|
+
|
|
12188
|
+
|
|
12189
|
+
|
|
12190
|
+
|
|
12191
|
+
|
|
12192
|
+
|
|
12193
|
+
|
|
12194
|
+
|
|
12195
|
+
|
|
12196
|
+
|
|
12197
|
+
|
|
12198
|
+
|
|
12199
|
+
|
|
12200
|
+
|
|
12201
|
+
|
|
12202
|
+
|
|
12203
|
+
|
|
12204
|
+
|
|
12205
|
+
|
|
12206
|
+
|
|
11557
12207
|
|
|
11558
12208
|
|
|
11559
12209
|
|
|
@@ -11730,6 +12380,26 @@ var TreeSet = class _TreeSet {
|
|
|
11730
12380
|
|
|
11731
12381
|
|
|
11732
12382
|
|
|
12383
|
+
|
|
12384
|
+
|
|
12385
|
+
|
|
12386
|
+
|
|
12387
|
+
|
|
12388
|
+
|
|
12389
|
+
|
|
12390
|
+
|
|
12391
|
+
|
|
12392
|
+
|
|
12393
|
+
|
|
12394
|
+
|
|
12395
|
+
|
|
12396
|
+
|
|
12397
|
+
|
|
12398
|
+
|
|
12399
|
+
|
|
12400
|
+
|
|
12401
|
+
|
|
12402
|
+
|
|
11733
12403
|
|
|
11734
12404
|
|
|
11735
12405
|
|
|
@@ -11901,6 +12571,26 @@ var TreeSet = class _TreeSet {
|
|
|
11901
12571
|
|
|
11902
12572
|
|
|
11903
12573
|
|
|
12574
|
+
|
|
12575
|
+
|
|
12576
|
+
|
|
12577
|
+
|
|
12578
|
+
|
|
12579
|
+
|
|
12580
|
+
|
|
12581
|
+
|
|
12582
|
+
|
|
12583
|
+
|
|
12584
|
+
|
|
12585
|
+
|
|
12586
|
+
|
|
12587
|
+
|
|
12588
|
+
|
|
12589
|
+
|
|
12590
|
+
|
|
12591
|
+
|
|
12592
|
+
|
|
12593
|
+
|
|
11904
12594
|
|
|
11905
12595
|
|
|
11906
12596
|
|
|
@@ -12073,6 +12763,26 @@ var TreeSet = class _TreeSet {
|
|
|
12073
12763
|
|
|
12074
12764
|
|
|
12075
12765
|
|
|
12766
|
+
|
|
12767
|
+
|
|
12768
|
+
|
|
12769
|
+
|
|
12770
|
+
|
|
12771
|
+
|
|
12772
|
+
|
|
12773
|
+
|
|
12774
|
+
|
|
12775
|
+
|
|
12776
|
+
|
|
12777
|
+
|
|
12778
|
+
|
|
12779
|
+
|
|
12780
|
+
|
|
12781
|
+
|
|
12782
|
+
|
|
12783
|
+
|
|
12784
|
+
|
|
12785
|
+
|
|
12076
12786
|
|
|
12077
12787
|
|
|
12078
12788
|
|
|
@@ -12266,23 +12976,83 @@ var TreeSet = class _TreeSet {
|
|
|
12266
12976
|
|
|
12267
12977
|
|
|
12268
12978
|
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12979
|
+
|
|
12980
|
+
|
|
12981
|
+
|
|
12982
|
+
|
|
12983
|
+
|
|
12984
|
+
|
|
12985
|
+
|
|
12986
|
+
|
|
12987
|
+
|
|
12988
|
+
|
|
12989
|
+
|
|
12990
|
+
|
|
12991
|
+
|
|
12992
|
+
|
|
12993
|
+
|
|
12994
|
+
|
|
12995
|
+
|
|
12996
|
+
|
|
12997
|
+
|
|
12998
|
+
|
|
12999
|
+
* @example
|
|
13000
|
+
* // Find entry
|
|
13001
|
+
* const ts = new TreeSet<number>([1, 2, 3]);
|
|
13002
|
+
* const found = ts.find(k => k === 2);
|
|
13003
|
+
* console.log(found); // 2;
|
|
13004
|
+
*/
|
|
13005
|
+
find(callbackfn, thisArg) {
|
|
13006
|
+
let index = 0;
|
|
13007
|
+
for (const v of this) {
|
|
13008
|
+
const ok = thisArg === void 0 ? callbackfn(v, index++, this) : callbackfn.call(thisArg, v, index++, this);
|
|
13009
|
+
if (ok) return v;
|
|
13010
|
+
}
|
|
13011
|
+
return void 0;
|
|
13012
|
+
}
|
|
13013
|
+
/**
|
|
13014
|
+
* Materialize the set into an array of keys.
|
|
13015
|
+
* @remarks Time O(n), Space O(n)
|
|
13016
|
+
|
|
13017
|
+
|
|
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
|
+
|
|
12286
13056
|
|
|
12287
13057
|
|
|
12288
13058
|
|
|
@@ -12421,6 +13191,17 @@ var TreeSet = class _TreeSet {
|
|
|
12421
13191
|
|
|
12422
13192
|
|
|
12423
13193
|
|
|
13194
|
+
* @example
|
|
13195
|
+
* // Convert to array
|
|
13196
|
+
* const ts = new TreeSet<number>([3, 1, 2]);
|
|
13197
|
+
* console.log(ts.toArray()); // [1, 2, 3];
|
|
13198
|
+
*/
|
|
13199
|
+
toArray() {
|
|
13200
|
+
return [...this];
|
|
13201
|
+
}
|
|
13202
|
+
/**
|
|
13203
|
+
* Print a human-friendly representation.
|
|
13204
|
+
* @remarks Time O(n), Space O(n)
|
|
12424
13205
|
|
|
12425
13206
|
|
|
12426
13207
|
|
|
@@ -12441,17 +13222,6 @@ var TreeSet = class _TreeSet {
|
|
|
12441
13222
|
|
|
12442
13223
|
|
|
12443
13224
|
|
|
12444
|
-
* @example
|
|
12445
|
-
* // Convert to array
|
|
12446
|
-
* const ts = new TreeSet<number>([3, 1, 2]);
|
|
12447
|
-
* console.log(ts.toArray()); // [1, 2, 3];
|
|
12448
|
-
*/
|
|
12449
|
-
toArray() {
|
|
12450
|
-
return [...this];
|
|
12451
|
-
}
|
|
12452
|
-
/**
|
|
12453
|
-
* Print a human-friendly representation.
|
|
12454
|
-
* @remarks Time O(n), Space O(n)
|
|
12455
13225
|
|
|
12456
13226
|
|
|
12457
13227
|
|
|
@@ -12651,6 +13421,10 @@ var TreeSet = class _TreeSet {
|
|
|
12651
13421
|
|
|
12652
13422
|
|
|
12653
13423
|
|
|
13424
|
+
|
|
13425
|
+
|
|
13426
|
+
|
|
13427
|
+
|
|
12654
13428
|
|
|
12655
13429
|
|
|
12656
13430
|
|
|
@@ -12719,6 +13493,10 @@ var TreeSet = class _TreeSet {
|
|
|
12719
13493
|
|
|
12720
13494
|
|
|
12721
13495
|
|
|
13496
|
+
|
|
13497
|
+
|
|
13498
|
+
|
|
13499
|
+
|
|
12722
13500
|
|
|
12723
13501
|
|
|
12724
13502
|
|
|
@@ -12765,6 +13543,10 @@ var TreeSet = class _TreeSet {
|
|
|
12765
13543
|
|
|
12766
13544
|
|
|
12767
13545
|
|
|
13546
|
+
|
|
13547
|
+
|
|
13548
|
+
|
|
13549
|
+
|
|
12768
13550
|
|
|
12769
13551
|
|
|
12770
13552
|
|
|
@@ -12816,6 +13598,10 @@ var TreeSet = class _TreeSet {
|
|
|
12816
13598
|
|
|
12817
13599
|
|
|
12818
13600
|
|
|
13601
|
+
|
|
13602
|
+
|
|
13603
|
+
|
|
13604
|
+
|
|
12819
13605
|
|
|
12820
13606
|
|
|
12821
13607
|
|
|
@@ -12953,6 +13739,22 @@ var TreeSet = class _TreeSet {
|
|
|
12953
13739
|
|
|
12954
13740
|
|
|
12955
13741
|
|
|
13742
|
+
|
|
13743
|
+
|
|
13744
|
+
|
|
13745
|
+
|
|
13746
|
+
|
|
13747
|
+
|
|
13748
|
+
|
|
13749
|
+
|
|
13750
|
+
|
|
13751
|
+
|
|
13752
|
+
|
|
13753
|
+
|
|
13754
|
+
|
|
13755
|
+
|
|
13756
|
+
|
|
13757
|
+
|
|
12956
13758
|
|
|
12957
13759
|
|
|
12958
13760
|
|
|
@@ -13110,6 +13912,22 @@ var TreeSet = class _TreeSet {
|
|
|
13110
13912
|
|
|
13111
13913
|
|
|
13112
13914
|
|
|
13915
|
+
|
|
13916
|
+
|
|
13917
|
+
|
|
13918
|
+
|
|
13919
|
+
|
|
13920
|
+
|
|
13921
|
+
|
|
13922
|
+
|
|
13923
|
+
|
|
13924
|
+
|
|
13925
|
+
|
|
13926
|
+
|
|
13927
|
+
|
|
13928
|
+
|
|
13929
|
+
|
|
13930
|
+
|
|
13113
13931
|
|
|
13114
13932
|
|
|
13115
13933
|
|
|
@@ -13259,6 +14077,22 @@ var TreeSet = class _TreeSet {
|
|
|
13259
14077
|
|
|
13260
14078
|
|
|
13261
14079
|
|
|
14080
|
+
|
|
14081
|
+
|
|
14082
|
+
|
|
14083
|
+
|
|
14084
|
+
|
|
14085
|
+
|
|
14086
|
+
|
|
14087
|
+
|
|
14088
|
+
|
|
14089
|
+
|
|
14090
|
+
|
|
14091
|
+
|
|
14092
|
+
|
|
14093
|
+
|
|
14094
|
+
|
|
14095
|
+
|
|
13262
14096
|
|
|
13263
14097
|
|
|
13264
14098
|
|
|
@@ -13406,6 +14240,22 @@ var TreeSet = class _TreeSet {
|
|
|
13406
14240
|
|
|
13407
14241
|
|
|
13408
14242
|
|
|
14243
|
+
|
|
14244
|
+
|
|
14245
|
+
|
|
14246
|
+
|
|
14247
|
+
|
|
14248
|
+
|
|
14249
|
+
|
|
14250
|
+
|
|
14251
|
+
|
|
14252
|
+
|
|
14253
|
+
|
|
14254
|
+
|
|
14255
|
+
|
|
14256
|
+
|
|
14257
|
+
|
|
14258
|
+
|
|
13409
14259
|
|
|
13410
14260
|
|
|
13411
14261
|
|
|
@@ -13556,6 +14406,22 @@ var TreeSet = class _TreeSet {
|
|
|
13556
14406
|
|
|
13557
14407
|
|
|
13558
14408
|
|
|
14409
|
+
|
|
14410
|
+
|
|
14411
|
+
|
|
14412
|
+
|
|
14413
|
+
|
|
14414
|
+
|
|
14415
|
+
|
|
14416
|
+
|
|
14417
|
+
|
|
14418
|
+
|
|
14419
|
+
|
|
14420
|
+
|
|
14421
|
+
|
|
14422
|
+
|
|
14423
|
+
|
|
14424
|
+
|
|
13559
14425
|
|
|
13560
14426
|
|
|
13561
14427
|
|
|
@@ -13645,8 +14511,16 @@ var TreeSet = class _TreeSet {
|
|
|
13645
14511
|
* Returns elements by rank range (0-indexed, inclusive on both ends).
|
|
13646
14512
|
* @remarks Time O(log n + k). Requires `enableOrderStatistic: true`.
|
|
13647
14513
|
|
|
14514
|
+
|
|
14515
|
+
|
|
14516
|
+
|
|
14517
|
+
|
|
14518
|
+
|
|
14519
|
+
|
|
14520
|
+
|
|
14521
|
+
|
|
13648
14522
|
* @example
|
|
13649
|
-
* // Pagination
|
|
14523
|
+
* // Pagination by position in tree order
|
|
13650
14524
|
* const tree = new TreeSet<number>(
|
|
13651
14525
|
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
13652
14526
|
* { enableOrderStatistic: true }
|
|
@@ -13804,6 +14678,26 @@ var TreeSet = class _TreeSet {
|
|
|
13804
14678
|
|
|
13805
14679
|
|
|
13806
14680
|
|
|
14681
|
+
|
|
14682
|
+
|
|
14683
|
+
|
|
14684
|
+
|
|
14685
|
+
|
|
14686
|
+
|
|
14687
|
+
|
|
14688
|
+
|
|
14689
|
+
|
|
14690
|
+
|
|
14691
|
+
|
|
14692
|
+
|
|
14693
|
+
|
|
14694
|
+
|
|
14695
|
+
|
|
14696
|
+
|
|
14697
|
+
|
|
14698
|
+
|
|
14699
|
+
|
|
14700
|
+
|
|
13807
14701
|
|
|
13808
14702
|
|
|
13809
14703
|
|
|
@@ -14054,6 +14948,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14054
14948
|
|
|
14055
14949
|
|
|
14056
14950
|
|
|
14951
|
+
|
|
14952
|
+
|
|
14953
|
+
|
|
14954
|
+
|
|
14955
|
+
|
|
14956
|
+
|
|
14957
|
+
|
|
14958
|
+
|
|
14959
|
+
|
|
14960
|
+
|
|
14961
|
+
|
|
14962
|
+
|
|
14963
|
+
|
|
14964
|
+
|
|
14965
|
+
|
|
14966
|
+
|
|
14967
|
+
|
|
14968
|
+
|
|
14969
|
+
|
|
14970
|
+
|
|
14057
14971
|
|
|
14058
14972
|
|
|
14059
14973
|
|
|
@@ -14222,6 +15136,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14222
15136
|
|
|
14223
15137
|
|
|
14224
15138
|
|
|
15139
|
+
|
|
15140
|
+
|
|
15141
|
+
|
|
15142
|
+
|
|
15143
|
+
|
|
15144
|
+
|
|
15145
|
+
|
|
15146
|
+
|
|
15147
|
+
|
|
15148
|
+
|
|
15149
|
+
|
|
15150
|
+
|
|
15151
|
+
|
|
15152
|
+
|
|
15153
|
+
|
|
15154
|
+
|
|
15155
|
+
|
|
15156
|
+
|
|
15157
|
+
|
|
15158
|
+
|
|
14225
15159
|
|
|
14226
15160
|
|
|
14227
15161
|
|
|
@@ -14277,6 +15211,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14277
15211
|
|
|
14278
15212
|
|
|
14279
15213
|
|
|
15214
|
+
|
|
15215
|
+
|
|
15216
|
+
|
|
15217
|
+
|
|
14280
15218
|
|
|
14281
15219
|
|
|
14282
15220
|
|
|
@@ -14317,6 +15255,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14317
15255
|
|
|
14318
15256
|
|
|
14319
15257
|
|
|
15258
|
+
|
|
15259
|
+
|
|
15260
|
+
|
|
15261
|
+
|
|
14320
15262
|
|
|
14321
15263
|
|
|
14322
15264
|
|
|
@@ -14513,6 +15455,30 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14513
15455
|
|
|
14514
15456
|
|
|
14515
15457
|
|
|
15458
|
+
|
|
15459
|
+
|
|
15460
|
+
|
|
15461
|
+
|
|
15462
|
+
|
|
15463
|
+
|
|
15464
|
+
|
|
15465
|
+
|
|
15466
|
+
|
|
15467
|
+
|
|
15468
|
+
|
|
15469
|
+
|
|
15470
|
+
|
|
15471
|
+
|
|
15472
|
+
|
|
15473
|
+
|
|
15474
|
+
|
|
15475
|
+
|
|
15476
|
+
|
|
15477
|
+
|
|
15478
|
+
|
|
15479
|
+
|
|
15480
|
+
|
|
15481
|
+
|
|
14516
15482
|
|
|
14517
15483
|
|
|
14518
15484
|
|
|
@@ -14723,6 +15689,30 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14723
15689
|
|
|
14724
15690
|
|
|
14725
15691
|
|
|
15692
|
+
|
|
15693
|
+
|
|
15694
|
+
|
|
15695
|
+
|
|
15696
|
+
|
|
15697
|
+
|
|
15698
|
+
|
|
15699
|
+
|
|
15700
|
+
|
|
15701
|
+
|
|
15702
|
+
|
|
15703
|
+
|
|
15704
|
+
|
|
15705
|
+
|
|
15706
|
+
|
|
15707
|
+
|
|
15708
|
+
|
|
15709
|
+
|
|
15710
|
+
|
|
15711
|
+
|
|
15712
|
+
|
|
15713
|
+
|
|
15714
|
+
|
|
15715
|
+
|
|
14726
15716
|
|
|
14727
15717
|
|
|
14728
15718
|
|
|
@@ -14889,6 +15879,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
14889
15879
|
|
|
14890
15880
|
|
|
14891
15881
|
|
|
15882
|
+
|
|
15883
|
+
|
|
15884
|
+
|
|
15885
|
+
|
|
15886
|
+
|
|
15887
|
+
|
|
15888
|
+
|
|
15889
|
+
|
|
15890
|
+
|
|
15891
|
+
|
|
15892
|
+
|
|
15893
|
+
|
|
15894
|
+
|
|
15895
|
+
|
|
15896
|
+
|
|
15897
|
+
|
|
15898
|
+
|
|
15899
|
+
|
|
15900
|
+
|
|
15901
|
+
|
|
14892
15902
|
|
|
14893
15903
|
|
|
14894
15904
|
|
|
@@ -15124,6 +16134,30 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15124
16134
|
|
|
15125
16135
|
|
|
15126
16136
|
|
|
16137
|
+
|
|
16138
|
+
|
|
16139
|
+
|
|
16140
|
+
|
|
16141
|
+
|
|
16142
|
+
|
|
16143
|
+
|
|
16144
|
+
|
|
16145
|
+
|
|
16146
|
+
|
|
16147
|
+
|
|
16148
|
+
|
|
16149
|
+
|
|
16150
|
+
|
|
16151
|
+
|
|
16152
|
+
|
|
16153
|
+
|
|
16154
|
+
|
|
16155
|
+
|
|
16156
|
+
|
|
16157
|
+
|
|
16158
|
+
|
|
16159
|
+
|
|
16160
|
+
|
|
15127
16161
|
|
|
15128
16162
|
|
|
15129
16163
|
|
|
@@ -15155,7 +16189,7 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15155
16189
|
*/
|
|
15156
16190
|
delete(key) {
|
|
15157
16191
|
this._validateKey(key);
|
|
15158
|
-
return this.#core.delete(key)
|
|
16192
|
+
return this.#core.delete(key);
|
|
15159
16193
|
}
|
|
15160
16194
|
/**
|
|
15161
16195
|
* Check if a specific value exists in a key's bucket.
|
|
@@ -15181,6 +16215,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15181
16215
|
|
|
15182
16216
|
|
|
15183
16217
|
|
|
16218
|
+
|
|
16219
|
+
|
|
16220
|
+
|
|
16221
|
+
|
|
15184
16222
|
|
|
15185
16223
|
|
|
15186
16224
|
|
|
@@ -15222,6 +16260,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15222
16260
|
|
|
15223
16261
|
|
|
15224
16262
|
|
|
16263
|
+
|
|
16264
|
+
|
|
16265
|
+
|
|
16266
|
+
|
|
15225
16267
|
|
|
15226
16268
|
|
|
15227
16269
|
|
|
@@ -15268,6 +16310,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15268
16310
|
|
|
15269
16311
|
|
|
15270
16312
|
|
|
16313
|
+
|
|
16314
|
+
|
|
16315
|
+
|
|
16316
|
+
|
|
15271
16317
|
|
|
15272
16318
|
|
|
15273
16319
|
|
|
@@ -15446,6 +16492,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15446
16492
|
|
|
15447
16493
|
|
|
15448
16494
|
|
|
16495
|
+
|
|
16496
|
+
|
|
16497
|
+
|
|
16498
|
+
|
|
16499
|
+
|
|
16500
|
+
|
|
16501
|
+
|
|
16502
|
+
|
|
16503
|
+
|
|
16504
|
+
|
|
16505
|
+
|
|
16506
|
+
|
|
16507
|
+
|
|
16508
|
+
|
|
16509
|
+
|
|
16510
|
+
|
|
16511
|
+
|
|
16512
|
+
|
|
16513
|
+
|
|
16514
|
+
|
|
15449
16515
|
|
|
15450
16516
|
|
|
15451
16517
|
|
|
@@ -15617,6 +16683,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15617
16683
|
|
|
15618
16684
|
|
|
15619
16685
|
|
|
16686
|
+
|
|
16687
|
+
|
|
16688
|
+
|
|
16689
|
+
|
|
16690
|
+
|
|
16691
|
+
|
|
16692
|
+
|
|
16693
|
+
|
|
16694
|
+
|
|
16695
|
+
|
|
16696
|
+
|
|
16697
|
+
|
|
16698
|
+
|
|
16699
|
+
|
|
16700
|
+
|
|
16701
|
+
|
|
16702
|
+
|
|
16703
|
+
|
|
16704
|
+
|
|
16705
|
+
|
|
15620
16706
|
|
|
15621
16707
|
|
|
15622
16708
|
|
|
@@ -15673,6 +16759,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15673
16759
|
|
|
15674
16760
|
|
|
15675
16761
|
|
|
16762
|
+
|
|
16763
|
+
|
|
16764
|
+
|
|
16765
|
+
|
|
15676
16766
|
|
|
15677
16767
|
|
|
15678
16768
|
|
|
@@ -15714,6 +16804,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15714
16804
|
|
|
15715
16805
|
|
|
15716
16806
|
|
|
16807
|
+
|
|
16808
|
+
|
|
16809
|
+
|
|
16810
|
+
|
|
15717
16811
|
|
|
15718
16812
|
|
|
15719
16813
|
|
|
@@ -15755,6 +16849,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15755
16849
|
|
|
15756
16850
|
|
|
15757
16851
|
|
|
16852
|
+
|
|
16853
|
+
|
|
16854
|
+
|
|
16855
|
+
|
|
15758
16856
|
|
|
15759
16857
|
|
|
15760
16858
|
|
|
@@ -15830,6 +16928,14 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15830
16928
|
|
|
15831
16929
|
|
|
15832
16930
|
|
|
16931
|
+
|
|
16932
|
+
|
|
16933
|
+
|
|
16934
|
+
|
|
16935
|
+
|
|
16936
|
+
|
|
16937
|
+
|
|
16938
|
+
|
|
15833
16939
|
|
|
15834
16940
|
|
|
15835
16941
|
|
|
@@ -15911,6 +17017,14 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15911
17017
|
|
|
15912
17018
|
|
|
15913
17019
|
|
|
17020
|
+
|
|
17021
|
+
|
|
17022
|
+
|
|
17023
|
+
|
|
17024
|
+
|
|
17025
|
+
|
|
17026
|
+
|
|
17027
|
+
|
|
15914
17028
|
|
|
15915
17029
|
|
|
15916
17030
|
|
|
@@ -15961,6 +17075,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
15961
17075
|
|
|
15962
17076
|
|
|
15963
17077
|
|
|
17078
|
+
|
|
17079
|
+
|
|
17080
|
+
|
|
17081
|
+
|
|
15964
17082
|
|
|
15965
17083
|
|
|
15966
17084
|
|
|
@@ -16006,6 +17124,10 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16006
17124
|
|
|
16007
17125
|
|
|
16008
17126
|
|
|
17127
|
+
|
|
17128
|
+
|
|
17129
|
+
|
|
17130
|
+
|
|
16009
17131
|
|
|
16010
17132
|
|
|
16011
17133
|
|
|
@@ -16168,6 +17290,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16168
17290
|
|
|
16169
17291
|
|
|
16170
17292
|
|
|
17293
|
+
|
|
17294
|
+
|
|
17295
|
+
|
|
17296
|
+
|
|
17297
|
+
|
|
17298
|
+
|
|
17299
|
+
|
|
17300
|
+
|
|
17301
|
+
|
|
17302
|
+
|
|
17303
|
+
|
|
17304
|
+
|
|
17305
|
+
|
|
17306
|
+
|
|
17307
|
+
|
|
17308
|
+
|
|
17309
|
+
|
|
17310
|
+
|
|
17311
|
+
|
|
17312
|
+
|
|
16171
17313
|
|
|
16172
17314
|
|
|
16173
17315
|
|
|
@@ -16350,6 +17492,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16350
17492
|
|
|
16351
17493
|
|
|
16352
17494
|
|
|
17495
|
+
|
|
17496
|
+
|
|
17497
|
+
|
|
17498
|
+
|
|
17499
|
+
|
|
17500
|
+
|
|
17501
|
+
|
|
17502
|
+
|
|
17503
|
+
|
|
17504
|
+
|
|
17505
|
+
|
|
17506
|
+
|
|
17507
|
+
|
|
17508
|
+
|
|
17509
|
+
|
|
17510
|
+
|
|
17511
|
+
|
|
17512
|
+
|
|
17513
|
+
|
|
17514
|
+
|
|
16353
17515
|
|
|
16354
17516
|
|
|
16355
17517
|
|
|
@@ -16501,6 +17663,22 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16501
17663
|
|
|
16502
17664
|
|
|
16503
17665
|
|
|
17666
|
+
|
|
17667
|
+
|
|
17668
|
+
|
|
17669
|
+
|
|
17670
|
+
|
|
17671
|
+
|
|
17672
|
+
|
|
17673
|
+
|
|
17674
|
+
|
|
17675
|
+
|
|
17676
|
+
|
|
17677
|
+
|
|
17678
|
+
|
|
17679
|
+
|
|
17680
|
+
|
|
17681
|
+
|
|
16504
17682
|
|
|
16505
17683
|
|
|
16506
17684
|
|
|
@@ -16647,6 +17825,22 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16647
17825
|
|
|
16648
17826
|
|
|
16649
17827
|
|
|
17828
|
+
|
|
17829
|
+
|
|
17830
|
+
|
|
17831
|
+
|
|
17832
|
+
|
|
17833
|
+
|
|
17834
|
+
|
|
17835
|
+
|
|
17836
|
+
|
|
17837
|
+
|
|
17838
|
+
|
|
17839
|
+
|
|
17840
|
+
|
|
17841
|
+
|
|
17842
|
+
|
|
17843
|
+
|
|
16650
17844
|
|
|
16651
17845
|
|
|
16652
17846
|
|
|
@@ -16822,6 +18016,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16822
18016
|
|
|
16823
18017
|
|
|
16824
18018
|
|
|
18019
|
+
|
|
18020
|
+
|
|
18021
|
+
|
|
18022
|
+
|
|
18023
|
+
|
|
18024
|
+
|
|
18025
|
+
|
|
18026
|
+
|
|
18027
|
+
|
|
18028
|
+
|
|
18029
|
+
|
|
18030
|
+
|
|
18031
|
+
|
|
18032
|
+
|
|
18033
|
+
|
|
18034
|
+
|
|
18035
|
+
|
|
18036
|
+
|
|
18037
|
+
|
|
18038
|
+
|
|
16825
18039
|
|
|
16826
18040
|
|
|
16827
18041
|
|
|
@@ -16992,6 +18206,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
16992
18206
|
|
|
16993
18207
|
|
|
16994
18208
|
|
|
18209
|
+
|
|
18210
|
+
|
|
18211
|
+
|
|
18212
|
+
|
|
18213
|
+
|
|
18214
|
+
|
|
18215
|
+
|
|
18216
|
+
|
|
18217
|
+
|
|
18218
|
+
|
|
18219
|
+
|
|
18220
|
+
|
|
18221
|
+
|
|
18222
|
+
|
|
18223
|
+
|
|
18224
|
+
|
|
18225
|
+
|
|
18226
|
+
|
|
18227
|
+
|
|
18228
|
+
|
|
16995
18229
|
|
|
16996
18230
|
|
|
16997
18231
|
|
|
@@ -17167,6 +18401,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17167
18401
|
|
|
17168
18402
|
|
|
17169
18403
|
|
|
18404
|
+
|
|
18405
|
+
|
|
18406
|
+
|
|
18407
|
+
|
|
18408
|
+
|
|
18409
|
+
|
|
18410
|
+
|
|
18411
|
+
|
|
18412
|
+
|
|
18413
|
+
|
|
18414
|
+
|
|
18415
|
+
|
|
18416
|
+
|
|
18417
|
+
|
|
18418
|
+
|
|
18419
|
+
|
|
18420
|
+
|
|
18421
|
+
|
|
18422
|
+
|
|
18423
|
+
|
|
17170
18424
|
|
|
17171
18425
|
|
|
17172
18426
|
|
|
@@ -17344,6 +18598,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17344
18598
|
|
|
17345
18599
|
|
|
17346
18600
|
|
|
18601
|
+
|
|
18602
|
+
|
|
18603
|
+
|
|
18604
|
+
|
|
18605
|
+
|
|
18606
|
+
|
|
18607
|
+
|
|
18608
|
+
|
|
18609
|
+
|
|
18610
|
+
|
|
18611
|
+
|
|
18612
|
+
|
|
18613
|
+
|
|
18614
|
+
|
|
18615
|
+
|
|
18616
|
+
|
|
18617
|
+
|
|
18618
|
+
|
|
18619
|
+
|
|
18620
|
+
|
|
17347
18621
|
|
|
17348
18622
|
|
|
17349
18623
|
|
|
@@ -17519,6 +18793,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17519
18793
|
|
|
17520
18794
|
|
|
17521
18795
|
|
|
18796
|
+
|
|
18797
|
+
|
|
18798
|
+
|
|
18799
|
+
|
|
18800
|
+
|
|
18801
|
+
|
|
18802
|
+
|
|
18803
|
+
|
|
18804
|
+
|
|
18805
|
+
|
|
18806
|
+
|
|
18807
|
+
|
|
18808
|
+
|
|
18809
|
+
|
|
18810
|
+
|
|
18811
|
+
|
|
18812
|
+
|
|
18813
|
+
|
|
18814
|
+
|
|
18815
|
+
|
|
17522
18816
|
|
|
17523
18817
|
|
|
17524
18818
|
|
|
@@ -17687,6 +18981,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17687
18981
|
|
|
17688
18982
|
|
|
17689
18983
|
|
|
18984
|
+
|
|
18985
|
+
|
|
18986
|
+
|
|
18987
|
+
|
|
18988
|
+
|
|
18989
|
+
|
|
18990
|
+
|
|
18991
|
+
|
|
18992
|
+
|
|
18993
|
+
|
|
18994
|
+
|
|
18995
|
+
|
|
18996
|
+
|
|
18997
|
+
|
|
18998
|
+
|
|
18999
|
+
|
|
19000
|
+
|
|
19001
|
+
|
|
19002
|
+
|
|
19003
|
+
|
|
17690
19004
|
|
|
17691
19005
|
|
|
17692
19006
|
|
|
@@ -17833,6 +19147,22 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
17833
19147
|
|
|
17834
19148
|
|
|
17835
19149
|
|
|
19150
|
+
|
|
19151
|
+
|
|
19152
|
+
|
|
19153
|
+
|
|
19154
|
+
|
|
19155
|
+
|
|
19156
|
+
|
|
19157
|
+
|
|
19158
|
+
|
|
19159
|
+
|
|
19160
|
+
|
|
19161
|
+
|
|
19162
|
+
|
|
19163
|
+
|
|
19164
|
+
|
|
19165
|
+
|
|
17836
19166
|
|
|
17837
19167
|
|
|
17838
19168
|
|
|
@@ -18053,8 +19383,16 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
18053
19383
|
/**
|
|
18054
19384
|
* Get elements by rank range
|
|
18055
19385
|
|
|
19386
|
+
|
|
19387
|
+
|
|
19388
|
+
|
|
19389
|
+
|
|
19390
|
+
|
|
19391
|
+
|
|
19392
|
+
|
|
19393
|
+
|
|
18056
19394
|
* @example
|
|
18057
|
-
* // Pagination
|
|
19395
|
+
* // Pagination by position in tree order
|
|
18058
19396
|
* const tree = new TreeMultiMap<number>(
|
|
18059
19397
|
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
18060
19398
|
* { enableOrderStatistic: true }
|
|
@@ -18077,6 +19415,26 @@ var TreeMultiMap = class _TreeMultiMap {
|
|
|
18077
19415
|
|
|
18078
19416
|
|
|
18079
19417
|
|
|
19418
|
+
|
|
19419
|
+
|
|
19420
|
+
|
|
19421
|
+
|
|
19422
|
+
|
|
19423
|
+
|
|
19424
|
+
|
|
19425
|
+
|
|
19426
|
+
|
|
19427
|
+
|
|
19428
|
+
|
|
19429
|
+
|
|
19430
|
+
|
|
19431
|
+
|
|
19432
|
+
|
|
19433
|
+
|
|
19434
|
+
|
|
19435
|
+
|
|
19436
|
+
|
|
19437
|
+
|
|
18080
19438
|
|
|
18081
19439
|
* @example
|
|
18082
19440
|
* // Deep clone
|
|
@@ -18330,6 +19688,26 @@ var TreeMap = class _TreeMap {
|
|
|
18330
19688
|
|
|
18331
19689
|
|
|
18332
19690
|
|
|
19691
|
+
|
|
19692
|
+
|
|
19693
|
+
|
|
19694
|
+
|
|
19695
|
+
|
|
19696
|
+
|
|
19697
|
+
|
|
19698
|
+
|
|
19699
|
+
|
|
19700
|
+
|
|
19701
|
+
|
|
19702
|
+
|
|
19703
|
+
|
|
19704
|
+
|
|
19705
|
+
|
|
19706
|
+
|
|
19707
|
+
|
|
19708
|
+
|
|
19709
|
+
|
|
19710
|
+
|
|
18333
19711
|
|
|
18334
19712
|
|
|
18335
19713
|
|
|
@@ -18507,6 +19885,26 @@ var TreeMap = class _TreeMap {
|
|
|
18507
19885
|
|
|
18508
19886
|
|
|
18509
19887
|
|
|
19888
|
+
|
|
19889
|
+
|
|
19890
|
+
|
|
19891
|
+
|
|
19892
|
+
|
|
19893
|
+
|
|
19894
|
+
|
|
19895
|
+
|
|
19896
|
+
|
|
19897
|
+
|
|
19898
|
+
|
|
19899
|
+
|
|
19900
|
+
|
|
19901
|
+
|
|
19902
|
+
|
|
19903
|
+
|
|
19904
|
+
|
|
19905
|
+
|
|
19906
|
+
|
|
19907
|
+
|
|
18510
19908
|
|
|
18511
19909
|
|
|
18512
19910
|
|
|
@@ -18554,6 +19952,41 @@ var TreeMap = class _TreeMap {
|
|
|
18554
19952
|
this.#core.set(key, value);
|
|
18555
19953
|
return this;
|
|
18556
19954
|
}
|
|
19955
|
+
/**
|
|
19956
|
+
* Set multiple key-value pairs at once.
|
|
19957
|
+
* @remarks Expected time O(m log n), where m is the number of entries.
|
|
19958
|
+
* @param entries - Iterable of `[key, value]` tuples.
|
|
19959
|
+
* @returns Array of booleans indicating whether each entry was successfully set.
|
|
19960
|
+
|
|
19961
|
+
|
|
19962
|
+
|
|
19963
|
+
|
|
19964
|
+
|
|
19965
|
+
|
|
19966
|
+
|
|
19967
|
+
|
|
19968
|
+
|
|
19969
|
+
|
|
19970
|
+
|
|
19971
|
+
|
|
19972
|
+
|
|
19973
|
+
|
|
19974
|
+
|
|
19975
|
+
|
|
19976
|
+
* @example
|
|
19977
|
+
* // Set multiple key-value pairs
|
|
19978
|
+
* const tm = new TreeMap<number, string>();
|
|
19979
|
+
* tm.setMany([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
19980
|
+
* console.log(tm.size); // 3;
|
|
19981
|
+
*/
|
|
19982
|
+
setMany(entries) {
|
|
19983
|
+
const results = [];
|
|
19984
|
+
for (const [key, value] of entries) {
|
|
19985
|
+
this._validateKey(key);
|
|
19986
|
+
results.push(this.#core.set(key, value));
|
|
19987
|
+
}
|
|
19988
|
+
return results;
|
|
19989
|
+
}
|
|
18557
19990
|
/**
|
|
18558
19991
|
* Get the value under a key.
|
|
18559
19992
|
* @remarks Expected time O(log n)
|
|
@@ -18705,6 +20138,26 @@ var TreeMap = class _TreeMap {
|
|
|
18705
20138
|
|
|
18706
20139
|
|
|
18707
20140
|
|
|
20141
|
+
|
|
20142
|
+
|
|
20143
|
+
|
|
20144
|
+
|
|
20145
|
+
|
|
20146
|
+
|
|
20147
|
+
|
|
20148
|
+
|
|
20149
|
+
|
|
20150
|
+
|
|
20151
|
+
|
|
20152
|
+
|
|
20153
|
+
|
|
20154
|
+
|
|
20155
|
+
|
|
20156
|
+
|
|
20157
|
+
|
|
20158
|
+
|
|
20159
|
+
|
|
20160
|
+
|
|
18708
20161
|
|
|
18709
20162
|
|
|
18710
20163
|
|
|
@@ -18893,6 +20346,26 @@ var TreeMap = class _TreeMap {
|
|
|
18893
20346
|
|
|
18894
20347
|
|
|
18895
20348
|
|
|
20349
|
+
|
|
20350
|
+
|
|
20351
|
+
|
|
20352
|
+
|
|
20353
|
+
|
|
20354
|
+
|
|
20355
|
+
|
|
20356
|
+
|
|
20357
|
+
|
|
20358
|
+
|
|
20359
|
+
|
|
20360
|
+
|
|
20361
|
+
|
|
20362
|
+
|
|
20363
|
+
|
|
20364
|
+
|
|
20365
|
+
|
|
20366
|
+
|
|
20367
|
+
|
|
20368
|
+
|
|
18896
20369
|
|
|
18897
20370
|
|
|
18898
20371
|
|
|
@@ -19081,6 +20554,26 @@ var TreeMap = class _TreeMap {
|
|
|
19081
20554
|
|
|
19082
20555
|
|
|
19083
20556
|
|
|
20557
|
+
|
|
20558
|
+
|
|
20559
|
+
|
|
20560
|
+
|
|
20561
|
+
|
|
20562
|
+
|
|
20563
|
+
|
|
20564
|
+
|
|
20565
|
+
|
|
20566
|
+
|
|
20567
|
+
|
|
20568
|
+
|
|
20569
|
+
|
|
20570
|
+
|
|
20571
|
+
|
|
20572
|
+
|
|
20573
|
+
|
|
20574
|
+
|
|
20575
|
+
|
|
20576
|
+
|
|
19084
20577
|
|
|
19085
20578
|
|
|
19086
20579
|
|
|
@@ -19117,8 +20610,24 @@ var TreeMap = class _TreeMap {
|
|
|
19117
20610
|
*/
|
|
19118
20611
|
delete(key) {
|
|
19119
20612
|
this._validateKey(key);
|
|
19120
|
-
|
|
19121
|
-
|
|
20613
|
+
return this.#core.delete(key);
|
|
20614
|
+
}
|
|
20615
|
+
/**
|
|
20616
|
+
* Delete all entries matching a predicate.
|
|
20617
|
+
* @remarks Time O(N), Space O(N)
|
|
20618
|
+
* @param predicate - Function (key, value, index, map) → boolean; return true to delete.
|
|
20619
|
+
* @returns True if at least one entry was deleted.
|
|
20620
|
+
*/
|
|
20621
|
+
deleteWhere(predicate) {
|
|
20622
|
+
let deleted = false;
|
|
20623
|
+
let index = 0;
|
|
20624
|
+
for (const [key, value] of this) {
|
|
20625
|
+
if (predicate(key, value, index++, this)) {
|
|
20626
|
+
this.delete(key);
|
|
20627
|
+
deleted = true;
|
|
20628
|
+
}
|
|
20629
|
+
}
|
|
20630
|
+
return deleted;
|
|
19122
20631
|
}
|
|
19123
20632
|
/**
|
|
19124
20633
|
* Remove all entries.
|
|
@@ -19259,6 +20768,26 @@ var TreeMap = class _TreeMap {
|
|
|
19259
20768
|
|
|
19260
20769
|
|
|
19261
20770
|
|
|
20771
|
+
|
|
20772
|
+
|
|
20773
|
+
|
|
20774
|
+
|
|
20775
|
+
|
|
20776
|
+
|
|
20777
|
+
|
|
20778
|
+
|
|
20779
|
+
|
|
20780
|
+
|
|
20781
|
+
|
|
20782
|
+
|
|
20783
|
+
|
|
20784
|
+
|
|
20785
|
+
|
|
20786
|
+
|
|
20787
|
+
|
|
20788
|
+
|
|
20789
|
+
|
|
20790
|
+
|
|
19262
20791
|
|
|
19263
20792
|
|
|
19264
20793
|
|
|
@@ -19428,6 +20957,26 @@ var TreeMap = class _TreeMap {
|
|
|
19428
20957
|
|
|
19429
20958
|
|
|
19430
20959
|
|
|
20960
|
+
|
|
20961
|
+
|
|
20962
|
+
|
|
20963
|
+
|
|
20964
|
+
|
|
20965
|
+
|
|
20966
|
+
|
|
20967
|
+
|
|
20968
|
+
|
|
20969
|
+
|
|
20970
|
+
|
|
20971
|
+
|
|
20972
|
+
|
|
20973
|
+
|
|
20974
|
+
|
|
20975
|
+
|
|
20976
|
+
|
|
20977
|
+
|
|
20978
|
+
|
|
20979
|
+
|
|
19431
20980
|
|
|
19432
20981
|
|
|
19433
20982
|
|
|
@@ -19601,6 +21150,26 @@ var TreeMap = class _TreeMap {
|
|
|
19601
21150
|
|
|
19602
21151
|
|
|
19603
21152
|
|
|
21153
|
+
|
|
21154
|
+
|
|
21155
|
+
|
|
21156
|
+
|
|
21157
|
+
|
|
21158
|
+
|
|
21159
|
+
|
|
21160
|
+
|
|
21161
|
+
|
|
21162
|
+
|
|
21163
|
+
|
|
21164
|
+
|
|
21165
|
+
|
|
21166
|
+
|
|
21167
|
+
|
|
21168
|
+
|
|
21169
|
+
|
|
21170
|
+
|
|
21171
|
+
|
|
21172
|
+
|
|
19604
21173
|
|
|
19605
21174
|
|
|
19606
21175
|
|
|
@@ -19771,6 +21340,26 @@ var TreeMap = class _TreeMap {
|
|
|
19771
21340
|
|
|
19772
21341
|
|
|
19773
21342
|
|
|
21343
|
+
|
|
21344
|
+
|
|
21345
|
+
|
|
21346
|
+
|
|
21347
|
+
|
|
21348
|
+
|
|
21349
|
+
|
|
21350
|
+
|
|
21351
|
+
|
|
21352
|
+
|
|
21353
|
+
|
|
21354
|
+
|
|
21355
|
+
|
|
21356
|
+
|
|
21357
|
+
|
|
21358
|
+
|
|
21359
|
+
|
|
21360
|
+
|
|
21361
|
+
|
|
21362
|
+
|
|
19774
21363
|
|
|
19775
21364
|
|
|
19776
21365
|
|
|
@@ -19944,6 +21533,26 @@ var TreeMap = class _TreeMap {
|
|
|
19944
21533
|
|
|
19945
21534
|
|
|
19946
21535
|
|
|
21536
|
+
|
|
21537
|
+
|
|
21538
|
+
|
|
21539
|
+
|
|
21540
|
+
|
|
21541
|
+
|
|
21542
|
+
|
|
21543
|
+
|
|
21544
|
+
|
|
21545
|
+
|
|
21546
|
+
|
|
21547
|
+
|
|
21548
|
+
|
|
21549
|
+
|
|
21550
|
+
|
|
21551
|
+
|
|
21552
|
+
|
|
21553
|
+
|
|
21554
|
+
|
|
21555
|
+
|
|
19947
21556
|
|
|
19948
21557
|
|
|
19949
21558
|
|
|
@@ -20117,6 +21726,26 @@ var TreeMap = class _TreeMap {
|
|
|
20117
21726
|
|
|
20118
21727
|
|
|
20119
21728
|
|
|
21729
|
+
|
|
21730
|
+
|
|
21731
|
+
|
|
21732
|
+
|
|
21733
|
+
|
|
21734
|
+
|
|
21735
|
+
|
|
21736
|
+
|
|
21737
|
+
|
|
21738
|
+
|
|
21739
|
+
|
|
21740
|
+
|
|
21741
|
+
|
|
21742
|
+
|
|
21743
|
+
|
|
21744
|
+
|
|
21745
|
+
|
|
21746
|
+
|
|
21747
|
+
|
|
21748
|
+
|
|
20120
21749
|
|
|
20121
21750
|
|
|
20122
21751
|
|
|
@@ -20293,6 +21922,26 @@ var TreeMap = class _TreeMap {
|
|
|
20293
21922
|
|
|
20294
21923
|
|
|
20295
21924
|
|
|
21925
|
+
|
|
21926
|
+
|
|
21927
|
+
|
|
21928
|
+
|
|
21929
|
+
|
|
21930
|
+
|
|
21931
|
+
|
|
21932
|
+
|
|
21933
|
+
|
|
21934
|
+
|
|
21935
|
+
|
|
21936
|
+
|
|
21937
|
+
|
|
21938
|
+
|
|
21939
|
+
|
|
21940
|
+
|
|
21941
|
+
|
|
21942
|
+
|
|
21943
|
+
|
|
21944
|
+
|
|
20296
21945
|
|
|
20297
21946
|
|
|
20298
21947
|
|
|
@@ -20469,6 +22118,26 @@ var TreeMap = class _TreeMap {
|
|
|
20469
22118
|
|
|
20470
22119
|
|
|
20471
22120
|
|
|
22121
|
+
|
|
22122
|
+
|
|
22123
|
+
|
|
22124
|
+
|
|
22125
|
+
|
|
22126
|
+
|
|
22127
|
+
|
|
22128
|
+
|
|
22129
|
+
|
|
22130
|
+
|
|
22131
|
+
|
|
22132
|
+
|
|
22133
|
+
|
|
22134
|
+
|
|
22135
|
+
|
|
22136
|
+
|
|
22137
|
+
|
|
22138
|
+
|
|
22139
|
+
|
|
22140
|
+
|
|
20472
22141
|
|
|
20473
22142
|
|
|
20474
22143
|
|
|
@@ -20639,6 +22308,26 @@ var TreeMap = class _TreeMap {
|
|
|
20639
22308
|
|
|
20640
22309
|
|
|
20641
22310
|
|
|
22311
|
+
|
|
22312
|
+
|
|
22313
|
+
|
|
22314
|
+
|
|
22315
|
+
|
|
22316
|
+
|
|
22317
|
+
|
|
22318
|
+
|
|
22319
|
+
|
|
22320
|
+
|
|
22321
|
+
|
|
22322
|
+
|
|
22323
|
+
|
|
22324
|
+
|
|
22325
|
+
|
|
22326
|
+
|
|
22327
|
+
|
|
22328
|
+
|
|
22329
|
+
|
|
22330
|
+
|
|
20642
22331
|
|
|
20643
22332
|
|
|
20644
22333
|
|
|
@@ -20811,6 +22500,26 @@ var TreeMap = class _TreeMap {
|
|
|
20811
22500
|
|
|
20812
22501
|
|
|
20813
22502
|
|
|
22503
|
+
|
|
22504
|
+
|
|
22505
|
+
|
|
22506
|
+
|
|
22507
|
+
|
|
22508
|
+
|
|
22509
|
+
|
|
22510
|
+
|
|
22511
|
+
|
|
22512
|
+
|
|
22513
|
+
|
|
22514
|
+
|
|
22515
|
+
|
|
22516
|
+
|
|
22517
|
+
|
|
22518
|
+
|
|
22519
|
+
|
|
22520
|
+
|
|
22521
|
+
|
|
22522
|
+
|
|
20814
22523
|
|
|
20815
22524
|
|
|
20816
22525
|
|
|
@@ -20984,6 +22693,26 @@ var TreeMap = class _TreeMap {
|
|
|
20984
22693
|
|
|
20985
22694
|
|
|
20986
22695
|
|
|
22696
|
+
|
|
22697
|
+
|
|
22698
|
+
|
|
22699
|
+
|
|
22700
|
+
|
|
22701
|
+
|
|
22702
|
+
|
|
22703
|
+
|
|
22704
|
+
|
|
22705
|
+
|
|
22706
|
+
|
|
22707
|
+
|
|
22708
|
+
|
|
22709
|
+
|
|
22710
|
+
|
|
22711
|
+
|
|
22712
|
+
|
|
22713
|
+
|
|
22714
|
+
|
|
22715
|
+
|
|
20987
22716
|
|
|
20988
22717
|
|
|
20989
22718
|
|
|
@@ -21158,6 +22887,26 @@ var TreeMap = class _TreeMap {
|
|
|
21158
22887
|
|
|
21159
22888
|
|
|
21160
22889
|
|
|
22890
|
+
|
|
22891
|
+
|
|
22892
|
+
|
|
22893
|
+
|
|
22894
|
+
|
|
22895
|
+
|
|
22896
|
+
|
|
22897
|
+
|
|
22898
|
+
|
|
22899
|
+
|
|
22900
|
+
|
|
22901
|
+
|
|
22902
|
+
|
|
22903
|
+
|
|
22904
|
+
|
|
22905
|
+
|
|
22906
|
+
|
|
22907
|
+
|
|
22908
|
+
|
|
22909
|
+
|
|
21161
22910
|
|
|
21162
22911
|
|
|
21163
22912
|
|
|
@@ -21327,6 +23076,26 @@ var TreeMap = class _TreeMap {
|
|
|
21327
23076
|
|
|
21328
23077
|
|
|
21329
23078
|
|
|
23079
|
+
|
|
23080
|
+
|
|
23081
|
+
|
|
23082
|
+
|
|
23083
|
+
|
|
23084
|
+
|
|
23085
|
+
|
|
23086
|
+
|
|
23087
|
+
|
|
23088
|
+
|
|
23089
|
+
|
|
23090
|
+
|
|
23091
|
+
|
|
23092
|
+
|
|
23093
|
+
|
|
23094
|
+
|
|
23095
|
+
|
|
23096
|
+
|
|
23097
|
+
|
|
23098
|
+
|
|
21330
23099
|
|
|
21331
23100
|
|
|
21332
23101
|
|
|
@@ -21390,6 +23159,10 @@ var TreeMap = class _TreeMap {
|
|
|
21390
23159
|
|
|
21391
23160
|
|
|
21392
23161
|
|
|
23162
|
+
|
|
23163
|
+
|
|
23164
|
+
|
|
23165
|
+
|
|
21393
23166
|
|
|
21394
23167
|
|
|
21395
23168
|
|
|
@@ -21458,6 +23231,10 @@ var TreeMap = class _TreeMap {
|
|
|
21458
23231
|
|
|
21459
23232
|
|
|
21460
23233
|
|
|
23234
|
+
|
|
23235
|
+
|
|
23236
|
+
|
|
23237
|
+
|
|
21461
23238
|
|
|
21462
23239
|
|
|
21463
23240
|
|
|
@@ -21510,6 +23287,10 @@ var TreeMap = class _TreeMap {
|
|
|
21510
23287
|
|
|
21511
23288
|
|
|
21512
23289
|
|
|
23290
|
+
|
|
23291
|
+
|
|
23292
|
+
|
|
23293
|
+
|
|
21513
23294
|
|
|
21514
23295
|
|
|
21515
23296
|
|
|
@@ -21566,6 +23347,10 @@ var TreeMap = class _TreeMap {
|
|
|
21566
23347
|
|
|
21567
23348
|
|
|
21568
23349
|
|
|
23350
|
+
|
|
23351
|
+
|
|
23352
|
+
|
|
23353
|
+
|
|
21569
23354
|
|
|
21570
23355
|
|
|
21571
23356
|
|
|
@@ -21709,6 +23494,22 @@ var TreeMap = class _TreeMap {
|
|
|
21709
23494
|
|
|
21710
23495
|
|
|
21711
23496
|
|
|
23497
|
+
|
|
23498
|
+
|
|
23499
|
+
|
|
23500
|
+
|
|
23501
|
+
|
|
23502
|
+
|
|
23503
|
+
|
|
23504
|
+
|
|
23505
|
+
|
|
23506
|
+
|
|
23507
|
+
|
|
23508
|
+
|
|
23509
|
+
|
|
23510
|
+
|
|
23511
|
+
|
|
23512
|
+
|
|
21712
23513
|
|
|
21713
23514
|
|
|
21714
23515
|
|
|
@@ -21882,6 +23683,22 @@ var TreeMap = class _TreeMap {
|
|
|
21882
23683
|
|
|
21883
23684
|
|
|
21884
23685
|
|
|
23686
|
+
|
|
23687
|
+
|
|
23688
|
+
|
|
23689
|
+
|
|
23690
|
+
|
|
23691
|
+
|
|
23692
|
+
|
|
23693
|
+
|
|
23694
|
+
|
|
23695
|
+
|
|
23696
|
+
|
|
23697
|
+
|
|
23698
|
+
|
|
23699
|
+
|
|
23700
|
+
|
|
23701
|
+
|
|
21885
23702
|
|
|
21886
23703
|
|
|
21887
23704
|
|
|
@@ -22039,6 +23856,22 @@ var TreeMap = class _TreeMap {
|
|
|
22039
23856
|
|
|
22040
23857
|
|
|
22041
23858
|
|
|
23859
|
+
|
|
23860
|
+
|
|
23861
|
+
|
|
23862
|
+
|
|
23863
|
+
|
|
23864
|
+
|
|
23865
|
+
|
|
23866
|
+
|
|
23867
|
+
|
|
23868
|
+
|
|
23869
|
+
|
|
23870
|
+
|
|
23871
|
+
|
|
23872
|
+
|
|
23873
|
+
|
|
23874
|
+
|
|
22042
23875
|
|
|
22043
23876
|
|
|
22044
23877
|
|
|
@@ -22196,6 +24029,22 @@ var TreeMap = class _TreeMap {
|
|
|
22196
24029
|
|
|
22197
24030
|
|
|
22198
24031
|
|
|
24032
|
+
|
|
24033
|
+
|
|
24034
|
+
|
|
24035
|
+
|
|
24036
|
+
|
|
24037
|
+
|
|
24038
|
+
|
|
24039
|
+
|
|
24040
|
+
|
|
24041
|
+
|
|
24042
|
+
|
|
24043
|
+
|
|
24044
|
+
|
|
24045
|
+
|
|
24046
|
+
|
|
24047
|
+
|
|
22199
24048
|
|
|
22200
24049
|
|
|
22201
24050
|
|
|
@@ -22354,6 +24203,22 @@ var TreeMap = class _TreeMap {
|
|
|
22354
24203
|
|
|
22355
24204
|
|
|
22356
24205
|
|
|
24206
|
+
|
|
24207
|
+
|
|
24208
|
+
|
|
24209
|
+
|
|
24210
|
+
|
|
24211
|
+
|
|
24212
|
+
|
|
24213
|
+
|
|
24214
|
+
|
|
24215
|
+
|
|
24216
|
+
|
|
24217
|
+
|
|
24218
|
+
|
|
24219
|
+
|
|
24220
|
+
|
|
24221
|
+
|
|
22357
24222
|
|
|
22358
24223
|
|
|
22359
24224
|
|
|
@@ -22461,8 +24326,16 @@ var TreeMap = class _TreeMap {
|
|
|
22461
24326
|
* Returns keys by rank range (0-indexed, inclusive on both ends).
|
|
22462
24327
|
* @remarks Time O(log n + k). Requires `enableOrderStatistic: true`.
|
|
22463
24328
|
|
|
24329
|
+
|
|
24330
|
+
|
|
24331
|
+
|
|
24332
|
+
|
|
24333
|
+
|
|
24334
|
+
|
|
24335
|
+
|
|
24336
|
+
|
|
22464
24337
|
* @example
|
|
22465
|
-
* // Pagination
|
|
24338
|
+
* // Pagination by position in tree order
|
|
22466
24339
|
* const tree = new TreeMap<number>(
|
|
22467
24340
|
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
22468
24341
|
* { enableOrderStatistic: true }
|
|
@@ -22621,6 +24494,26 @@ var TreeMap = class _TreeMap {
|
|
|
22621
24494
|
|
|
22622
24495
|
|
|
22623
24496
|
|
|
24497
|
+
|
|
24498
|
+
|
|
24499
|
+
|
|
24500
|
+
|
|
24501
|
+
|
|
24502
|
+
|
|
24503
|
+
|
|
24504
|
+
|
|
24505
|
+
|
|
24506
|
+
|
|
24507
|
+
|
|
24508
|
+
|
|
24509
|
+
|
|
24510
|
+
|
|
24511
|
+
|
|
24512
|
+
|
|
24513
|
+
|
|
24514
|
+
|
|
24515
|
+
|
|
24516
|
+
|
|
22624
24517
|
|
|
22625
24518
|
|
|
22626
24519
|
|
|
@@ -22744,6 +24637,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
22744
24637
|
|
|
22745
24638
|
|
|
22746
24639
|
|
|
24640
|
+
|
|
24641
|
+
|
|
24642
|
+
|
|
24643
|
+
|
|
22747
24644
|
|
|
22748
24645
|
|
|
22749
24646
|
|
|
@@ -22899,6 +24796,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
22899
24796
|
|
|
22900
24797
|
|
|
22901
24798
|
|
|
24799
|
+
|
|
24800
|
+
|
|
24801
|
+
|
|
24802
|
+
|
|
24803
|
+
|
|
24804
|
+
|
|
24805
|
+
|
|
24806
|
+
|
|
24807
|
+
|
|
24808
|
+
|
|
24809
|
+
|
|
24810
|
+
|
|
24811
|
+
|
|
24812
|
+
|
|
24813
|
+
|
|
24814
|
+
|
|
24815
|
+
|
|
24816
|
+
|
|
24817
|
+
|
|
24818
|
+
|
|
22902
24819
|
|
|
22903
24820
|
|
|
22904
24821
|
|
|
@@ -23070,6 +24987,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23070
24987
|
|
|
23071
24988
|
|
|
23072
24989
|
|
|
24990
|
+
|
|
24991
|
+
|
|
24992
|
+
|
|
24993
|
+
|
|
24994
|
+
|
|
24995
|
+
|
|
24996
|
+
|
|
24997
|
+
|
|
24998
|
+
|
|
24999
|
+
|
|
25000
|
+
|
|
25001
|
+
|
|
25002
|
+
|
|
25003
|
+
|
|
25004
|
+
|
|
25005
|
+
|
|
25006
|
+
|
|
25007
|
+
|
|
25008
|
+
|
|
25009
|
+
|
|
23073
25010
|
|
|
23074
25011
|
|
|
23075
25012
|
|
|
@@ -23126,6 +25063,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23126
25063
|
|
|
23127
25064
|
|
|
23128
25065
|
|
|
25066
|
+
|
|
25067
|
+
|
|
25068
|
+
|
|
25069
|
+
|
|
23129
25070
|
|
|
23130
25071
|
|
|
23131
25072
|
|
|
@@ -23276,6 +25217,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23276
25217
|
|
|
23277
25218
|
|
|
23278
25219
|
|
|
25220
|
+
|
|
25221
|
+
|
|
25222
|
+
|
|
25223
|
+
|
|
25224
|
+
|
|
25225
|
+
|
|
25226
|
+
|
|
25227
|
+
|
|
25228
|
+
|
|
25229
|
+
|
|
25230
|
+
|
|
25231
|
+
|
|
25232
|
+
|
|
25233
|
+
|
|
25234
|
+
|
|
25235
|
+
|
|
25236
|
+
|
|
25237
|
+
|
|
25238
|
+
|
|
25239
|
+
|
|
23279
25240
|
|
|
23280
25241
|
|
|
23281
25242
|
|
|
@@ -23341,6 +25302,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23341
25302
|
|
|
23342
25303
|
|
|
23343
25304
|
|
|
25305
|
+
|
|
25306
|
+
|
|
25307
|
+
|
|
25308
|
+
|
|
23344
25309
|
|
|
23345
25310
|
|
|
23346
25311
|
|
|
@@ -23509,6 +25474,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23509
25474
|
|
|
23510
25475
|
|
|
23511
25476
|
|
|
25477
|
+
|
|
25478
|
+
|
|
25479
|
+
|
|
25480
|
+
|
|
25481
|
+
|
|
25482
|
+
|
|
25483
|
+
|
|
25484
|
+
|
|
25485
|
+
|
|
25486
|
+
|
|
25487
|
+
|
|
25488
|
+
|
|
25489
|
+
|
|
25490
|
+
|
|
25491
|
+
|
|
25492
|
+
|
|
25493
|
+
|
|
25494
|
+
|
|
25495
|
+
|
|
25496
|
+
|
|
23512
25497
|
|
|
23513
25498
|
|
|
23514
25499
|
|
|
@@ -23575,6 +25560,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23575
25560
|
|
|
23576
25561
|
|
|
23577
25562
|
|
|
25563
|
+
|
|
25564
|
+
|
|
25565
|
+
|
|
25566
|
+
|
|
23578
25567
|
|
|
23579
25568
|
|
|
23580
25569
|
|
|
@@ -23619,6 +25608,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23619
25608
|
|
|
23620
25609
|
|
|
23621
25610
|
|
|
25611
|
+
|
|
25612
|
+
|
|
25613
|
+
|
|
25614
|
+
|
|
23622
25615
|
|
|
23623
25616
|
|
|
23624
25617
|
|
|
@@ -23774,6 +25767,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23774
25767
|
|
|
23775
25768
|
|
|
23776
25769
|
|
|
25770
|
+
|
|
25771
|
+
|
|
25772
|
+
|
|
25773
|
+
|
|
25774
|
+
|
|
25775
|
+
|
|
25776
|
+
|
|
25777
|
+
|
|
25778
|
+
|
|
25779
|
+
|
|
25780
|
+
|
|
25781
|
+
|
|
25782
|
+
|
|
25783
|
+
|
|
25784
|
+
|
|
25785
|
+
|
|
25786
|
+
|
|
25787
|
+
|
|
25788
|
+
|
|
25789
|
+
|
|
23777
25790
|
|
|
23778
25791
|
|
|
23779
25792
|
|
|
@@ -23955,6 +25968,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
23955
25968
|
|
|
23956
25969
|
|
|
23957
25970
|
|
|
25971
|
+
|
|
25972
|
+
|
|
25973
|
+
|
|
25974
|
+
|
|
25975
|
+
|
|
25976
|
+
|
|
25977
|
+
|
|
25978
|
+
|
|
25979
|
+
|
|
25980
|
+
|
|
25981
|
+
|
|
25982
|
+
|
|
25983
|
+
|
|
25984
|
+
|
|
25985
|
+
|
|
25986
|
+
|
|
25987
|
+
|
|
25988
|
+
|
|
25989
|
+
|
|
25990
|
+
|
|
23958
25991
|
|
|
23959
25992
|
|
|
23960
25993
|
|
|
@@ -24010,6 +26043,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24010
26043
|
|
|
24011
26044
|
|
|
24012
26045
|
|
|
26046
|
+
|
|
26047
|
+
|
|
26048
|
+
|
|
26049
|
+
|
|
24013
26050
|
|
|
24014
26051
|
|
|
24015
26052
|
|
|
@@ -24049,6 +26086,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24049
26086
|
|
|
24050
26087
|
|
|
24051
26088
|
|
|
26089
|
+
|
|
26090
|
+
|
|
26091
|
+
|
|
26092
|
+
|
|
24052
26093
|
|
|
24053
26094
|
|
|
24054
26095
|
|
|
@@ -24213,6 +26254,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24213
26254
|
|
|
24214
26255
|
|
|
24215
26256
|
|
|
26257
|
+
|
|
26258
|
+
|
|
26259
|
+
|
|
26260
|
+
|
|
26261
|
+
|
|
26262
|
+
|
|
26263
|
+
|
|
26264
|
+
|
|
26265
|
+
|
|
26266
|
+
|
|
26267
|
+
|
|
26268
|
+
|
|
26269
|
+
|
|
26270
|
+
|
|
26271
|
+
|
|
26272
|
+
|
|
26273
|
+
|
|
26274
|
+
|
|
26275
|
+
|
|
26276
|
+
|
|
24216
26277
|
|
|
24217
26278
|
|
|
24218
26279
|
|
|
@@ -24271,6 +26332,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24271
26332
|
|
|
24272
26333
|
|
|
24273
26334
|
|
|
26335
|
+
|
|
26336
|
+
|
|
26337
|
+
|
|
26338
|
+
|
|
24274
26339
|
|
|
24275
26340
|
|
|
24276
26341
|
|
|
@@ -24311,6 +26376,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24311
26376
|
|
|
24312
26377
|
|
|
24313
26378
|
|
|
26379
|
+
|
|
26380
|
+
|
|
26381
|
+
|
|
26382
|
+
|
|
24314
26383
|
|
|
24315
26384
|
|
|
24316
26385
|
|
|
@@ -24351,6 +26420,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24351
26420
|
|
|
24352
26421
|
|
|
24353
26422
|
|
|
26423
|
+
|
|
26424
|
+
|
|
26425
|
+
|
|
26426
|
+
|
|
24354
26427
|
|
|
24355
26428
|
|
|
24356
26429
|
|
|
@@ -24395,6 +26468,10 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24395
26468
|
|
|
24396
26469
|
|
|
24397
26470
|
|
|
26471
|
+
|
|
26472
|
+
|
|
26473
|
+
|
|
26474
|
+
|
|
24398
26475
|
|
|
24399
26476
|
|
|
24400
26477
|
|
|
@@ -24525,6 +26602,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24525
26602
|
|
|
24526
26603
|
|
|
24527
26604
|
|
|
26605
|
+
|
|
26606
|
+
|
|
26607
|
+
|
|
26608
|
+
|
|
26609
|
+
|
|
26610
|
+
|
|
26611
|
+
|
|
26612
|
+
|
|
26613
|
+
|
|
26614
|
+
|
|
26615
|
+
|
|
26616
|
+
|
|
26617
|
+
|
|
26618
|
+
|
|
26619
|
+
|
|
26620
|
+
|
|
24528
26621
|
|
|
24529
26622
|
|
|
24530
26623
|
|
|
@@ -24666,6 +26759,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24666
26759
|
|
|
24667
26760
|
|
|
24668
26761
|
|
|
26762
|
+
|
|
26763
|
+
|
|
26764
|
+
|
|
26765
|
+
|
|
26766
|
+
|
|
26767
|
+
|
|
26768
|
+
|
|
26769
|
+
|
|
26770
|
+
|
|
26771
|
+
|
|
26772
|
+
|
|
26773
|
+
|
|
26774
|
+
|
|
26775
|
+
|
|
26776
|
+
|
|
26777
|
+
|
|
24669
26778
|
|
|
24670
26779
|
|
|
24671
26780
|
|
|
@@ -24807,6 +26916,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24807
26916
|
|
|
24808
26917
|
|
|
24809
26918
|
|
|
26919
|
+
|
|
26920
|
+
|
|
26921
|
+
|
|
26922
|
+
|
|
26923
|
+
|
|
26924
|
+
|
|
26925
|
+
|
|
26926
|
+
|
|
26927
|
+
|
|
26928
|
+
|
|
26929
|
+
|
|
26930
|
+
|
|
26931
|
+
|
|
26932
|
+
|
|
26933
|
+
|
|
26934
|
+
|
|
24810
26935
|
|
|
24811
26936
|
|
|
24812
26937
|
|
|
@@ -24947,6 +27072,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
24947
27072
|
|
|
24948
27073
|
|
|
24949
27074
|
|
|
27075
|
+
|
|
27076
|
+
|
|
27077
|
+
|
|
27078
|
+
|
|
27079
|
+
|
|
27080
|
+
|
|
27081
|
+
|
|
27082
|
+
|
|
27083
|
+
|
|
27084
|
+
|
|
27085
|
+
|
|
27086
|
+
|
|
27087
|
+
|
|
27088
|
+
|
|
27089
|
+
|
|
27090
|
+
|
|
24950
27091
|
|
|
24951
27092
|
|
|
24952
27093
|
|
|
@@ -25117,6 +27258,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25117
27258
|
|
|
25118
27259
|
|
|
25119
27260
|
|
|
27261
|
+
|
|
27262
|
+
|
|
27263
|
+
|
|
27264
|
+
|
|
27265
|
+
|
|
27266
|
+
|
|
27267
|
+
|
|
27268
|
+
|
|
27269
|
+
|
|
27270
|
+
|
|
27271
|
+
|
|
27272
|
+
|
|
27273
|
+
|
|
27274
|
+
|
|
27275
|
+
|
|
27276
|
+
|
|
27277
|
+
|
|
27278
|
+
|
|
27279
|
+
|
|
27280
|
+
|
|
25120
27281
|
|
|
25121
27282
|
|
|
25122
27283
|
|
|
@@ -25293,6 +27454,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25293
27454
|
|
|
25294
27455
|
|
|
25295
27456
|
|
|
27457
|
+
|
|
27458
|
+
|
|
27459
|
+
|
|
27460
|
+
|
|
27461
|
+
|
|
27462
|
+
|
|
27463
|
+
|
|
27464
|
+
|
|
27465
|
+
|
|
27466
|
+
|
|
27467
|
+
|
|
27468
|
+
|
|
27469
|
+
|
|
27470
|
+
|
|
27471
|
+
|
|
27472
|
+
|
|
27473
|
+
|
|
27474
|
+
|
|
27475
|
+
|
|
27476
|
+
|
|
25296
27477
|
|
|
25297
27478
|
|
|
25298
27479
|
|
|
@@ -25476,6 +27657,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25476
27657
|
|
|
25477
27658
|
|
|
25478
27659
|
|
|
27660
|
+
|
|
27661
|
+
|
|
27662
|
+
|
|
27663
|
+
|
|
27664
|
+
|
|
27665
|
+
|
|
27666
|
+
|
|
27667
|
+
|
|
27668
|
+
|
|
27669
|
+
|
|
27670
|
+
|
|
27671
|
+
|
|
27672
|
+
|
|
27673
|
+
|
|
27674
|
+
|
|
27675
|
+
|
|
27676
|
+
|
|
27677
|
+
|
|
27678
|
+
|
|
27679
|
+
|
|
25479
27680
|
|
|
25480
27681
|
|
|
25481
27682
|
|
|
@@ -25654,6 +27855,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25654
27855
|
|
|
25655
27856
|
|
|
25656
27857
|
|
|
27858
|
+
|
|
27859
|
+
|
|
27860
|
+
|
|
27861
|
+
|
|
27862
|
+
|
|
27863
|
+
|
|
27864
|
+
|
|
27865
|
+
|
|
27866
|
+
|
|
27867
|
+
|
|
27868
|
+
|
|
27869
|
+
|
|
27870
|
+
|
|
27871
|
+
|
|
27872
|
+
|
|
27873
|
+
|
|
27874
|
+
|
|
27875
|
+
|
|
27876
|
+
|
|
27877
|
+
|
|
25657
27878
|
|
|
25658
27879
|
|
|
25659
27880
|
|
|
@@ -25884,8 +28105,16 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25884
28105
|
/**
|
|
25885
28106
|
* Get elements by rank range
|
|
25886
28107
|
|
|
28108
|
+
|
|
28109
|
+
|
|
28110
|
+
|
|
28111
|
+
|
|
28112
|
+
|
|
28113
|
+
|
|
28114
|
+
|
|
28115
|
+
|
|
25887
28116
|
* @example
|
|
25888
|
-
* // Pagination
|
|
28117
|
+
* // Pagination by position in tree order
|
|
25889
28118
|
* const tree = new TreeMultiSet<number>(
|
|
25890
28119
|
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
25891
28120
|
* { enableOrderStatistic: true }
|
|
@@ -25907,6 +28136,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
25907
28136
|
|
|
25908
28137
|
|
|
25909
28138
|
|
|
28139
|
+
|
|
28140
|
+
|
|
28141
|
+
|
|
28142
|
+
|
|
28143
|
+
|
|
28144
|
+
|
|
28145
|
+
|
|
28146
|
+
|
|
28147
|
+
|
|
28148
|
+
|
|
28149
|
+
|
|
28150
|
+
|
|
28151
|
+
|
|
28152
|
+
|
|
28153
|
+
|
|
28154
|
+
|
|
28155
|
+
|
|
28156
|
+
|
|
28157
|
+
|
|
28158
|
+
|
|
25910
28159
|
|
|
25911
28160
|
* @example
|
|
25912
28161
|
* // Deep clone
|
|
@@ -26039,6 +28288,22 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
26039
28288
|
|
|
26040
28289
|
|
|
26041
28290
|
|
|
28291
|
+
|
|
28292
|
+
|
|
28293
|
+
|
|
28294
|
+
|
|
28295
|
+
|
|
28296
|
+
|
|
28297
|
+
|
|
28298
|
+
|
|
28299
|
+
|
|
28300
|
+
|
|
28301
|
+
|
|
28302
|
+
|
|
28303
|
+
|
|
28304
|
+
|
|
28305
|
+
|
|
28306
|
+
|
|
26042
28307
|
|
|
26043
28308
|
|
|
26044
28309
|
|
|
@@ -26210,6 +28475,26 @@ var TreeMultiSet = class _TreeMultiSet {
|
|
|
26210
28475
|
|
|
26211
28476
|
|
|
26212
28477
|
|
|
28478
|
+
|
|
28479
|
+
|
|
28480
|
+
|
|
28481
|
+
|
|
28482
|
+
|
|
28483
|
+
|
|
28484
|
+
|
|
28485
|
+
|
|
28486
|
+
|
|
28487
|
+
|
|
28488
|
+
|
|
28489
|
+
|
|
28490
|
+
|
|
28491
|
+
|
|
28492
|
+
|
|
28493
|
+
|
|
28494
|
+
|
|
28495
|
+
|
|
28496
|
+
|
|
28497
|
+
|
|
26213
28498
|
|
|
26214
28499
|
|
|
26215
28500
|
|