avl-tree-typed 2.5.1 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +423 -52
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +423 -51
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +423 -52
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +423 -51
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +77 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +171 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +409 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +411 -6
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +339 -6
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +391 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
- package/dist/types/data-structures/heap/heap.d.ts +42 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +51 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
- package/dist/types/data-structures/queue/deque.d.ts +45 -0
- package/dist/types/data-structures/queue/queue.d.ts +36 -0
- package/dist/types/data-structures/stack/stack.d.ts +30 -0
- package/dist/types/data-structures/trie/trie.d.ts +36 -0
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/avl-tree-typed.js +420 -49
- package/dist/umd/avl-tree-typed.js.map +1 -1
- package/dist/umd/avl-tree-typed.min.js +3 -3
- package/dist/umd/avl-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +47 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
- package/src/data-structures/binary-tree/binary-tree.ts +79 -4
- package/src/data-structures/binary-tree/bst.ts +441 -6
- package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
- package/src/data-structures/binary-tree/segment-tree.ts +18 -0
- package/src/data-structures/binary-tree/tree-map.ts +434 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
- package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
- package/src/data-structures/binary-tree/tree-set.ts +410 -8
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +30 -0
- package/src/data-structures/graph/undirected-graph.ts +27 -0
- package/src/data-structures/hash/hash-map.ts +35 -4
- package/src/data-structures/heap/heap.ts +46 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
- package/src/data-structures/matrix/matrix.ts +33 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +45 -0
- package/src/data-structures/queue/queue.ts +36 -0
- package/src/data-structures/stack/stack.ts +30 -0
- package/src/data-structures/trie/trie.ts +38 -2
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
|
@@ -82,6 +82,52 @@ var avlTreeTyped = (() => {
|
|
|
82
82
|
return (...args) => trampoline(fn(...args));
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
// src/common/error.ts
|
|
86
|
+
function raise(ErrorClass, message) {
|
|
87
|
+
throw new ErrorClass(message);
|
|
88
|
+
}
|
|
89
|
+
var ERR = {
|
|
90
|
+
// Range / index
|
|
91
|
+
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
92
|
+
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
93
|
+
// Type / argument
|
|
94
|
+
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
95
|
+
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
96
|
+
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
97
|
+
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
98
|
+
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
99
|
+
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
100
|
+
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
101
|
+
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
102
|
+
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
103
|
+
// State / operation
|
|
104
|
+
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
105
|
+
// Matrix
|
|
106
|
+
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
107
|
+
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
108
|
+
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
109
|
+
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
110
|
+
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`,
|
|
111
|
+
// Order statistic
|
|
112
|
+
orderStatisticNotEnabled: (method, ctx) => `${ctx ? ctx + ": " : ""}${method}() requires enableOrderStatistic: true.`
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/common/index.ts
|
|
116
|
+
var Range = class {
|
|
117
|
+
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
118
|
+
this.low = low;
|
|
119
|
+
this.high = high;
|
|
120
|
+
this.includeLow = includeLow;
|
|
121
|
+
this.includeHigh = includeHigh;
|
|
122
|
+
}
|
|
123
|
+
// Determine whether a key is within the range
|
|
124
|
+
isInRange(key, comparator) {
|
|
125
|
+
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
126
|
+
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
127
|
+
return lowCheck && highCheck;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
85
131
|
// src/data-structures/base/iterable-element-base.ts
|
|
86
132
|
var IterableElementBase = class {
|
|
87
133
|
/**
|
|
@@ -104,7 +150,7 @@ var avlTreeTyped = (() => {
|
|
|
104
150
|
if (options) {
|
|
105
151
|
const { toElementFn } = options;
|
|
106
152
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
107
|
-
else if (toElementFn)
|
|
153
|
+
else if (toElementFn) raise(TypeError, "toElementFn must be a function type");
|
|
108
154
|
}
|
|
109
155
|
}
|
|
110
156
|
/**
|
|
@@ -260,7 +306,7 @@ var avlTreeTyped = (() => {
|
|
|
260
306
|
acc = initialValue;
|
|
261
307
|
} else {
|
|
262
308
|
const first = iter.next();
|
|
263
|
-
if (first.done)
|
|
309
|
+
if (first.done) raise(TypeError, "Reduce of empty structure with no initial value");
|
|
264
310
|
acc = first.value;
|
|
265
311
|
index = 1;
|
|
266
312
|
}
|
|
@@ -492,47 +538,6 @@ var avlTreeTyped = (() => {
|
|
|
492
538
|
}
|
|
493
539
|
};
|
|
494
540
|
|
|
495
|
-
// src/common/error.ts
|
|
496
|
-
var ERR = {
|
|
497
|
-
// Range / index
|
|
498
|
-
indexOutOfRange: (index, min, max, ctx) => `${ctx ? ctx + ": " : ""}Index ${index} is out of range [${min}, ${max}].`,
|
|
499
|
-
invalidIndex: (ctx) => `${ctx ? ctx + ": " : ""}Index must be an integer.`,
|
|
500
|
-
// Type / argument
|
|
501
|
-
invalidArgument: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
502
|
-
comparatorRequired: (ctx) => `${ctx ? ctx + ": " : ""}Comparator is required for non-number/non-string/non-Date keys.`,
|
|
503
|
-
invalidKey: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
504
|
-
notAFunction: (name, ctx) => `${ctx ? ctx + ": " : ""}${name} must be a function.`,
|
|
505
|
-
invalidEntry: (ctx) => `${ctx ? ctx + ": " : ""}Each entry must be a [key, value] tuple.`,
|
|
506
|
-
invalidNaN: (ctx) => `${ctx ? ctx + ": " : ""}NaN is not a valid key.`,
|
|
507
|
-
invalidDate: (ctx) => `${ctx ? ctx + ": " : ""}Invalid Date key.`,
|
|
508
|
-
reduceEmpty: (ctx) => `${ctx ? ctx + ": " : ""}Reduce of empty structure with no initial value.`,
|
|
509
|
-
callbackReturnType: (expected, got, ctx) => `${ctx ? ctx + ": " : ""}Callback must return ${expected}; got ${got}.`,
|
|
510
|
-
// State / operation
|
|
511
|
-
invalidOperation: (reason, ctx) => `${ctx ? ctx + ": " : ""}${reason}`,
|
|
512
|
-
// Matrix
|
|
513
|
-
matrixDimensionMismatch: (op) => `Matrix: Dimensions must be compatible for ${op}.`,
|
|
514
|
-
matrixSingular: () => "Matrix: Singular matrix, inverse does not exist.",
|
|
515
|
-
matrixNotSquare: () => "Matrix: Must be square for inversion.",
|
|
516
|
-
matrixNotRectangular: () => "Matrix: Must be rectangular for transposition.",
|
|
517
|
-
matrixRowMismatch: (expected, got) => `Matrix: Expected row length ${expected}, but got ${got}.`
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
// src/common/index.ts
|
|
521
|
-
var Range = class {
|
|
522
|
-
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
523
|
-
this.low = low;
|
|
524
|
-
this.high = high;
|
|
525
|
-
this.includeLow = includeLow;
|
|
526
|
-
this.includeHigh = includeHigh;
|
|
527
|
-
}
|
|
528
|
-
// Determine whether a key is within the range
|
|
529
|
-
isInRange(key, comparator) {
|
|
530
|
-
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
531
|
-
const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;
|
|
532
|
-
return lowCheck && highCheck;
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
|
|
536
541
|
// src/data-structures/base/iterable-entry-base.ts
|
|
537
542
|
var IterableEntryBase = class {
|
|
538
543
|
/**
|
|
@@ -797,6 +802,9 @@ var avlTreeTyped = (() => {
|
|
|
797
802
|
|
|
798
803
|
|
|
799
804
|
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
800
808
|
|
|
801
809
|
|
|
802
810
|
|
|
@@ -844,6 +852,9 @@ var avlTreeTyped = (() => {
|
|
|
844
852
|
|
|
845
853
|
|
|
846
854
|
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
847
858
|
|
|
848
859
|
|
|
849
860
|
|
|
@@ -907,6 +918,9 @@ var avlTreeTyped = (() => {
|
|
|
907
918
|
|
|
908
919
|
|
|
909
920
|
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
910
924
|
|
|
911
925
|
|
|
912
926
|
|
|
@@ -966,6 +980,9 @@ var avlTreeTyped = (() => {
|
|
|
966
980
|
|
|
967
981
|
|
|
968
982
|
|
|
983
|
+
|
|
984
|
+
|
|
985
|
+
|
|
969
986
|
|
|
970
987
|
|
|
971
988
|
|
|
@@ -1032,6 +1049,9 @@ var avlTreeTyped = (() => {
|
|
|
1032
1049
|
|
|
1033
1050
|
|
|
1034
1051
|
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
|
|
1035
1055
|
|
|
1036
1056
|
|
|
1037
1057
|
|
|
@@ -1088,6 +1108,9 @@ var avlTreeTyped = (() => {
|
|
|
1088
1108
|
|
|
1089
1109
|
|
|
1090
1110
|
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
|
|
1091
1114
|
|
|
1092
1115
|
|
|
1093
1116
|
|
|
@@ -1137,6 +1160,9 @@ var avlTreeTyped = (() => {
|
|
|
1137
1160
|
|
|
1138
1161
|
|
|
1139
1162
|
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
|
|
1140
1166
|
|
|
1141
1167
|
|
|
1142
1168
|
|
|
@@ -1227,6 +1253,9 @@ var avlTreeTyped = (() => {
|
|
|
1227
1253
|
|
|
1228
1254
|
|
|
1229
1255
|
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1230
1259
|
|
|
1231
1260
|
|
|
1232
1261
|
|
|
@@ -1270,6 +1299,9 @@ var avlTreeTyped = (() => {
|
|
|
1270
1299
|
|
|
1271
1300
|
|
|
1272
1301
|
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
|
|
1273
1305
|
|
|
1274
1306
|
|
|
1275
1307
|
|
|
@@ -1336,6 +1368,9 @@ var avlTreeTyped = (() => {
|
|
|
1336
1368
|
|
|
1337
1369
|
|
|
1338
1370
|
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
|
|
1339
1374
|
|
|
1340
1375
|
|
|
1341
1376
|
|
|
@@ -1386,6 +1421,9 @@ var avlTreeTyped = (() => {
|
|
|
1386
1421
|
|
|
1387
1422
|
|
|
1388
1423
|
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1389
1427
|
|
|
1390
1428
|
|
|
1391
1429
|
|
|
@@ -1440,6 +1478,9 @@ var avlTreeTyped = (() => {
|
|
|
1440
1478
|
|
|
1441
1479
|
|
|
1442
1480
|
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
|
|
1443
1484
|
|
|
1444
1485
|
|
|
1445
1486
|
|
|
@@ -1708,7 +1749,7 @@ var avlTreeTyped = (() => {
|
|
|
1708
1749
|
if (isMapMode !== void 0) this._isMapMode = isMapMode;
|
|
1709
1750
|
if (isDuplicate !== void 0) this._isDuplicate = isDuplicate;
|
|
1710
1751
|
if (typeof toEntryFn === "function") this._toEntryFn = toEntryFn;
|
|
1711
|
-
else if (toEntryFn)
|
|
1752
|
+
else if (toEntryFn) raise(TypeError, ERR.notAFunction("toEntryFn", "BinaryTree"));
|
|
1712
1753
|
}
|
|
1713
1754
|
if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
|
|
1714
1755
|
}
|
|
@@ -1941,6 +1982,9 @@ var avlTreeTyped = (() => {
|
|
|
1941
1982
|
|
|
1942
1983
|
|
|
1943
1984
|
|
|
1985
|
+
|
|
1986
|
+
|
|
1987
|
+
|
|
1944
1988
|
|
|
1945
1989
|
|
|
1946
1990
|
|
|
@@ -1992,6 +2036,9 @@ var avlTreeTyped = (() => {
|
|
|
1992
2036
|
|
|
1993
2037
|
|
|
1994
2038
|
|
|
2039
|
+
|
|
2040
|
+
|
|
2041
|
+
|
|
1995
2042
|
|
|
1996
2043
|
|
|
1997
2044
|
|
|
@@ -2095,6 +2142,9 @@ var avlTreeTyped = (() => {
|
|
|
2095
2142
|
|
|
2096
2143
|
|
|
2097
2144
|
|
|
2145
|
+
|
|
2146
|
+
|
|
2147
|
+
|
|
2098
2148
|
|
|
2099
2149
|
|
|
2100
2150
|
|
|
@@ -2134,6 +2184,9 @@ var avlTreeTyped = (() => {
|
|
|
2134
2184
|
|
|
2135
2185
|
|
|
2136
2186
|
|
|
2187
|
+
|
|
2188
|
+
|
|
2189
|
+
|
|
2137
2190
|
|
|
2138
2191
|
|
|
2139
2192
|
|
|
@@ -2194,6 +2247,9 @@ var avlTreeTyped = (() => {
|
|
|
2194
2247
|
|
|
2195
2248
|
|
|
2196
2249
|
|
|
2250
|
+
|
|
2251
|
+
|
|
2252
|
+
|
|
2197
2253
|
|
|
2198
2254
|
|
|
2199
2255
|
|
|
@@ -2253,6 +2309,9 @@ var avlTreeTyped = (() => {
|
|
|
2253
2309
|
|
|
2254
2310
|
|
|
2255
2311
|
|
|
2312
|
+
|
|
2313
|
+
|
|
2314
|
+
|
|
2256
2315
|
|
|
2257
2316
|
|
|
2258
2317
|
|
|
@@ -2390,6 +2449,9 @@ var avlTreeTyped = (() => {
|
|
|
2390
2449
|
|
|
2391
2450
|
|
|
2392
2451
|
|
|
2452
|
+
|
|
2453
|
+
|
|
2454
|
+
|
|
2393
2455
|
|
|
2394
2456
|
|
|
2395
2457
|
|
|
@@ -2445,6 +2507,9 @@ var avlTreeTyped = (() => {
|
|
|
2445
2507
|
|
|
2446
2508
|
|
|
2447
2509
|
|
|
2510
|
+
|
|
2511
|
+
|
|
2512
|
+
|
|
2448
2513
|
|
|
2449
2514
|
|
|
2450
2515
|
|
|
@@ -2503,6 +2568,9 @@ var avlTreeTyped = (() => {
|
|
|
2503
2568
|
|
|
2504
2569
|
|
|
2505
2570
|
|
|
2571
|
+
|
|
2572
|
+
|
|
2573
|
+
|
|
2506
2574
|
|
|
2507
2575
|
|
|
2508
2576
|
|
|
@@ -2548,6 +2616,9 @@ var avlTreeTyped = (() => {
|
|
|
2548
2616
|
|
|
2549
2617
|
|
|
2550
2618
|
|
|
2619
|
+
|
|
2620
|
+
|
|
2621
|
+
|
|
2551
2622
|
|
|
2552
2623
|
|
|
2553
2624
|
|
|
@@ -2602,6 +2673,9 @@ var avlTreeTyped = (() => {
|
|
|
2602
2673
|
|
|
2603
2674
|
|
|
2604
2675
|
|
|
2676
|
+
|
|
2677
|
+
|
|
2678
|
+
|
|
2605
2679
|
|
|
2606
2680
|
|
|
2607
2681
|
|
|
@@ -2683,6 +2757,9 @@ var avlTreeTyped = (() => {
|
|
|
2683
2757
|
|
|
2684
2758
|
|
|
2685
2759
|
|
|
2760
|
+
|
|
2761
|
+
|
|
2762
|
+
|
|
2686
2763
|
|
|
2687
2764
|
|
|
2688
2765
|
|
|
@@ -2741,6 +2818,9 @@ var avlTreeTyped = (() => {
|
|
|
2741
2818
|
|
|
2742
2819
|
|
|
2743
2820
|
|
|
2821
|
+
|
|
2822
|
+
|
|
2823
|
+
|
|
2744
2824
|
|
|
2745
2825
|
|
|
2746
2826
|
|
|
@@ -3215,6 +3295,9 @@ var avlTreeTyped = (() => {
|
|
|
3215
3295
|
|
|
3216
3296
|
|
|
3217
3297
|
|
|
3298
|
+
|
|
3299
|
+
|
|
3300
|
+
|
|
3218
3301
|
|
|
3219
3302
|
|
|
3220
3303
|
|
|
@@ -3264,6 +3347,9 @@ var avlTreeTyped = (() => {
|
|
|
3264
3347
|
|
|
3265
3348
|
|
|
3266
3349
|
|
|
3350
|
+
|
|
3351
|
+
|
|
3352
|
+
|
|
3267
3353
|
|
|
3268
3354
|
|
|
3269
3355
|
|
|
@@ -3317,6 +3403,9 @@ var avlTreeTyped = (() => {
|
|
|
3317
3403
|
|
|
3318
3404
|
|
|
3319
3405
|
|
|
3406
|
+
|
|
3407
|
+
|
|
3408
|
+
|
|
3320
3409
|
|
|
3321
3410
|
|
|
3322
3411
|
|
|
@@ -3395,6 +3484,9 @@ var avlTreeTyped = (() => {
|
|
|
3395
3484
|
|
|
3396
3485
|
|
|
3397
3486
|
|
|
3487
|
+
|
|
3488
|
+
|
|
3489
|
+
|
|
3398
3490
|
|
|
3399
3491
|
|
|
3400
3492
|
|
|
@@ -4013,6 +4105,7 @@ var avlTreeTyped = (() => {
|
|
|
4013
4105
|
constructor(keysNodesEntriesOrRaws = [], options) {
|
|
4014
4106
|
super([], options);
|
|
4015
4107
|
__publicField(this, "_root");
|
|
4108
|
+
__publicField(this, "_enableOrderStatistic", false);
|
|
4016
4109
|
/**
|
|
4017
4110
|
* The comparator function used to determine the order of keys in the tree.
|
|
4018
4111
|
|
|
@@ -4025,6 +4118,9 @@ var avlTreeTyped = (() => {
|
|
|
4025
4118
|
} else {
|
|
4026
4119
|
this._comparator = this._createDefaultComparator();
|
|
4027
4120
|
}
|
|
4121
|
+
if (options.enableOrderStatistic) {
|
|
4122
|
+
this._enableOrderStatistic = true;
|
|
4123
|
+
}
|
|
4028
4124
|
} else {
|
|
4029
4125
|
this._comparator = this._createDefaultComparator();
|
|
4030
4126
|
}
|
|
@@ -4194,6 +4290,12 @@ var avlTreeTyped = (() => {
|
|
|
4194
4290
|
|
|
4195
4291
|
|
|
4196
4292
|
|
|
4293
|
+
|
|
4294
|
+
|
|
4295
|
+
|
|
4296
|
+
|
|
4297
|
+
|
|
4298
|
+
|
|
4197
4299
|
|
|
4198
4300
|
|
|
4199
4301
|
|
|
@@ -4356,6 +4458,85 @@ var avlTreeTyped = (() => {
|
|
|
4356
4458
|
const searchRange = range instanceof Range ? range : new Range(range[0], range[1]);
|
|
4357
4459
|
return this.search(searchRange, false, callback, startNode, iterationType);
|
|
4358
4460
|
}
|
|
4461
|
+
getByRank(k, callback = this._DEFAULT_NODE_CALLBACK, iterationType = this.iterationType) {
|
|
4462
|
+
if (!this._enableOrderStatistic) {
|
|
4463
|
+
raise(Error, ERR.orderStatisticNotEnabled("getByRank"));
|
|
4464
|
+
}
|
|
4465
|
+
if (k < 0 || k >= this._size) return void 0;
|
|
4466
|
+
let actualCallback = void 0;
|
|
4467
|
+
let actualIterationType = this.iterationType;
|
|
4468
|
+
if (typeof callback === "string") {
|
|
4469
|
+
actualIterationType = callback;
|
|
4470
|
+
} else if (callback) {
|
|
4471
|
+
actualCallback = callback;
|
|
4472
|
+
if (iterationType) {
|
|
4473
|
+
actualIterationType = iterationType;
|
|
4474
|
+
}
|
|
4475
|
+
}
|
|
4476
|
+
const node = actualIterationType === "RECURSIVE" ? this._getByRankRecursive(this._root, k) : this._getByRankIterative(this._root, k);
|
|
4477
|
+
if (!node) return void 0;
|
|
4478
|
+
return actualCallback ? actualCallback(node) : node.key;
|
|
4479
|
+
}
|
|
4480
|
+
getRank(keyNodeEntryOrPredicate, iterationType = this.iterationType) {
|
|
4481
|
+
var _a;
|
|
4482
|
+
if (!this._enableOrderStatistic) {
|
|
4483
|
+
raise(Error, ERR.orderStatisticNotEnabled("getRank"));
|
|
4484
|
+
}
|
|
4485
|
+
if (!this._root || this._size === 0) return -1;
|
|
4486
|
+
let actualIterationType = this.iterationType;
|
|
4487
|
+
if (iterationType) actualIterationType = iterationType;
|
|
4488
|
+
let key;
|
|
4489
|
+
if (typeof keyNodeEntryOrPredicate === "function") {
|
|
4490
|
+
const results = this.search(keyNodeEntryOrPredicate, true);
|
|
4491
|
+
if (results.length === 0 || results[0] === void 0) return -1;
|
|
4492
|
+
key = results[0];
|
|
4493
|
+
} else if (keyNodeEntryOrPredicate === null || keyNodeEntryOrPredicate === void 0) {
|
|
4494
|
+
return -1;
|
|
4495
|
+
} else if (this.isNode(keyNodeEntryOrPredicate)) {
|
|
4496
|
+
key = keyNodeEntryOrPredicate.key;
|
|
4497
|
+
} else if (Array.isArray(keyNodeEntryOrPredicate)) {
|
|
4498
|
+
key = (_a = keyNodeEntryOrPredicate[0]) != null ? _a : void 0;
|
|
4499
|
+
if (key === void 0 || key === null) return -1;
|
|
4500
|
+
} else {
|
|
4501
|
+
key = keyNodeEntryOrPredicate;
|
|
4502
|
+
}
|
|
4503
|
+
if (key === void 0) return -1;
|
|
4504
|
+
return actualIterationType === "RECURSIVE" ? this._getRankRecursive(this._root, key) : this._getRankIterative(this._root, key);
|
|
4505
|
+
}
|
|
4506
|
+
rangeByRank(start, end, callback = this._DEFAULT_NODE_CALLBACK, iterationType = this.iterationType) {
|
|
4507
|
+
if (!this._enableOrderStatistic) {
|
|
4508
|
+
raise(Error, ERR.orderStatisticNotEnabled("rangeByRank"));
|
|
4509
|
+
}
|
|
4510
|
+
if (this._size === 0) return [];
|
|
4511
|
+
const lo = Math.max(0, start);
|
|
4512
|
+
const hi = Math.min(this._size - 1, end);
|
|
4513
|
+
if (lo > hi) return [];
|
|
4514
|
+
let actualCallback = void 0;
|
|
4515
|
+
let actualIterationType = this.iterationType;
|
|
4516
|
+
if (typeof callback === "string") {
|
|
4517
|
+
actualIterationType = callback;
|
|
4518
|
+
} else if (callback) {
|
|
4519
|
+
actualCallback = callback;
|
|
4520
|
+
if (iterationType) {
|
|
4521
|
+
actualIterationType = iterationType;
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
const results = [];
|
|
4525
|
+
const count = hi - lo + 1;
|
|
4526
|
+
const startNode = actualIterationType === "RECURSIVE" ? this._getByRankRecursive(this._root, lo) : this._getByRankIterative(this._root, lo);
|
|
4527
|
+
if (!startNode) return [];
|
|
4528
|
+
let collected = 0;
|
|
4529
|
+
const cb = actualCallback != null ? actualCallback : this._DEFAULT_NODE_CALLBACK;
|
|
4530
|
+
let current = startNode;
|
|
4531
|
+
while (current && collected < count) {
|
|
4532
|
+
results.push(cb(current));
|
|
4533
|
+
collected++;
|
|
4534
|
+
if (collected < count) {
|
|
4535
|
+
current = this._next(current);
|
|
4536
|
+
}
|
|
4537
|
+
}
|
|
4538
|
+
return results;
|
|
4539
|
+
}
|
|
4359
4540
|
/**
|
|
4360
4541
|
* Adds a new node to the BST based on key comparison.
|
|
4361
4542
|
* @remarks Time O(log N), where H is tree height. O(N) worst-case (unbalanced tree), O(log N) average. Space O(1).
|
|
@@ -4441,6 +4622,15 @@ var avlTreeTyped = (() => {
|
|
|
4441
4622
|
|
|
4442
4623
|
|
|
4443
4624
|
|
|
4625
|
+
|
|
4626
|
+
|
|
4627
|
+
|
|
4628
|
+
|
|
4629
|
+
|
|
4630
|
+
|
|
4631
|
+
|
|
4632
|
+
|
|
4633
|
+
|
|
4444
4634
|
|
|
4445
4635
|
|
|
4446
4636
|
|
|
@@ -4465,6 +4655,7 @@ var avlTreeTyped = (() => {
|
|
|
4465
4655
|
this._setRoot(newNode);
|
|
4466
4656
|
if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
|
|
4467
4657
|
this._size++;
|
|
4658
|
+
this._updateCount(newNode);
|
|
4468
4659
|
return true;
|
|
4469
4660
|
}
|
|
4470
4661
|
let current = this._root;
|
|
@@ -4478,6 +4669,7 @@ var avlTreeTyped = (() => {
|
|
|
4478
4669
|
current.left = newNode;
|
|
4479
4670
|
if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
|
|
4480
4671
|
this._size++;
|
|
4672
|
+
this._updateCountAlongPath(newNode);
|
|
4481
4673
|
return true;
|
|
4482
4674
|
}
|
|
4483
4675
|
if (current.left !== null) current = current.left;
|
|
@@ -4486,6 +4678,7 @@ var avlTreeTyped = (() => {
|
|
|
4486
4678
|
current.right = newNode;
|
|
4487
4679
|
if (this._isMapMode && this.isRealNode(newNode)) this._store.set(newNode.key, newNode);
|
|
4488
4680
|
this._size++;
|
|
4681
|
+
this._updateCountAlongPath(newNode);
|
|
4489
4682
|
return true;
|
|
4490
4683
|
}
|
|
4491
4684
|
if (current.right !== null) current = current.right;
|
|
@@ -4550,6 +4743,12 @@ var avlTreeTyped = (() => {
|
|
|
4550
4743
|
|
|
4551
4744
|
|
|
4552
4745
|
|
|
4746
|
+
|
|
4747
|
+
|
|
4748
|
+
|
|
4749
|
+
|
|
4750
|
+
|
|
4751
|
+
|
|
4553
4752
|
|
|
4554
4753
|
|
|
4555
4754
|
|
|
@@ -4837,6 +5036,9 @@ var avlTreeTyped = (() => {
|
|
|
4837
5036
|
|
|
4838
5037
|
|
|
4839
5038
|
|
|
5039
|
+
|
|
5040
|
+
|
|
5041
|
+
|
|
4840
5042
|
|
|
4841
5043
|
|
|
4842
5044
|
|
|
@@ -4903,6 +5105,9 @@ var avlTreeTyped = (() => {
|
|
|
4903
5105
|
|
|
4904
5106
|
|
|
4905
5107
|
|
|
5108
|
+
|
|
5109
|
+
|
|
5110
|
+
|
|
4906
5111
|
|
|
4907
5112
|
|
|
4908
5113
|
|
|
@@ -5016,6 +5221,12 @@ var avlTreeTyped = (() => {
|
|
|
5016
5221
|
|
|
5017
5222
|
|
|
5018
5223
|
|
|
5224
|
+
|
|
5225
|
+
|
|
5226
|
+
|
|
5227
|
+
|
|
5228
|
+
|
|
5229
|
+
|
|
5019
5230
|
|
|
5020
5231
|
|
|
5021
5232
|
|
|
@@ -5097,13 +5308,11 @@ var avlTreeTyped = (() => {
|
|
|
5097
5308
|
if (a instanceof Date && b instanceof Date) {
|
|
5098
5309
|
const ta = a.getTime();
|
|
5099
5310
|
const tb = b.getTime();
|
|
5100
|
-
if (Number.isNaN(ta) || Number.isNaN(tb))
|
|
5311
|
+
if (Number.isNaN(ta) || Number.isNaN(tb)) raise(TypeError, ERR.invalidDate("BST"));
|
|
5101
5312
|
return ta > tb ? 1 : ta < tb ? -1 : 0;
|
|
5102
5313
|
}
|
|
5103
5314
|
if (typeof a === "object" || typeof b === "object") {
|
|
5104
|
-
|
|
5105
|
-
ERR.comparatorRequired("BST")
|
|
5106
|
-
);
|
|
5315
|
+
raise(TypeError, ERR.comparatorRequired("BST"));
|
|
5107
5316
|
}
|
|
5108
5317
|
return 0;
|
|
5109
5318
|
};
|
|
@@ -5425,7 +5634,8 @@ var avlTreeTyped = (() => {
|
|
|
5425
5634
|
_snapshotOptions() {
|
|
5426
5635
|
return {
|
|
5427
5636
|
...super._snapshotOptions(),
|
|
5428
|
-
comparator: this._comparator
|
|
5637
|
+
comparator: this._comparator,
|
|
5638
|
+
enableOrderStatistic: this._enableOrderStatistic
|
|
5429
5639
|
};
|
|
5430
5640
|
}
|
|
5431
5641
|
/**
|
|
@@ -5447,6 +5657,113 @@ var avlTreeTyped = (() => {
|
|
|
5447
5657
|
*
|
|
5448
5658
|
* @param v - The node to set as root.
|
|
5449
5659
|
*/
|
|
5660
|
+
/**
|
|
5661
|
+
* (Protected) Recalculates the subtree count for a single node.
|
|
5662
|
+
* @remarks Time O(1). Only active when enableOrderStatistic is true.
|
|
5663
|
+
*/
|
|
5664
|
+
_updateCount(node) {
|
|
5665
|
+
if (!this._enableOrderStatistic) return;
|
|
5666
|
+
node._count = 1 + (this.isRealNode(node.left) ? node.left._count : 0) + (this.isRealNode(node.right) ? node.right._count : 0);
|
|
5667
|
+
}
|
|
5668
|
+
/**
|
|
5669
|
+
* (Protected) Updates subtree counts from a node up to the root.
|
|
5670
|
+
* @remarks Time O(log n). Only active when enableOrderStatistic is true.
|
|
5671
|
+
*/
|
|
5672
|
+
_updateCountAlongPath(node) {
|
|
5673
|
+
if (!this._enableOrderStatistic) return;
|
|
5674
|
+
let current = node;
|
|
5675
|
+
while (current) {
|
|
5676
|
+
this._updateCount(current);
|
|
5677
|
+
current = current.parent;
|
|
5678
|
+
}
|
|
5679
|
+
}
|
|
5680
|
+
/**
|
|
5681
|
+
* (Protected) Finds the node at position k in tree order (iterative).
|
|
5682
|
+
* @remarks Time O(log n), Space O(1)
|
|
5683
|
+
*/
|
|
5684
|
+
_getByRankIterative(node, k) {
|
|
5685
|
+
let current = node;
|
|
5686
|
+
let remaining = k;
|
|
5687
|
+
while (current) {
|
|
5688
|
+
const leftCount = this.isRealNode(current.left) ? current.left._count : 0;
|
|
5689
|
+
if (remaining < leftCount) {
|
|
5690
|
+
current = current.left;
|
|
5691
|
+
} else if (remaining === leftCount) {
|
|
5692
|
+
return current;
|
|
5693
|
+
} else {
|
|
5694
|
+
remaining = remaining - leftCount - 1;
|
|
5695
|
+
current = current.right;
|
|
5696
|
+
}
|
|
5697
|
+
}
|
|
5698
|
+
return void 0;
|
|
5699
|
+
}
|
|
5700
|
+
/**
|
|
5701
|
+
* (Protected) Finds the node at position k in tree order (recursive).
|
|
5702
|
+
* @remarks Time O(log n), Space O(log n) call stack
|
|
5703
|
+
*/
|
|
5704
|
+
_getByRankRecursive(node, k) {
|
|
5705
|
+
if (!node) return void 0;
|
|
5706
|
+
const leftCount = this.isRealNode(node.left) ? node.left._count : 0;
|
|
5707
|
+
if (k < leftCount) return this._getByRankRecursive(node.left, k);
|
|
5708
|
+
if (k === leftCount) return node;
|
|
5709
|
+
return this._getByRankRecursive(node.right, k - leftCount - 1);
|
|
5710
|
+
}
|
|
5711
|
+
/**
|
|
5712
|
+
* (Protected) Computes the rank of a key iteratively.
|
|
5713
|
+
* @remarks Time O(log n), Space O(1)
|
|
5714
|
+
*/
|
|
5715
|
+
_getRankIterative(node, key) {
|
|
5716
|
+
let rank = 0;
|
|
5717
|
+
let current = node;
|
|
5718
|
+
while (this.isRealNode(current)) {
|
|
5719
|
+
const cmp = this._compare(current.key, key);
|
|
5720
|
+
if (cmp > 0) {
|
|
5721
|
+
current = current.left;
|
|
5722
|
+
} else if (cmp < 0) {
|
|
5723
|
+
rank += (this.isRealNode(current.left) ? current.left._count : 0) + 1;
|
|
5724
|
+
current = current.right;
|
|
5725
|
+
} else {
|
|
5726
|
+
rank += this.isRealNode(current.left) ? current.left._count : 0;
|
|
5727
|
+
return rank;
|
|
5728
|
+
}
|
|
5729
|
+
}
|
|
5730
|
+
return rank;
|
|
5731
|
+
}
|
|
5732
|
+
/**
|
|
5733
|
+
* (Protected) Computes the rank of a key recursively.
|
|
5734
|
+
* @remarks Time O(log n), Space O(log n) call stack
|
|
5735
|
+
*/
|
|
5736
|
+
_getRankRecursive(node, key) {
|
|
5737
|
+
if (!node) return 0;
|
|
5738
|
+
const cmp = this._compare(node.key, key);
|
|
5739
|
+
if (cmp > 0) {
|
|
5740
|
+
return this._getRankRecursive(node.left, key);
|
|
5741
|
+
} else if (cmp < 0) {
|
|
5742
|
+
return (this.isRealNode(node.left) ? node.left._count : 0) + 1 + this._getRankRecursive(node.right, key);
|
|
5743
|
+
} else {
|
|
5744
|
+
return this.isRealNode(node.left) ? node.left._count : 0;
|
|
5745
|
+
}
|
|
5746
|
+
}
|
|
5747
|
+
/**
|
|
5748
|
+
* (Protected) Finds the in-order successor of a node.
|
|
5749
|
+
* @remarks Time O(log n), Space O(1)
|
|
5750
|
+
*/
|
|
5751
|
+
_next(node) {
|
|
5752
|
+
if (this.isRealNode(node.right)) {
|
|
5753
|
+
let current2 = node.right;
|
|
5754
|
+
while (this.isRealNode(current2.left)) {
|
|
5755
|
+
current2 = current2.left;
|
|
5756
|
+
}
|
|
5757
|
+
return current2;
|
|
5758
|
+
}
|
|
5759
|
+
let current = node;
|
|
5760
|
+
let parent = current.parent;
|
|
5761
|
+
while (parent && current === parent.right) {
|
|
5762
|
+
current = parent;
|
|
5763
|
+
parent = parent.parent;
|
|
5764
|
+
}
|
|
5765
|
+
return parent;
|
|
5766
|
+
}
|
|
5450
5767
|
_setRoot(v) {
|
|
5451
5768
|
if (v) v.parent = void 0;
|
|
5452
5769
|
this._root = v;
|
|
@@ -5493,21 +5810,28 @@ var avlTreeTyped = (() => {
|
|
|
5493
5810
|
while (x.left !== void 0 && x.left !== null) x = x.left;
|
|
5494
5811
|
return x;
|
|
5495
5812
|
};
|
|
5813
|
+
let countUpdateStart;
|
|
5496
5814
|
if (node.left === void 0) {
|
|
5815
|
+
countUpdateStart = node.parent;
|
|
5497
5816
|
transplant(node, node.right);
|
|
5498
5817
|
} else if (node.right === void 0) {
|
|
5818
|
+
countUpdateStart = node.parent;
|
|
5499
5819
|
transplant(node, node.left);
|
|
5500
5820
|
} else {
|
|
5501
5821
|
const succ = minNode(node.right);
|
|
5502
5822
|
if (succ.parent !== node) {
|
|
5823
|
+
countUpdateStart = succ.parent;
|
|
5503
5824
|
transplant(succ, succ.right);
|
|
5504
5825
|
succ.right = node.right;
|
|
5505
5826
|
if (succ.right) succ.right.parent = succ;
|
|
5827
|
+
} else {
|
|
5828
|
+
countUpdateStart = succ;
|
|
5506
5829
|
}
|
|
5507
5830
|
transplant(node, succ);
|
|
5508
5831
|
succ.left = node.left;
|
|
5509
5832
|
if (succ.left) succ.left.parent = succ;
|
|
5510
5833
|
}
|
|
5834
|
+
this._updateCountAlongPath(countUpdateStart);
|
|
5511
5835
|
this._size = Math.max(0, this._size - 1);
|
|
5512
5836
|
return true;
|
|
5513
5837
|
}
|
|
@@ -5788,6 +6112,18 @@ var avlTreeTyped = (() => {
|
|
|
5788
6112
|
|
|
5789
6113
|
|
|
5790
6114
|
|
|
6115
|
+
|
|
6116
|
+
|
|
6117
|
+
|
|
6118
|
+
|
|
6119
|
+
|
|
6120
|
+
|
|
6121
|
+
|
|
6122
|
+
|
|
6123
|
+
|
|
6124
|
+
|
|
6125
|
+
|
|
6126
|
+
|
|
5791
6127
|
|
|
5792
6128
|
|
|
5793
6129
|
|
|
@@ -5906,6 +6242,15 @@ var avlTreeTyped = (() => {
|
|
|
5906
6242
|
|
|
5907
6243
|
|
|
5908
6244
|
|
|
6245
|
+
|
|
6246
|
+
|
|
6247
|
+
|
|
6248
|
+
|
|
6249
|
+
|
|
6250
|
+
|
|
6251
|
+
|
|
6252
|
+
|
|
6253
|
+
|
|
5909
6254
|
|
|
5910
6255
|
|
|
5911
6256
|
|
|
@@ -5986,6 +6331,12 @@ var avlTreeTyped = (() => {
|
|
|
5986
6331
|
|
|
5987
6332
|
|
|
5988
6333
|
|
|
6334
|
+
|
|
6335
|
+
|
|
6336
|
+
|
|
6337
|
+
|
|
6338
|
+
|
|
6339
|
+
|
|
5989
6340
|
|
|
5990
6341
|
|
|
5991
6342
|
|
|
@@ -6110,6 +6461,15 @@ var avlTreeTyped = (() => {
|
|
|
6110
6461
|
|
|
6111
6462
|
|
|
6112
6463
|
|
|
6464
|
+
|
|
6465
|
+
|
|
6466
|
+
|
|
6467
|
+
|
|
6468
|
+
|
|
6469
|
+
|
|
6470
|
+
|
|
6471
|
+
|
|
6472
|
+
|
|
6113
6473
|
|
|
6114
6474
|
|
|
6115
6475
|
|
|
@@ -6238,6 +6598,8 @@ var avlTreeTyped = (() => {
|
|
|
6238
6598
|
}
|
|
6239
6599
|
this._updateHeight(A);
|
|
6240
6600
|
if (B) this._updateHeight(B);
|
|
6601
|
+
this._updateCount(A);
|
|
6602
|
+
if (B) this._updateCount(B);
|
|
6241
6603
|
}
|
|
6242
6604
|
/**
|
|
6243
6605
|
* (Protected) Performs a Left-Right (LR) double rotation.
|
|
@@ -6283,6 +6645,9 @@ var avlTreeTyped = (() => {
|
|
|
6283
6645
|
this._updateHeight(A);
|
|
6284
6646
|
if (B) this._updateHeight(B);
|
|
6285
6647
|
if (C) this._updateHeight(C);
|
|
6648
|
+
this._updateCount(A);
|
|
6649
|
+
if (B) this._updateCount(B);
|
|
6650
|
+
if (C) this._updateCount(C);
|
|
6286
6651
|
}
|
|
6287
6652
|
/**
|
|
6288
6653
|
* (Protected) Performs a Right-Right (RR) rotation (a single left rotation).
|
|
@@ -6317,6 +6682,8 @@ var avlTreeTyped = (() => {
|
|
|
6317
6682
|
}
|
|
6318
6683
|
this._updateHeight(A);
|
|
6319
6684
|
if (B) this._updateHeight(B);
|
|
6685
|
+
this._updateCount(A);
|
|
6686
|
+
if (B) this._updateCount(B);
|
|
6320
6687
|
}
|
|
6321
6688
|
/**
|
|
6322
6689
|
* (Protected) Performs a Right-Left (RL) double rotation.
|
|
@@ -6360,6 +6727,9 @@ var avlTreeTyped = (() => {
|
|
|
6360
6727
|
this._updateHeight(A);
|
|
6361
6728
|
if (B) this._updateHeight(B);
|
|
6362
6729
|
if (C) this._updateHeight(C);
|
|
6730
|
+
this._updateCount(A);
|
|
6731
|
+
if (B) this._updateCount(B);
|
|
6732
|
+
if (C) this._updateCount(C);
|
|
6363
6733
|
}
|
|
6364
6734
|
/**
|
|
6365
6735
|
* (Protected) Traverses up the tree from the specified node, updating heights and performing rotations as needed.
|
|
@@ -6374,6 +6744,7 @@ var avlTreeTyped = (() => {
|
|
|
6374
6744
|
const A = path[i];
|
|
6375
6745
|
if (A) {
|
|
6376
6746
|
this._updateHeight(A);
|
|
6747
|
+
this._updateCount(A);
|
|
6377
6748
|
switch (this._balanceFactor(A)) {
|
|
6378
6749
|
case -2:
|
|
6379
6750
|
if (A && A.left) {
|