bst-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/dist/cjs/index.cjs +241 -59
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +241 -59
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +241 -59
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +241 -59
- package/dist/esm-legacy/index.mjs.map +1 -1
- 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/bst-typed.js +241 -59
- package/dist/umd/bst-typed.js.map +1 -1
- package/dist/umd/bst-typed.min.js +2 -2
- package/dist/umd/bst-typed.min.js.map +1 -1
- package/package.json +2 -2
- 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/dist/cjs/index.cjs
CHANGED
|
@@ -802,6 +802,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
802
802
|
|
|
803
803
|
|
|
804
804
|
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
805
809
|
|
|
806
810
|
|
|
807
811
|
|
|
@@ -852,6 +856,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
852
856
|
|
|
853
857
|
|
|
854
858
|
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
|
|
855
863
|
|
|
856
864
|
|
|
857
865
|
|
|
@@ -866,6 +874,14 @@ var Queue = class _Queue extends LinearBase {
|
|
|
866
874
|
get first() {
|
|
867
875
|
return this.length > 0 ? this.elements[this._offset] : void 0;
|
|
868
876
|
}
|
|
877
|
+
/**
|
|
878
|
+
* Peek at the front element without removing it (alias for `first`).
|
|
879
|
+
* @remarks Time O(1), Space O(1)
|
|
880
|
+
* @returns Front element or undefined.
|
|
881
|
+
*/
|
|
882
|
+
peek() {
|
|
883
|
+
return this.first;
|
|
884
|
+
}
|
|
869
885
|
/**
|
|
870
886
|
* Get the last element (back) without removing it.
|
|
871
887
|
* @remarks Time O(1), Space O(1)
|
|
@@ -918,6 +934,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
918
934
|
|
|
919
935
|
|
|
920
936
|
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
921
941
|
|
|
922
942
|
|
|
923
943
|
|
|
@@ -980,6 +1000,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
980
1000
|
|
|
981
1001
|
|
|
982
1002
|
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
983
1007
|
|
|
984
1008
|
|
|
985
1009
|
|
|
@@ -1049,6 +1073,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1049
1073
|
|
|
1050
1074
|
|
|
1051
1075
|
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
|
|
1052
1080
|
|
|
1053
1081
|
|
|
1054
1082
|
|
|
@@ -1108,6 +1136,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1108
1136
|
|
|
1109
1137
|
|
|
1110
1138
|
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
|
|
1111
1143
|
|
|
1112
1144
|
|
|
1113
1145
|
|
|
@@ -1160,6 +1192,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1160
1192
|
|
|
1161
1193
|
|
|
1162
1194
|
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1163
1199
|
|
|
1164
1200
|
|
|
1165
1201
|
|
|
@@ -1211,6 +1247,21 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1211
1247
|
this._elements[this._offset + index] = newElement;
|
|
1212
1248
|
return true;
|
|
1213
1249
|
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Delete the first element that satisfies a predicate.
|
|
1252
|
+
* @remarks Time O(N), Space O(N)
|
|
1253
|
+
* @param predicate - Function (value, index, queue) → boolean to decide deletion.
|
|
1254
|
+
* @returns True if a match was removed.
|
|
1255
|
+
*/
|
|
1256
|
+
deleteWhere(predicate) {
|
|
1257
|
+
for (let i = 0; i < this.length; i++) {
|
|
1258
|
+
if (predicate(this._elements[this._offset + i], i, this)) {
|
|
1259
|
+
this.deleteAt(i);
|
|
1260
|
+
return true;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
return false;
|
|
1264
|
+
}
|
|
1214
1265
|
/**
|
|
1215
1266
|
* Reverse the queue in-place by compacting then reversing.
|
|
1216
1267
|
* @remarks Time O(N), Space O(N)
|
|
@@ -1253,6 +1304,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1253
1304
|
|
|
1254
1305
|
|
|
1255
1306
|
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
|
|
1310
|
+
|
|
1256
1311
|
|
|
1257
1312
|
|
|
1258
1313
|
|
|
@@ -1299,6 +1354,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1299
1354
|
|
|
1300
1355
|
|
|
1301
1356
|
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1302
1361
|
|
|
1303
1362
|
|
|
1304
1363
|
|
|
@@ -1368,6 +1427,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1368
1427
|
|
|
1369
1428
|
|
|
1370
1429
|
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1371
1434
|
|
|
1372
1435
|
|
|
1373
1436
|
|
|
@@ -1421,6 +1484,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1421
1484
|
|
|
1422
1485
|
|
|
1423
1486
|
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
|
|
1424
1491
|
|
|
1425
1492
|
|
|
1426
1493
|
|
|
@@ -1478,6 +1545,10 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1478
1545
|
|
|
1479
1546
|
|
|
1480
1547
|
|
|
1548
|
+
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
|
|
1481
1552
|
|
|
1482
1553
|
|
|
1483
1554
|
|
|
@@ -1949,7 +2020,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1949
2020
|
}
|
|
1950
2021
|
/**
|
|
1951
2022
|
* Adds a new node to the tree.
|
|
1952
|
-
* @remarks Time O(
|
|
2023
|
+
* @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).
|
|
1953
2024
|
*
|
|
1954
2025
|
* @param keyNodeOrEntry - The key, node, or entry to add.
|
|
1955
2026
|
* @returns True if the addition was successful, false otherwise.
|
|
@@ -1978,6 +2049,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1978
2049
|
|
|
1979
2050
|
|
|
1980
2051
|
|
|
2052
|
+
|
|
2053
|
+
|
|
2054
|
+
|
|
2055
|
+
|
|
1981
2056
|
|
|
1982
2057
|
|
|
1983
2058
|
|
|
@@ -1997,7 +2072,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1997
2072
|
}
|
|
1998
2073
|
/**
|
|
1999
2074
|
* Adds or updates a new node to the tree.
|
|
2000
|
-
* @remarks Time O(
|
|
2075
|
+
* @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).
|
|
2001
2076
|
*
|
|
2002
2077
|
* @param keyNodeOrEntry - The key, node, or entry to set or update.
|
|
2003
2078
|
* @param [value] - The value, if providing just a key.
|
|
@@ -2032,6 +2107,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2032
2107
|
|
|
2033
2108
|
|
|
2034
2109
|
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
|
|
2113
|
+
|
|
2035
2114
|
|
|
2036
2115
|
|
|
2037
2116
|
|
|
@@ -2138,6 +2217,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2138
2217
|
|
|
2139
2218
|
|
|
2140
2219
|
|
|
2220
|
+
|
|
2221
|
+
|
|
2222
|
+
|
|
2223
|
+
|
|
2141
2224
|
|
|
2142
2225
|
|
|
2143
2226
|
|
|
@@ -2180,6 +2263,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2180
2263
|
|
|
2181
2264
|
|
|
2182
2265
|
|
|
2266
|
+
|
|
2267
|
+
|
|
2268
|
+
|
|
2269
|
+
|
|
2183
2270
|
|
|
2184
2271
|
|
|
2185
2272
|
|
|
@@ -2243,6 +2330,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2243
2330
|
|
|
2244
2331
|
|
|
2245
2332
|
|
|
2333
|
+
|
|
2334
|
+
|
|
2335
|
+
|
|
2336
|
+
|
|
2246
2337
|
|
|
2247
2338
|
|
|
2248
2339
|
|
|
@@ -2259,22 +2350,66 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2259
2350
|
this.setMany(anotherTree, []);
|
|
2260
2351
|
}
|
|
2261
2352
|
/**
|
|
2262
|
-
*
|
|
2263
|
-
* @remarks Time O(N)
|
|
2353
|
+
* Deletes a node from the tree (internal, returns balancing metadata).
|
|
2354
|
+
* @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).
|
|
2355
|
+
* @internal Used by AVL/BST subclasses that need balancing metadata after deletion.
|
|
2264
2356
|
*
|
|
2265
|
-
* @param
|
|
2266
|
-
* @
|
|
2357
|
+
* @param keyNodeEntryRawOrPredicate - The node to delete.
|
|
2358
|
+
* @returns An array containing deletion results with balancing metadata.
|
|
2267
2359
|
*/
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
this.
|
|
2360
|
+
_deleteInternal(keyNodeEntryRawOrPredicate) {
|
|
2361
|
+
const deletedResult = [];
|
|
2362
|
+
if (!this._root) return deletedResult;
|
|
2363
|
+
const curr = this.getNode(keyNodeEntryRawOrPredicate);
|
|
2364
|
+
if (!curr) return deletedResult;
|
|
2365
|
+
const parent = curr?.parent;
|
|
2366
|
+
let needBalanced;
|
|
2367
|
+
let orgCurrent = curr;
|
|
2368
|
+
if (!curr.left && !curr.right && !parent) {
|
|
2369
|
+
this._setRoot(void 0);
|
|
2370
|
+
} else if (curr.left) {
|
|
2371
|
+
const leftSubTreeRightMost = this.getRightMost((node) => node, curr.left);
|
|
2372
|
+
if (leftSubTreeRightMost) {
|
|
2373
|
+
const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
|
|
2374
|
+
orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
|
|
2375
|
+
if (this._isMapMode) {
|
|
2376
|
+
this._store.set(curr.key, curr);
|
|
2377
|
+
this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);
|
|
2378
|
+
}
|
|
2379
|
+
if (parentOfLeftSubTreeMax) {
|
|
2380
|
+
if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)
|
|
2381
|
+
parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
|
|
2382
|
+
else parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
|
|
2383
|
+
needBalanced = parentOfLeftSubTreeMax;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
} else if (parent) {
|
|
2387
|
+
const { familyPosition: fp } = curr;
|
|
2388
|
+
if (fp === "LEFT" || fp === "ROOT_LEFT") {
|
|
2389
|
+
parent.left = curr.right;
|
|
2390
|
+
} else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
|
|
2391
|
+
parent.right = curr.right;
|
|
2392
|
+
}
|
|
2393
|
+
needBalanced = parent;
|
|
2394
|
+
} else {
|
|
2395
|
+
this._setRoot(curr.right);
|
|
2396
|
+
curr.right = void 0;
|
|
2397
|
+
}
|
|
2398
|
+
this._size = this._size - 1;
|
|
2399
|
+
deletedResult.push({ deleted: orgCurrent, needBalanced });
|
|
2400
|
+
if (this._isMapMode && orgCurrent) this._store.delete(orgCurrent.key);
|
|
2401
|
+
return deletedResult;
|
|
2271
2402
|
}
|
|
2272
2403
|
/**
|
|
2273
2404
|
* Deletes a node from the tree.
|
|
2274
|
-
* @remarks Time O(
|
|
2405
|
+
* @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).
|
|
2275
2406
|
*
|
|
2276
2407
|
* @param keyNodeEntryRawOrPredicate - The node to delete.
|
|
2277
|
-
* @returns
|
|
2408
|
+
* @returns True if the node was found and deleted, false otherwise.
|
|
2409
|
+
|
|
2410
|
+
|
|
2411
|
+
|
|
2412
|
+
|
|
2278
2413
|
|
|
2279
2414
|
|
|
2280
2415
|
|
|
@@ -2318,51 +2453,11 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2318
2453
|
* console.log(tree.size); // 4;
|
|
2319
2454
|
*/
|
|
2320
2455
|
delete(keyNodeEntryRawOrPredicate) {
|
|
2321
|
-
|
|
2322
|
-
if (!this._root) return deletedResult;
|
|
2323
|
-
const curr = this.getNode(keyNodeEntryRawOrPredicate);
|
|
2324
|
-
if (!curr) return deletedResult;
|
|
2325
|
-
const parent = curr?.parent;
|
|
2326
|
-
let needBalanced;
|
|
2327
|
-
let orgCurrent = curr;
|
|
2328
|
-
if (!curr.left && !curr.right && !parent) {
|
|
2329
|
-
this._setRoot(void 0);
|
|
2330
|
-
} else if (curr.left) {
|
|
2331
|
-
const leftSubTreeRightMost = this.getRightMost((node) => node, curr.left);
|
|
2332
|
-
if (leftSubTreeRightMost) {
|
|
2333
|
-
const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
|
|
2334
|
-
orgCurrent = this._swapProperties(curr, leftSubTreeRightMost);
|
|
2335
|
-
if (this._isMapMode) {
|
|
2336
|
-
this._store.set(curr.key, curr);
|
|
2337
|
-
this._store.set(leftSubTreeRightMost.key, leftSubTreeRightMost);
|
|
2338
|
-
}
|
|
2339
|
-
if (parentOfLeftSubTreeMax) {
|
|
2340
|
-
if (parentOfLeftSubTreeMax.right === leftSubTreeRightMost)
|
|
2341
|
-
parentOfLeftSubTreeMax.right = leftSubTreeRightMost.left;
|
|
2342
|
-
else parentOfLeftSubTreeMax.left = leftSubTreeRightMost.left;
|
|
2343
|
-
needBalanced = parentOfLeftSubTreeMax;
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
} else if (parent) {
|
|
2347
|
-
const { familyPosition: fp } = curr;
|
|
2348
|
-
if (fp === "LEFT" || fp === "ROOT_LEFT") {
|
|
2349
|
-
parent.left = curr.right;
|
|
2350
|
-
} else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
|
|
2351
|
-
parent.right = curr.right;
|
|
2352
|
-
}
|
|
2353
|
-
needBalanced = parent;
|
|
2354
|
-
} else {
|
|
2355
|
-
this._setRoot(curr.right);
|
|
2356
|
-
curr.right = void 0;
|
|
2357
|
-
}
|
|
2358
|
-
this._size = this._size - 1;
|
|
2359
|
-
deletedResult.push({ deleted: orgCurrent, needBalanced });
|
|
2360
|
-
if (this._isMapMode && orgCurrent) this._store.delete(orgCurrent.key);
|
|
2361
|
-
return deletedResult;
|
|
2456
|
+
return this._deleteInternal(keyNodeEntryRawOrPredicate).length > 0;
|
|
2362
2457
|
}
|
|
2363
2458
|
/**
|
|
2364
2459
|
* Searches the tree for nodes matching a predicate.
|
|
2365
|
-
* @remarks Time O(
|
|
2460
|
+
* @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).
|
|
2366
2461
|
*
|
|
2367
2462
|
* @template C - The type of the callback function.
|
|
2368
2463
|
* @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
|
|
@@ -2411,7 +2506,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2411
2506
|
}
|
|
2412
2507
|
/**
|
|
2413
2508
|
* Gets the first node matching a predicate.
|
|
2414
|
-
* @remarks Time O(
|
|
2509
|
+
* @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.
|
|
2415
2510
|
*
|
|
2416
2511
|
* @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
|
|
2417
2512
|
* @param [startNode=this._root] - The node to start the search from.
|
|
@@ -2445,6 +2540,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2445
2540
|
|
|
2446
2541
|
|
|
2447
2542
|
|
|
2543
|
+
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
|
|
2448
2547
|
|
|
2449
2548
|
|
|
2450
2549
|
|
|
@@ -2467,7 +2566,7 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2467
2566
|
}
|
|
2468
2567
|
/**
|
|
2469
2568
|
* Gets the value associated with a key.
|
|
2470
|
-
* @remarks Time O(
|
|
2569
|
+
* @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).
|
|
2471
2570
|
*
|
|
2472
2571
|
* @param keyNodeEntryOrPredicate - The key, node, or entry to get the value for.
|
|
2473
2572
|
* @param [startNode=this._root] - The node to start searching from (if not in Map mode).
|
|
@@ -2503,6 +2602,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2503
2602
|
|
|
2504
2603
|
|
|
2505
2604
|
|
|
2605
|
+
|
|
2606
|
+
|
|
2607
|
+
|
|
2608
|
+
|
|
2506
2609
|
|
|
2507
2610
|
|
|
2508
2611
|
|
|
@@ -2563,6 +2666,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2563
2666
|
|
|
2564
2667
|
|
|
2565
2668
|
|
|
2669
|
+
|
|
2670
|
+
|
|
2671
|
+
|
|
2672
|
+
|
|
2566
2673
|
|
|
2567
2674
|
|
|
2568
2675
|
|
|
@@ -2611,6 +2718,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2611
2718
|
|
|
2612
2719
|
|
|
2613
2720
|
|
|
2721
|
+
|
|
2722
|
+
|
|
2723
|
+
|
|
2724
|
+
|
|
2614
2725
|
|
|
2615
2726
|
|
|
2616
2727
|
|
|
@@ -2668,6 +2779,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2668
2779
|
|
|
2669
2780
|
|
|
2670
2781
|
|
|
2782
|
+
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
|
|
2671
2786
|
|
|
2672
2787
|
|
|
2673
2788
|
|
|
@@ -2752,6 +2867,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2752
2867
|
|
|
2753
2868
|
|
|
2754
2869
|
|
|
2870
|
+
|
|
2871
|
+
|
|
2872
|
+
|
|
2873
|
+
|
|
2755
2874
|
|
|
2756
2875
|
|
|
2757
2876
|
|
|
@@ -2813,6 +2932,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2813
2932
|
|
|
2814
2933
|
|
|
2815
2934
|
|
|
2935
|
+
|
|
2936
|
+
|
|
2937
|
+
|
|
2938
|
+
|
|
2816
2939
|
|
|
2817
2940
|
|
|
2818
2941
|
|
|
@@ -3290,6 +3413,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3290
3413
|
|
|
3291
3414
|
|
|
3292
3415
|
|
|
3416
|
+
|
|
3417
|
+
|
|
3418
|
+
|
|
3419
|
+
|
|
3293
3420
|
|
|
3294
3421
|
|
|
3295
3422
|
|
|
@@ -3342,6 +3469,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3342
3469
|
|
|
3343
3470
|
|
|
3344
3471
|
|
|
3472
|
+
|
|
3473
|
+
|
|
3474
|
+
|
|
3475
|
+
|
|
3345
3476
|
|
|
3346
3477
|
|
|
3347
3478
|
|
|
@@ -3398,6 +3529,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3398
3529
|
|
|
3399
3530
|
|
|
3400
3531
|
|
|
3532
|
+
|
|
3533
|
+
|
|
3534
|
+
|
|
3535
|
+
|
|
3401
3536
|
|
|
3402
3537
|
|
|
3403
3538
|
|
|
@@ -3479,6 +3614,10 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
3479
3614
|
|
|
3480
3615
|
|
|
3481
3616
|
|
|
3617
|
+
|
|
3618
|
+
|
|
3619
|
+
|
|
3620
|
+
|
|
3482
3621
|
|
|
3483
3622
|
|
|
3484
3623
|
|
|
@@ -4298,6 +4437,14 @@ var BST = class extends BinaryTree {
|
|
|
4298
4437
|
|
|
4299
4438
|
|
|
4300
4439
|
|
|
4440
|
+
|
|
4441
|
+
|
|
4442
|
+
|
|
4443
|
+
|
|
4444
|
+
|
|
4445
|
+
|
|
4446
|
+
|
|
4447
|
+
|
|
4301
4448
|
|
|
4302
4449
|
|
|
4303
4450
|
|
|
@@ -4630,6 +4777,18 @@ var BST = class extends BinaryTree {
|
|
|
4630
4777
|
|
|
4631
4778
|
|
|
4632
4779
|
|
|
4780
|
+
|
|
4781
|
+
|
|
4782
|
+
|
|
4783
|
+
|
|
4784
|
+
|
|
4785
|
+
|
|
4786
|
+
|
|
4787
|
+
|
|
4788
|
+
|
|
4789
|
+
|
|
4790
|
+
|
|
4791
|
+
|
|
4633
4792
|
|
|
4634
4793
|
|
|
4635
4794
|
|
|
@@ -4749,6 +4908,14 @@ var BST = class extends BinaryTree {
|
|
|
4749
4908
|
|
|
4750
4909
|
|
|
4751
4910
|
|
|
4911
|
+
|
|
4912
|
+
|
|
4913
|
+
|
|
4914
|
+
|
|
4915
|
+
|
|
4916
|
+
|
|
4917
|
+
|
|
4918
|
+
|
|
4752
4919
|
|
|
4753
4920
|
|
|
4754
4921
|
|
|
@@ -5040,6 +5207,10 @@ var BST = class extends BinaryTree {
|
|
|
5040
5207
|
|
|
5041
5208
|
|
|
5042
5209
|
|
|
5210
|
+
|
|
5211
|
+
|
|
5212
|
+
|
|
5213
|
+
|
|
5043
5214
|
|
|
5044
5215
|
|
|
5045
5216
|
|
|
@@ -5109,6 +5280,10 @@ var BST = class extends BinaryTree {
|
|
|
5109
5280
|
|
|
5110
5281
|
|
|
5111
5282
|
|
|
5283
|
+
|
|
5284
|
+
|
|
5285
|
+
|
|
5286
|
+
|
|
5112
5287
|
|
|
5113
5288
|
|
|
5114
5289
|
|
|
@@ -5227,6 +5402,14 @@ var BST = class extends BinaryTree {
|
|
|
5227
5402
|
|
|
5228
5403
|
|
|
5229
5404
|
|
|
5405
|
+
|
|
5406
|
+
|
|
5407
|
+
|
|
5408
|
+
|
|
5409
|
+
|
|
5410
|
+
|
|
5411
|
+
|
|
5412
|
+
|
|
5230
5413
|
|
|
5231
5414
|
|
|
5232
5415
|
|
|
@@ -5288,12 +5471,11 @@ var BST = class extends BinaryTree {
|
|
|
5288
5471
|
*/
|
|
5289
5472
|
deleteWhere(keyNodeEntryOrPredicate, onlyOne = false, startNode = this._root, iterationType = this.iterationType) {
|
|
5290
5473
|
const toDelete = this.search(keyNodeEntryOrPredicate, onlyOne, (node) => node, startNode, iterationType);
|
|
5291
|
-
let
|
|
5474
|
+
let deleted = false;
|
|
5292
5475
|
for (const node of toDelete) {
|
|
5293
|
-
|
|
5294
|
-
results = results.concat(deleteInfo);
|
|
5476
|
+
if (this.delete(node)) deleted = true;
|
|
5295
5477
|
}
|
|
5296
|
-
return
|
|
5478
|
+
return deleted;
|
|
5297
5479
|
}
|
|
5298
5480
|
/**
|
|
5299
5481
|
* (Protected) Creates the default comparator function for keys that don't have a custom comparator.
|