tree-multimap-typed 2.2.2 → 2.2.4

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.
Files changed (53) hide show
  1. package/dist/cjs/index.cjs +245 -72
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +246 -72
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +245 -72
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +246 -72
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -2
  10. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -5
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +98 -5
  12. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +103 -7
  13. package/dist/types/data-structures/binary-tree/bst.d.ts +202 -39
  14. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +86 -37
  15. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +4 -5
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +7 -7
  17. package/dist/types/data-structures/graph/directed-graph.d.ts +126 -1
  18. package/dist/types/data-structures/graph/undirected-graph.d.ts +160 -1
  19. package/dist/types/data-structures/hash/hash-map.d.ts +110 -27
  20. package/dist/types/data-structures/heap/heap.d.ts +107 -58
  21. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +72 -404
  22. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -5
  23. package/dist/types/data-structures/queue/deque.d.ts +95 -67
  24. package/dist/types/data-structures/queue/queue.d.ts +90 -34
  25. package/dist/types/data-structures/stack/stack.d.ts +58 -40
  26. package/dist/types/data-structures/trie/trie.d.ts +109 -47
  27. package/dist/types/interfaces/binary-tree.d.ts +1 -0
  28. package/dist/types/types/data-structures/binary-tree/bst.d.ts +5 -5
  29. package/dist/umd/tree-multimap-typed.js +246 -72
  30. package/dist/umd/tree-multimap-typed.js.map +1 -1
  31. package/dist/umd/tree-multimap-typed.min.js +3 -3
  32. package/dist/umd/tree-multimap-typed.min.js.map +1 -1
  33. package/package.json +2 -2
  34. package/src/data-structures/binary-tree/avl-tree-counter.ts +1 -2
  35. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +7 -8
  36. package/src/data-structures/binary-tree/avl-tree.ts +100 -7
  37. package/src/data-structures/binary-tree/binary-tree.ts +117 -7
  38. package/src/data-structures/binary-tree/bst.ts +431 -93
  39. package/src/data-structures/binary-tree/red-black-tree.ts +85 -37
  40. package/src/data-structures/binary-tree/tree-counter.ts +5 -7
  41. package/src/data-structures/binary-tree/tree-multi-map.ts +9 -10
  42. package/src/data-structures/graph/directed-graph.ts +126 -1
  43. package/src/data-structures/graph/undirected-graph.ts +160 -1
  44. package/src/data-structures/hash/hash-map.ts +110 -27
  45. package/src/data-structures/heap/heap.ts +107 -58
  46. package/src/data-structures/linked-list/doubly-linked-list.ts +72 -404
  47. package/src/data-structures/linked-list/singly-linked-list.ts +121 -5
  48. package/src/data-structures/queue/deque.ts +95 -67
  49. package/src/data-structures/queue/queue.ts +90 -34
  50. package/src/data-structures/stack/stack.ts +58 -40
  51. package/src/data-structures/trie/trie.ts +109 -47
  52. package/src/interfaces/binary-tree.ts +2 -0
  53. package/src/types/data-structures/binary-tree/bst.ts +5 -5
@@ -1464,6 +1464,17 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1464
1464
  }
1465
1465
  return false;
1466
1466
  }
1467
+ /**
1468
+ * Adds or updates a new node to the tree.
1469
+ * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation adds the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
1470
+ *
1471
+ * @param keyNodeOrEntry - The key, node, or entry to add or update.
1472
+ * @param [value] - The value, if providing just a key.
1473
+ * @returns True if the addition was successful, false otherwise.
1474
+ */
1475
+ set(keyNodeOrEntry, value) {
1476
+ return this.add(keyNodeOrEntry, value);
1477
+ }
1467
1478
  /**
1468
1479
  * Adds multiple items to the tree.
1469
1480
  * @remarks Time O(N * M), where N is the number of items to add and M is the size of the tree at insertion (due to O(M) `add` operation). Space O(M) (from `add`) + O(N) (for the `inserted` array).
@@ -1491,6 +1502,17 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1491
1502
  }
1492
1503
  return inserted;
1493
1504
  }
1505
+ /**
1506
+ * Adds or updates multiple items to the tree.
1507
+ * @remarks Time O(N * M), where N is the number of items to add and M is the size of the tree at insertion (due to O(M) `add` operation). Space O(M) (from `add`) + O(N) (for the `inserted` array).
1508
+ *
1509
+ * @param keysNodesEntriesOrRaws - An iterable of items to add or update.
1510
+ * @param [values] - An optional parallel iterable of values.
1511
+ * @returns An array of booleans indicating the success of each individual `add` operation.
1512
+ */
1513
+ setMany(keysNodesEntriesOrRaws, values) {
1514
+ return this.addMany(keysNodesEntriesOrRaws, values);
1515
+ }
1494
1516
  /**
1495
1517
  * Merges another tree into this one by adding all its nodes.
1496
1518
  * @remarks Time O(N * M), same as `addMany`, where N is the size of `anotherTree` and M is the size of this tree. Space O(M) (from `add`).
@@ -2807,36 +2829,20 @@ var _BST = class _BST extends BinaryTree {
2807
2829
  constructor(keysNodesEntriesOrRaws = [], options) {
2808
2830
  super([], options);
2809
2831
  __publicField(this, "_root");
2810
- __publicField(this, "_isReverse", false);
2811
2832
  /**
2812
- * The default comparator function.
2813
- * @remarks Time O(1) (or O(C) if `specifyComparable` is used, C is complexity of that function).
2814
- */
2815
- __publicField(this, "_comparator", /* @__PURE__ */ __name((a, b) => {
2816
- if (isComparable(a) && isComparable(b)) {
2817
- if (a > b) return 1;
2818
- if (a < b) return -1;
2819
- return 0;
2820
- }
2821
- if (this._specifyComparable) {
2822
- const va = this._specifyComparable(a);
2823
- const vb = this._specifyComparable(b);
2824
- if (va > vb) return 1;
2825
- if (va < vb) return -1;
2826
- return 0;
2827
- }
2828
- if (typeof a === "object" || typeof b === "object") {
2829
- throw TypeError(
2830
- `When comparing object types, a custom specifyComparable must be defined in the constructor's options.`
2831
- );
2832
- }
2833
- return 0;
2834
- }, "_comparator"));
2835
- __publicField(this, "_specifyComparable");
2833
+ * The comparator function used to determine the order of keys in the tree.
2834
+
2835
+ * @remarks Time O(1) Space O(1)
2836
+ */
2837
+ __publicField(this, "_comparator");
2836
2838
  if (options) {
2837
- const { specifyComparable, isReverse } = options;
2838
- if (typeof specifyComparable === "function") this._specifyComparable = specifyComparable;
2839
- if (isReverse !== void 0) this._isReverse = isReverse;
2839
+ if ("comparator" in options && options.comparator !== void 0) {
2840
+ this._comparator = options.comparator;
2841
+ } else {
2842
+ this._comparator = this._createDefaultComparator();
2843
+ }
2844
+ } else {
2845
+ this._comparator = this._createDefaultComparator();
2840
2846
  }
2841
2847
  if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
2842
2848
  }
@@ -2850,13 +2856,25 @@ var _BST = class _BST extends BinaryTree {
2850
2856
  return this._root;
2851
2857
  }
2852
2858
  /**
2853
- * Gets whether the tree's comparison logic is reversed.
2854
- * @remarks Time O(1)
2855
- *
2856
- * @returns True if the tree is reversed (e.g., a max-heap logic).
2859
+ * (Protected) Creates the default comparator function for keys that don't have a custom comparator.
2860
+ * @remarks Time O(1) Space O(1)
2861
+ * @returns The default comparator function.
2857
2862
  */
2858
- get isReverse() {
2859
- return this._isReverse;
2863
+ _createDefaultComparator() {
2864
+ return (a, b) => {
2865
+ debugger;
2866
+ if (isComparable(a) && isComparable(b)) {
2867
+ if (a > b) return 1;
2868
+ if (a < b) return -1;
2869
+ return 0;
2870
+ }
2871
+ if (typeof a === "object" || typeof b === "object") {
2872
+ throw TypeError(
2873
+ `When comparing object type keys, a custom comparator must be provided in the constructor's options!`
2874
+ );
2875
+ }
2876
+ return 0;
2877
+ };
2860
2878
  }
2861
2879
  /**
2862
2880
  * Gets the comparator function used by the tree.
@@ -2867,15 +2885,6 @@ var _BST = class _BST extends BinaryTree {
2867
2885
  get comparator() {
2868
2886
  return this._comparator;
2869
2887
  }
2870
- /**
2871
- * Gets the function used to extract a comparable value from a complex key.
2872
- * @remarks Time O(1)
2873
- *
2874
- * @returns The key-to-comparable conversion function.
2875
- */
2876
- get specifyComparable() {
2877
- return this._specifyComparable;
2878
- }
2879
2888
  /**
2880
2889
  * (Protected) Creates a new BST node.
2881
2890
  * @remarks Time O(1), Space O(1)
@@ -2917,7 +2926,7 @@ var _BST = class _BST extends BinaryTree {
2917
2926
  * @returns True if the key is valid, false otherwise.
2918
2927
  */
2919
2928
  isValidKey(key) {
2920
- return isComparable(key, this._specifyComparable !== void 0);
2929
+ return isComparable(key);
2921
2930
  }
2922
2931
  /**
2923
2932
  * Performs a Depth-First Search (DFS) traversal.
@@ -3007,8 +3016,8 @@ var _BST = class _BST extends BinaryTree {
3007
3016
  if (!this.isRealNode(cur.left)) return false;
3008
3017
  if (isRange) {
3009
3018
  const range = keyNodeEntryOrPredicate;
3010
- const leftS = this.isReverse ? range.high : range.low;
3011
- const leftI = this.isReverse ? range.includeHigh : range.includeLow;
3019
+ const leftS = range.low;
3020
+ const leftI = range.includeLow;
3012
3021
  return leftI && this._compare(cur.key, leftS) >= 0 || !leftI && this._compare(cur.key, leftS) > 0;
3013
3022
  }
3014
3023
  if (!isRange && !this._isPredicate(keyNodeEntryOrPredicate)) {
@@ -3022,8 +3031,8 @@ var _BST = class _BST extends BinaryTree {
3022
3031
  if (!this.isRealNode(cur.right)) return false;
3023
3032
  if (isRange) {
3024
3033
  const range = keyNodeEntryOrPredicate;
3025
- const rightS = this.isReverse ? range.low : range.high;
3026
- const rightI = this.isReverse ? range.includeLow : range.includeHigh;
3034
+ const rightS = range.high;
3035
+ const rightI = range.includeHigh;
3027
3036
  return rightI && this._compare(cur.key, rightS) <= 0 || !rightI && this._compare(cur.key, rightS) < 0;
3028
3037
  }
3029
3038
  if (!isRange && !this._isPredicate(keyNodeEntryOrPredicate)) {
@@ -3184,6 +3193,32 @@ var _BST = class _BST extends BinaryTree {
3184
3193
  else _iterate();
3185
3194
  return inserted;
3186
3195
  }
3196
+ /**
3197
+ * Returns the first node with a key greater than or equal to the given key.
3198
+ * This is equivalent to C++ std::lower_bound on a BST.
3199
+ * Supports RECURSIVE and ITERATIVE implementations.
3200
+ * Time Complexity: O(log n) on average, O(h) where h is tree height.
3201
+ * Space Complexity: O(h) for recursion, O(1) for iteration.
3202
+ * @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
3203
+ * @param iterationType The iteration type (RECURSIVE or ITERATIVE). Defaults to this.iterationType.
3204
+ * @returns The first node with key >= given key, or undefined if no such node exists.
3205
+ */
3206
+ lowerBound(keyNodeEntryOrPredicate, iterationType = this.iterationType) {
3207
+ return this._bound(keyNodeEntryOrPredicate, true, iterationType);
3208
+ }
3209
+ /**
3210
+ * Returns the first node with a key strictly greater than the given key.
3211
+ * This is equivalent to C++ std::upper_bound on a BST.
3212
+ * Supports RECURSIVE and ITERATIVE implementations.
3213
+ * Time Complexity: O(log n) on average, O(h) where h is tree height.
3214
+ * Space Complexity: O(h) for recursion, O(1) for iteration.
3215
+ * @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
3216
+ * @param iterationType The iteration type (RECURSIVE or ITERATIVE). Defaults to this.iterationType.
3217
+ * @returns The first node with key > given key, or undefined if no such node exists.
3218
+ */
3219
+ upperBound(keyNodeEntryOrPredicate, iterationType = this.iterationType) {
3220
+ return this._bound(keyNodeEntryOrPredicate, false, iterationType);
3221
+ }
3187
3222
  /**
3188
3223
  * Traverses the tree and returns nodes that are lesser or greater than a target node.
3189
3224
  * @remarks Time O(N), as it performs a full traversal. Space O(log N) or O(N).
@@ -3318,31 +3353,171 @@ var _BST = class _BST extends BinaryTree {
3318
3353
  return out;
3319
3354
  }
3320
3355
  /**
3321
- * Deletes the first node found that satisfies the predicate.
3322
- * @remarks Performs an in-order traversal. Time O(N) worst-case (O(log N) to find + O(log N) to delete). Space O(log N) for stack.
3356
+ * Deletes nodes that match a key, node, entry, predicate, or range.
3323
3357
  *
3324
- * @param predicate - A function to test each [key, value] pair.
3325
- * @returns True if a node was deleted, false otherwise.
3358
+ * @remarks
3359
+ * Time Complexity: O(N) for search + O(M log N) for M deletions, where N is tree size.
3360
+ * Space Complexity: O(M) for storing matched nodes and result map.
3361
+ *
3362
+ * @template K - The key type.
3363
+ * @template V - The value type.
3364
+ *
3365
+ * @param keyNodeEntryOrPredicate - The search criteria. Can be one of:
3366
+ * - A key (type K): searches for exact key match using the comparator.
3367
+ * - A BSTNode: searches for the matching node in the tree.
3368
+ * - An entry tuple: searches for the key-value pair.
3369
+ * - A NodePredicate function: tests each node and returns true for matches.
3370
+ * - A Range object: searches for nodes whose keys fall within the specified range (inclusive/exclusive based on range settings).
3371
+ * - null or undefined: treated as no match, returns empty results.
3372
+ *
3373
+ * @param onlyOne - If true, stops the search after finding the first match and only deletes that one node.
3374
+ * If false (default), searches for and deletes all matching nodes.
3375
+ *
3376
+ * @param startNode - The node to start the search from. Can be:
3377
+ * - A key, node, or entry: the method resolves it to a node and searches from that subtree.
3378
+ * - null or undefined: defaults to the root, searching the entire tree.
3379
+ * - Default value: this._root (the tree's root).
3380
+ *
3381
+ * @param iterationType - Controls the internal traversal implementation:
3382
+ * - 'RECURSIVE': uses recursive function calls for traversal.
3383
+ * - 'ITERATIVE': uses explicit stack-based iteration.
3384
+ * - Default: this.iterationType (the tree's default iteration mode).
3385
+ *
3386
+ * @returns A Map<K, boolean> containing the deletion results:
3387
+ * - Key: the matched node's key.
3388
+ * - Value: true if the deletion succeeded, false if it failed (e.g., key not found during deletion phase).
3389
+ * - If no nodes match the search criteria, the returned map is empty.
3390
+ */
3391
+ deleteWhere(keyNodeEntryOrPredicate, onlyOne = false, startNode = this._root, iterationType = this.iterationType) {
3392
+ const toDelete = this.search(
3393
+ keyNodeEntryOrPredicate,
3394
+ onlyOne,
3395
+ (node) => node,
3396
+ startNode,
3397
+ iterationType
3398
+ );
3399
+ let results = [];
3400
+ for (const node of toDelete) {
3401
+ const deleteInfo = this.delete(node);
3402
+ results = results.concat(deleteInfo);
3403
+ }
3404
+ return results;
3405
+ }
3406
+ /**
3407
+ * (Protected) Core bound search implementation supporting all parameter types.
3408
+ * Unified logic for both lowerBound and upperBound.
3409
+ * Resolves various input types (Key, Node, Entry, Predicate) using parent class utilities.
3410
+ * @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
3411
+ * @param isLower - True for lowerBound (>=), false for upperBound (>).
3412
+ * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).
3413
+ * @returns The first matching node, or undefined if no such node exists.
3326
3414
  */
3327
- deleteWhere(predicate) {
3328
- const stack = [];
3329
- let cur = this._root;
3330
- let index = 0;
3331
- while (stack.length > 0 || cur !== void 0) {
3332
- while (cur !== void 0 && cur !== null) {
3333
- stack.push(cur);
3334
- cur = cur.left;
3415
+ _bound(keyNodeEntryOrPredicate, isLower, iterationType) {
3416
+ if (keyNodeEntryOrPredicate === null || keyNodeEntryOrPredicate === void 0) {
3417
+ return void 0;
3418
+ }
3419
+ if (this._isPredicate(keyNodeEntryOrPredicate)) {
3420
+ return this._boundByPredicate(keyNodeEntryOrPredicate, iterationType);
3421
+ }
3422
+ let targetKey;
3423
+ if (this.isNode(keyNodeEntryOrPredicate)) {
3424
+ targetKey = keyNodeEntryOrPredicate.key;
3425
+ } else if (this.isEntry(keyNodeEntryOrPredicate)) {
3426
+ const key = keyNodeEntryOrPredicate[0];
3427
+ if (key === null || key === void 0) {
3428
+ return void 0;
3429
+ }
3430
+ targetKey = key;
3431
+ } else {
3432
+ targetKey = keyNodeEntryOrPredicate;
3433
+ }
3434
+ if (targetKey !== void 0) {
3435
+ return this._boundByKey(targetKey, isLower, iterationType);
3436
+ }
3437
+ return void 0;
3438
+ }
3439
+ /**
3440
+ * (Protected) Binary search for bound by key with pruning optimization.
3441
+ * Performs standard BST binary search, choosing left or right subtree based on comparator result.
3442
+ * For lowerBound: finds first node where key >= target.
3443
+ * For upperBound: finds first node where key > target.
3444
+ * @param key - The target key to search for.
3445
+ * @param isLower - True for lowerBound (>=), false for upperBound (>).
3446
+ * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).
3447
+ * @returns The first node matching the bound condition, or undefined if none exists.
3448
+ */
3449
+ _boundByKey(key, isLower, iterationType) {
3450
+ var _a, _b;
3451
+ if (iterationType === "RECURSIVE") {
3452
+ const dfs = /* @__PURE__ */ __name((cur) => {
3453
+ if (!this.isRealNode(cur)) return void 0;
3454
+ const cmp = this.comparator(cur.key, key);
3455
+ const condition = isLower ? cmp >= 0 : cmp > 0;
3456
+ if (condition) {
3457
+ const leftResult = dfs(cur.left);
3458
+ return leftResult != null ? leftResult : cur;
3459
+ } else {
3460
+ return dfs(cur.right);
3461
+ }
3462
+ }, "dfs");
3463
+ return dfs(this.root);
3464
+ } else {
3465
+ let current = this.root;
3466
+ let result = void 0;
3467
+ while (this.isRealNode(current)) {
3468
+ const cmp = this.comparator(current.key, key);
3469
+ const condition = isLower ? cmp >= 0 : cmp > 0;
3470
+ if (condition) {
3471
+ result = current;
3472
+ current = (_a = current.left) != null ? _a : void 0;
3473
+ } else {
3474
+ current = (_b = current.right) != null ? _b : void 0;
3475
+ }
3335
3476
  }
3336
- const node = stack.pop();
3337
- if (!node) break;
3338
- const key = node.key;
3339
- const val = node.value;
3340
- if (predicate(key, val, index++, this)) {
3341
- return this._deleteByKey(key);
3477
+ return result;
3478
+ }
3479
+ }
3480
+ /**
3481
+ * (Protected) In-order traversal search by predicate.
3482
+ * Falls back to linear in-order traversal when predicate-based search is required.
3483
+ * Returns the first node that satisfies the predicate function.
3484
+ * Note: Predicate-based search cannot leverage BST's binary search optimization.
3485
+ * Time Complexity: O(n) since it may visit every node.
3486
+ * @param predicate - The predicate function to test nodes.
3487
+ * @param iterationType - The iteration type (RECURSIVE or ITERATIVE).
3488
+ * @returns The first node satisfying predicate, or undefined if none found.
3489
+ */
3490
+ _boundByPredicate(predicate, iterationType) {
3491
+ if (iterationType === "RECURSIVE") {
3492
+ let result = void 0;
3493
+ const dfs = /* @__PURE__ */ __name((cur) => {
3494
+ if (result || !this.isRealNode(cur)) return;
3495
+ if (this.isRealNode(cur.left)) dfs(cur.left);
3496
+ if (!result && predicate(cur)) {
3497
+ result = cur;
3498
+ }
3499
+ if (!result && this.isRealNode(cur.right)) dfs(cur.right);
3500
+ }, "dfs");
3501
+ dfs(this.root);
3502
+ return result;
3503
+ } else {
3504
+ const stack = [];
3505
+ let current = this.root;
3506
+ while (stack.length > 0 || this.isRealNode(current)) {
3507
+ if (this.isRealNode(current)) {
3508
+ stack.push(current);
3509
+ current = current.left;
3510
+ } else {
3511
+ const node = stack.pop();
3512
+ if (!this.isRealNode(node)) break;
3513
+ if (predicate(node)) {
3514
+ return node;
3515
+ }
3516
+ current = node.right;
3517
+ }
3342
3518
  }
3343
- cur = node.right;
3519
+ return void 0;
3344
3520
  }
3345
- return false;
3346
3521
  }
3347
3522
  /**
3348
3523
  * (Protected) Creates a new, empty instance of the same BST constructor.
@@ -3379,8 +3554,7 @@ var _BST = class _BST extends BinaryTree {
3379
3554
  _snapshotOptions() {
3380
3555
  return {
3381
3556
  ...super._snapshotOptions(),
3382
- specifyComparable: this.specifyComparable,
3383
- isReverse: this.isReverse
3557
+ comparator: this._comparator
3384
3558
  };
3385
3559
  }
3386
3560
  /**
@@ -3408,14 +3582,14 @@ var _BST = class _BST extends BinaryTree {
3408
3582
  }
3409
3583
  /**
3410
3584
  * (Protected) Compares two keys using the tree's comparator and reverse setting.
3411
- * @remarks Time O(1) (or O(C) if `specifyComparable` is used).
3585
+ * @remarks Time O(1) Space O(1)
3412
3586
  *
3413
3587
  * @param a - The first key.
3414
3588
  * @param b - The second key.
3415
3589
  * @returns A number (1, -1, or 0) representing the comparison.
3416
3590
  */
3417
3591
  _compare(a, b) {
3418
- return this._isReverse ? -this._comparator(a, b) : this._comparator(a, b);
3592
+ return this._comparator(a, b);
3419
3593
  }
3420
3594
  /**
3421
3595
  * (Private) Deletes a node by its key.