data-structure-typed 1.51.6 → 1.51.8

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 (92) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/benchmark/report.html +37 -1
  4. package/benchmark/report.json +405 -3
  5. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -12
  6. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +2 -10
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +3 -3
  9. package/dist/cjs/data-structures/binary-tree/avl-tree.js +12 -14
  10. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +7 -13
  12. package/dist/cjs/data-structures/binary-tree/binary-tree.js +46 -78
  13. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/bst.d.ts +51 -96
  15. package/dist/cjs/data-structures/binary-tree/bst.js +120 -218
  16. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +3 -4
  18. package/dist/cjs/data-structures/binary-tree/rb-tree.js +4 -2
  19. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  21. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +1 -0
  22. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  23. package/dist/cjs/data-structures/heap/heap.d.ts +1 -3
  24. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  25. package/dist/cjs/interfaces/binary-tree.d.ts +3 -3
  26. package/dist/cjs/types/common.d.ts +1 -1
  27. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -2
  28. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -2
  29. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
  30. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +6 -5
  31. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +4 -3
  32. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -2
  33. package/dist/cjs/types/utils/utils.d.ts +10 -1
  34. package/dist/cjs/utils/utils.d.ts +2 -1
  35. package/dist/cjs/utils/utils.js +29 -1
  36. package/dist/cjs/utils/utils.js.map +1 -1
  37. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -12
  38. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +2 -10
  39. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +3 -3
  40. package/dist/mjs/data-structures/binary-tree/avl-tree.js +12 -14
  41. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +7 -13
  42. package/dist/mjs/data-structures/binary-tree/binary-tree.js +45 -77
  43. package/dist/mjs/data-structures/binary-tree/bst.d.ts +51 -96
  44. package/dist/mjs/data-structures/binary-tree/bst.js +122 -221
  45. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +3 -4
  46. package/dist/mjs/data-structures/binary-tree/rb-tree.js +4 -2
  47. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  48. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +1 -0
  49. package/dist/mjs/data-structures/heap/heap.d.ts +1 -3
  50. package/dist/mjs/interfaces/binary-tree.d.ts +3 -3
  51. package/dist/mjs/types/common.d.ts +1 -1
  52. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -2
  53. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -2
  54. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
  55. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +6 -5
  56. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +4 -3
  57. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -2
  58. package/dist/mjs/types/utils/utils.d.ts +10 -1
  59. package/dist/mjs/utils/utils.d.ts +2 -1
  60. package/dist/mjs/utils/utils.js +27 -0
  61. package/dist/umd/data-structure-typed.js +206 -301
  62. package/dist/umd/data-structure-typed.min.js +4 -4
  63. package/dist/umd/data-structure-typed.min.js.map +1 -1
  64. package/package.json +6 -6
  65. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +5 -12
  66. package/src/data-structures/binary-tree/avl-tree.ts +15 -15
  67. package/src/data-structures/binary-tree/binary-tree.ts +56 -76
  68. package/src/data-structures/binary-tree/bst.ts +132 -224
  69. package/src/data-structures/binary-tree/rb-tree.ts +9 -6
  70. package/src/data-structures/binary-tree/tree-multi-map.ts +5 -3
  71. package/src/data-structures/heap/heap.ts +1 -1
  72. package/src/interfaces/binary-tree.ts +4 -3
  73. package/src/types/common.ts +1 -1
  74. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -2
  75. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -2
  76. package/src/types/data-structures/binary-tree/binary-tree.ts +5 -5
  77. package/src/types/data-structures/binary-tree/bst.ts +6 -5
  78. package/src/types/data-structures/binary-tree/rb-tree.ts +4 -3
  79. package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -2
  80. package/src/types/utils/utils.ts +14 -1
  81. package/src/utils/utils.ts +20 -1
  82. package/test/integration/all-in-one.test.ts +2 -2
  83. package/test/integration/index.html +70 -0
  84. package/test/performance/data-structures/binary-tree/binary-tree-overall.test.ts +7 -7
  85. package/test/performance/reportor.ts +2 -3
  86. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +7 -7
  87. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +2 -2
  88. package/test/unit/data-structures/binary-tree/bst.test.ts +6 -6
  89. package/test/unit/data-structures/binary-tree/overall.test.ts +24 -20
  90. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +6 -6
  91. package/test/unit/utils/utils.test.ts +5 -0
  92. package/test/utils/console.ts +1 -1
@@ -160,6 +160,7 @@ var dataStructureTyped = (() => {
160
160
  arrayRemove: () => arrayRemove,
161
161
  calcMinUnitsRequired: () => calcMinUnitsRequired,
162
162
  getMSB: () => getMSB,
163
+ isComparable: () => isComparable,
163
164
  isThunk: () => isThunk,
164
165
  isWeakKey: () => isWeakKey,
165
166
  rangeCheck: () => rangeCheck,
@@ -711,6 +712,33 @@ var dataStructureTyped = (() => {
711
712
  const multiplier = Math.pow(10, digit);
712
713
  return Math.round(num * multiplier) / multiplier;
713
714
  };
715
+ function isComparable(key) {
716
+ const keyType = typeof key;
717
+ if (keyType === "number")
718
+ return isNaN(key);
719
+ if (keyType === "string")
720
+ return true;
721
+ if (keyType === "bigint")
722
+ return true;
723
+ if (keyType === "boolean")
724
+ return true;
725
+ if (keyType === "symbol")
726
+ return false;
727
+ if (keyType === "undefined")
728
+ return false;
729
+ if (keyType === "function")
730
+ return isComparable(key());
731
+ if (keyType === "object") {
732
+ if (key === null)
733
+ return true;
734
+ if (typeof key.valueOf === "function")
735
+ return isComparable(key.valueOf());
736
+ if (typeof key.toString === "function")
737
+ return isComparable(key.toString());
738
+ return false;
739
+ }
740
+ return false;
741
+ }
714
742
 
715
743
  // src/utils/number.ts
716
744
  function toBinaryString(num, digit = 32) {
@@ -7745,29 +7773,19 @@ var dataStructureTyped = (() => {
7745
7773
  constructor(keysOrNodesOrEntries = [], options) {
7746
7774
  super();
7747
7775
  __publicField(this, "iterationType", "ITERATIVE");
7748
- __publicField(this, "_extractor", (key) => typeof key === "number" ? key : Number(key));
7749
7776
  __publicField(this, "_root");
7750
7777
  __publicField(this, "_size");
7751
7778
  __publicField(this, "_NIL", new BinaryTreeNode(NaN));
7752
7779
  __publicField(this, "_DEFAULT_CALLBACK", (node) => node ? node.key : void 0);
7753
7780
  if (options) {
7754
- const { iterationType, extractor } = options;
7781
+ const { iterationType } = options;
7755
7782
  if (iterationType)
7756
7783
  this.iterationType = iterationType;
7757
- if (extractor)
7758
- this._extractor = extractor;
7759
7784
  }
7760
7785
  this._size = 0;
7761
7786
  if (keysOrNodesOrEntries)
7762
7787
  this.addMany(keysOrNodesOrEntries);
7763
7788
  }
7764
- /**
7765
- * The function returns the value of the `_extractor` property.
7766
- * @returns The `_extractor` property is being returned.
7767
- */
7768
- get extractor() {
7769
- return this._extractor;
7770
- }
7771
7789
  /**
7772
7790
  * The function returns the root node, which can be of type NODE, null, or undefined.
7773
7791
  * @returns The method is returning the value of the `_root` property, which can be of type `NODE`,
@@ -7860,21 +7878,24 @@ var dataStructureTyped = (() => {
7860
7878
  * itself if it is not a valid node key.
7861
7879
  */
7862
7880
  ensureNode(keyOrNodeOrEntry, iterationType = "ITERATIVE") {
7881
+ if (keyOrNodeOrEntry === this.NIL)
7882
+ return;
7863
7883
  if (this.isRealNode(keyOrNodeOrEntry)) {
7864
7884
  return keyOrNodeOrEntry;
7865
- } else if (this.isEntry(keyOrNodeOrEntry)) {
7866
- if (keyOrNodeOrEntry[0] === null)
7867
- return null;
7868
- if (keyOrNodeOrEntry[0] === void 0)
7869
- return;
7870
- return this.getNodeByKey(keyOrNodeOrEntry[0], iterationType);
7871
- } else {
7872
- if (keyOrNodeOrEntry === null)
7885
+ }
7886
+ if (this.isEntry(keyOrNodeOrEntry)) {
7887
+ const key = keyOrNodeOrEntry[0];
7888
+ if (key === null)
7873
7889
  return null;
7874
- if (keyOrNodeOrEntry === void 0)
7890
+ if (key === void 0)
7875
7891
  return;
7876
- return this.getNodeByKey(keyOrNodeOrEntry, iterationType);
7892
+ return this.getNodeByKey(key, iterationType);
7877
7893
  }
7894
+ if (keyOrNodeOrEntry === null)
7895
+ return null;
7896
+ if (keyOrNodeOrEntry === void 0)
7897
+ return;
7898
+ return this.getNodeByKey(keyOrNodeOrEntry, iterationType);
7878
7899
  }
7879
7900
  /**
7880
7901
  * The function checks if a given node is a real node or null.
@@ -8052,8 +8073,7 @@ var dataStructureTyped = (() => {
8052
8073
  const deletedResult = [];
8053
8074
  if (!this.root)
8054
8075
  return deletedResult;
8055
- if ((!callback || callback === this._DEFAULT_CALLBACK) && identifier instanceof BinaryTreeNode)
8056
- callback = (node) => node;
8076
+ callback = this._ensureCallback(identifier, callback);
8057
8077
  const curr = this.getNode(identifier, callback);
8058
8078
  if (!curr)
8059
8079
  return deletedResult;
@@ -8121,11 +8141,10 @@ var dataStructureTyped = (() => {
8121
8141
  * @returns an array of nodes of type `NODE`.
8122
8142
  */
8123
8143
  getNodes(identifier, callback = this._DEFAULT_CALLBACK, onlyOne = false, beginRoot = this.root, iterationType = this.iterationType) {
8124
- if ((!callback || callback === this._DEFAULT_CALLBACK) && identifier instanceof BinaryTreeNode)
8125
- callback = (node) => node;
8126
8144
  beginRoot = this.ensureNode(beginRoot);
8127
8145
  if (!beginRoot)
8128
8146
  return [];
8147
+ callback = this._ensureCallback(identifier, callback);
8129
8148
  const ans = [];
8130
8149
  if (iterationType === "RECURSIVE") {
8131
8150
  const dfs = (cur) => {
@@ -8205,32 +8224,7 @@ var dataStructureTyped = (() => {
8205
8224
  * found in the binary tree. If no node is found, it returns `undefined`.
8206
8225
  */
8207
8226
  getNodeByKey(key, iterationType = "ITERATIVE") {
8208
- if (!this.root)
8209
- return void 0;
8210
- if (iterationType === "RECURSIVE") {
8211
- const dfs = (cur) => {
8212
- if (cur.key === key)
8213
- return cur;
8214
- if (!cur.left && !cur.right)
8215
- return;
8216
- if (cur.left)
8217
- return dfs(cur.left);
8218
- if (cur.right)
8219
- return dfs(cur.right);
8220
- };
8221
- return dfs(this.root);
8222
- } else {
8223
- const stack = [this.root];
8224
- while (stack.length > 0) {
8225
- const cur = stack.pop();
8226
- if (cur) {
8227
- if (cur.key === key)
8228
- return cur;
8229
- cur.left && stack.push(cur.left);
8230
- cur.right && stack.push(cur.right);
8231
- }
8232
- }
8233
- }
8227
+ return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType);
8234
8228
  }
8235
8229
  /**
8236
8230
  * Time Complexity: O(n)
@@ -8259,8 +8253,8 @@ var dataStructureTyped = (() => {
8259
8253
  * found, `undefined` is returned.
8260
8254
  */
8261
8255
  get(identifier, callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
8262
- var _a, _b;
8263
- return (_b = (_a = this.getNode(identifier, callback, beginRoot, iterationType)) == null ? void 0 : _a.value) != null ? _b : void 0;
8256
+ var _a;
8257
+ return (_a = this.getNode(identifier, callback, beginRoot, iterationType)) == null ? void 0 : _a.value;
8264
8258
  }
8265
8259
  /**
8266
8260
  * Time Complexity: O(n)
@@ -8288,8 +8282,7 @@ var dataStructureTyped = (() => {
8288
8282
  * @returns a boolean value.
8289
8283
  */
8290
8284
  has(identifier, callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
8291
- if ((!callback || callback === this._DEFAULT_CALLBACK) && identifier instanceof BinaryTreeNode)
8292
- callback = (node) => node;
8285
+ callback = this._ensureCallback(identifier, callback);
8293
8286
  return this.getNodes(identifier, callback, true, beginRoot, iterationType).length > 0;
8294
8287
  }
8295
8288
  /**
@@ -8362,7 +8355,7 @@ var dataStructureTyped = (() => {
8362
8355
  const dfs = (cur, min, max) => {
8363
8356
  if (!this.isRealNode(cur))
8364
8357
  return true;
8365
- const numKey = this.extractor(cur.key);
8358
+ const numKey = Number(cur.key);
8366
8359
  if (numKey <= min || numKey >= max)
8367
8360
  return false;
8368
8361
  return dfs(cur.left, min, numKey) && dfs(cur.right, numKey, max);
@@ -8381,7 +8374,7 @@ var dataStructureTyped = (() => {
8381
8374
  curr = curr.left;
8382
8375
  }
8383
8376
  curr = stack.pop();
8384
- const numKey = this.extractor(curr.key);
8377
+ const numKey = Number(curr.key);
8385
8378
  if (!this.isRealNode(curr) || !checkMax && prev >= numKey || checkMax && prev <= numKey)
8386
8379
  return false;
8387
8380
  prev = numKey;
@@ -8411,15 +8404,15 @@ var dataStructureTyped = (() => {
8411
8404
  * @returns the depth of the `dist` relative to the `beginRoot`.
8412
8405
  */
8413
8406
  getDepth(dist, beginRoot = this.root) {
8414
- dist = this.ensureNode(dist);
8415
- beginRoot = this.ensureNode(beginRoot);
8407
+ let distEnsured = this.ensureNode(dist);
8408
+ const beginRootEnsured = this.ensureNode(beginRoot);
8416
8409
  let depth = 0;
8417
- while (dist == null ? void 0 : dist.parent) {
8418
- if (dist === beginRoot) {
8410
+ while (distEnsured == null ? void 0 : distEnsured.parent) {
8411
+ if (distEnsured === beginRootEnsured) {
8419
8412
  return depth;
8420
8413
  }
8421
8414
  depth++;
8422
- dist = dist.parent;
8415
+ distEnsured = distEnsured.parent;
8423
8416
  }
8424
8417
  return depth;
8425
8418
  }
@@ -8548,14 +8541,14 @@ var dataStructureTyped = (() => {
8548
8541
  */
8549
8542
  getPathToRoot(beginNode, isReverse = true) {
8550
8543
  const result = [];
8551
- beginNode = this.ensureNode(beginNode);
8552
- if (!beginNode)
8544
+ let beginNodeEnsured = this.ensureNode(beginNode);
8545
+ if (!beginNodeEnsured)
8553
8546
  return result;
8554
- while (beginNode.parent) {
8555
- result.push(beginNode);
8556
- beginNode = beginNode.parent;
8547
+ while (beginNodeEnsured.parent) {
8548
+ result.push(beginNodeEnsured);
8549
+ beginNodeEnsured = beginNodeEnsured.parent;
8557
8550
  }
8558
- result.push(beginNode);
8551
+ result.push(beginNodeEnsured);
8559
8552
  return isReverse ? result.reverse() : result;
8560
8553
  }
8561
8554
  /**
@@ -9183,10 +9176,10 @@ var dataStructureTyped = (() => {
9183
9176
  console.log(`U for undefined
9184
9177
  `);
9185
9178
  if (opts.isShowNull)
9186
- console.log(`NODE for null
9179
+ console.log(`N for null
9187
9180
  `);
9188
9181
  if (opts.isShowRedBlackNIL)
9189
- console.log(`S for Sentinel Node
9182
+ console.log(`S for Sentinel Node(NIL)
9190
9183
  `);
9191
9184
  const display = (root) => {
9192
9185
  const [lines, , ,] = this._displayAux(root, opts);
@@ -9212,22 +9205,22 @@ var dataStructureTyped = (() => {
9212
9205
  const stack = [];
9213
9206
  let current = node;
9214
9207
  while (current || stack.length > 0) {
9215
- while (current && !isNaN(this.extractor(current.key))) {
9208
+ while (this.isRealNode(current)) {
9216
9209
  stack.push(current);
9217
9210
  current = current.left;
9218
9211
  }
9219
9212
  current = stack.pop();
9220
- if (current && !isNaN(this.extractor(current.key))) {
9213
+ if (this.isRealNode(current)) {
9221
9214
  yield [current.key, current.value];
9222
9215
  current = current.right;
9223
9216
  }
9224
9217
  }
9225
9218
  } else {
9226
- if (node.left && !isNaN(this.extractor(node.key))) {
9219
+ if (node.left && this.isRealNode(node)) {
9227
9220
  yield* __yieldStar(this[Symbol.iterator](node.left));
9228
9221
  }
9229
9222
  yield [node.key, node.value];
9230
- if (node.right && !isNaN(this.extractor(node.key))) {
9223
+ if (node.right && this.isRealNode(node)) {
9231
9224
  yield* __yieldStar(this[Symbol.iterator](node.right));
9232
9225
  }
9233
9226
  }
@@ -9253,10 +9246,10 @@ var dataStructureTyped = (() => {
9253
9246
  return emptyDisplayLayout;
9254
9247
  } else if (node === void 0 && !isShowUndefined) {
9255
9248
  return emptyDisplayLayout;
9256
- } else if (node !== null && node !== void 0 && isNaN(this.extractor(node.key)) && !isShowRedBlackNIL) {
9249
+ } else if (this.isNIL(node) && !isShowRedBlackNIL) {
9257
9250
  return emptyDisplayLayout;
9258
9251
  } else if (node !== null && node !== void 0) {
9259
- const key = node.key, line = isNaN(this.extractor(key)) ? "S" : this.extractor(key).toString(), width = line.length;
9252
+ const key = node.key, line = this.isNIL(node) ? "S" : key.toString(), width = line.length;
9260
9253
  return _buildNodeDisplay(
9261
9254
  line,
9262
9255
  width,
@@ -9344,6 +9337,12 @@ var dataStructureTyped = (() => {
9344
9337
  }
9345
9338
  this._root = v;
9346
9339
  }
9340
+ _ensureCallback(identifier, callback = this._DEFAULT_CALLBACK) {
9341
+ if ((!callback || callback === this._DEFAULT_CALLBACK) && this.isNode(identifier)) {
9342
+ callback = (node) => node;
9343
+ }
9344
+ return callback;
9345
+ }
9347
9346
  };
9348
9347
 
9349
9348
  // src/data-structures/binary-tree/bst.ts
@@ -9397,23 +9396,29 @@ var dataStructureTyped = (() => {
9397
9396
  };
9398
9397
  var BST = class _BST extends BinaryTree {
9399
9398
  /**
9400
- * This is the constructor function for a TypeScript class that initializes a binary search tree with
9401
- * optional keys or nodes or entries and options.
9402
- * @param keysOrNodesOrEntries - An iterable object that contains keys, nodes, or entries. It is used
9403
- * to initialize the binary search tree with the provided keys, nodes, or entries.
9399
+ * This is the constructor function for a Binary Search Tree class in TypeScript, which initializes
9400
+ * the tree with keys, nodes, or entries and optional options.
9401
+ * @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
9402
+ * contain keys, nodes, or entries. It is used to initialize the binary search tree with the provided
9403
+ * keys, nodes, or entries.
9404
9404
  * @param [options] - The `options` parameter is an optional object that can contain additional
9405
9405
  * configuration options for the binary search tree. It can have the following properties:
9406
9406
  */
9407
9407
  constructor(keysOrNodesOrEntries = [], options) {
9408
9408
  super([], options);
9409
9409
  __publicField(this, "_root");
9410
- __publicField(this, "_variant", "STANDARD");
9410
+ __publicField(this, "_comparator", (a, b) => {
9411
+ if (a > b)
9412
+ return 1;
9413
+ if (a < b)
9414
+ return -1;
9415
+ return 0;
9416
+ });
9411
9417
  if (options) {
9412
- const { variant } = options;
9413
- if (variant)
9414
- this._variant = variant;
9418
+ const { comparator } = options;
9419
+ if (comparator)
9420
+ this._comparator = comparator;
9415
9421
  }
9416
- this._root = void 0;
9417
9422
  if (keysOrNodesOrEntries)
9418
9423
  this.addMany(keysOrNodesOrEntries);
9419
9424
  }
@@ -9425,11 +9430,11 @@ var dataStructureTyped = (() => {
9425
9430
  return this._root;
9426
9431
  }
9427
9432
  /**
9428
- * The function returns the value of the _variant property.
9429
- * @returns The value of the `_variant` property.
9433
+ * The function returns the value of the _comparator property.
9434
+ * @returns The `_comparator` property is being returned.
9430
9435
  */
9431
- get variant() {
9432
- return this._variant;
9436
+ get comparator() {
9437
+ return this._comparator;
9433
9438
  }
9434
9439
  /**
9435
9440
  * The function creates a new BSTNode with the given key and value and returns it.
@@ -9453,7 +9458,7 @@ var dataStructureTyped = (() => {
9453
9458
  createTree(options) {
9454
9459
  return new _BST([], __spreadValues({
9455
9460
  iterationType: this.iterationType,
9456
- variant: this.variant
9461
+ comparator: this.comparator
9457
9462
  }, options));
9458
9463
  }
9459
9464
  /**
@@ -9501,17 +9506,21 @@ var dataStructureTyped = (() => {
9501
9506
  * @returns either a node object (NODE) or undefined.
9502
9507
  */
9503
9508
  ensureNode(keyOrNodeOrEntry, iterationType = "ITERATIVE") {
9509
+ if (keyOrNodeOrEntry === this.NIL)
9510
+ return;
9504
9511
  if (this.isRealNode(keyOrNodeOrEntry)) {
9505
9512
  return keyOrNodeOrEntry;
9506
- } else if (this.isEntry(keyOrNodeOrEntry)) {
9507
- if (keyOrNodeOrEntry[0] === null || keyOrNodeOrEntry[0] === void 0)
9508
- return;
9509
- return this.getNodeByKey(keyOrNodeOrEntry[0], iterationType);
9510
- } else {
9511
- if (keyOrNodeOrEntry === null || keyOrNodeOrEntry === void 0)
9513
+ }
9514
+ if (this.isEntry(keyOrNodeOrEntry)) {
9515
+ const key2 = keyOrNodeOrEntry[0];
9516
+ if (key2 === null || key2 === void 0)
9512
9517
  return;
9513
- return this.getNodeByKey(keyOrNodeOrEntry, iterationType);
9518
+ return this.getNodeByKey(key2, iterationType);
9514
9519
  }
9520
+ const key = keyOrNodeOrEntry;
9521
+ if (key === null || key === void 0)
9522
+ return;
9523
+ return this.getNodeByKey(key, iterationType);
9515
9524
  }
9516
9525
  /**
9517
9526
  * The function checks if an keyOrNodeOrEntry is an instance of BSTNode.
@@ -9529,13 +9538,11 @@ var dataStructureTyped = (() => {
9529
9538
  * Time Complexity: O(log n)
9530
9539
  * Space Complexity: O(1)
9531
9540
  *
9532
- * The `add` function adds a new node to a binary tree, updating the value if the key already exists
9533
- * or inserting a new node if the key is unique.
9534
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
9535
- * @param {V} [value] - The `value` parameter represents the value associated with the key that is
9536
- * being added to the binary tree.
9537
- * @returns The method `add` returns either the newly added node (`newNode`) or `undefined` if the
9538
- * node was not added.
9541
+ * The `add` function in TypeScript adds a new node to a binary search tree based on the key value,
9542
+ * updating the value if the key already exists.
9543
+ * @param keyOrNodeOrEntry - It is a parameter that can accept three types of values:
9544
+ * @param {V} [value] - The value to be added to the binary search tree.
9545
+ * @returns The method returns a boolean value.
9539
9546
  */
9540
9547
  add(keyOrNodeOrEntry, value) {
9541
9548
  const newNode = this.keyValueOrEntryToNode(keyOrNodeOrEntry, value);
@@ -9548,10 +9555,10 @@ var dataStructureTyped = (() => {
9548
9555
  }
9549
9556
  let current = this.root;
9550
9557
  while (current !== void 0) {
9551
- if (this._compare(current.key, newNode.key) === "EQ") {
9558
+ if (this.comparator(current.key, newNode.key) === 0) {
9552
9559
  this._replaceNode(current, newNode);
9553
9560
  return true;
9554
- } else if (this._compare(current.key, newNode.key) === "GT") {
9561
+ } else if (this.comparator(current.key, newNode.key) > 0) {
9555
9562
  if (current.left === void 0) {
9556
9563
  current.left = newNode;
9557
9564
  this._size++;
@@ -9577,21 +9584,24 @@ var dataStructureTyped = (() => {
9577
9584
  * Time Complexity: O(k log n)
9578
9585
  * Space Complexity: O(k + log n)
9579
9586
  *
9580
- * The `addMany` function in TypeScript adds multiple keys or nodes to a binary tree, optionally
9581
- * balancing the tree after each addition.
9582
- * @param keysOrNodesOrEntries - An iterable containing the keys, nodes, or entries to be added to
9583
- * the binary tree.
9587
+ * The `addMany` function in TypeScript adds multiple keys or nodes to a data structure, balancing
9588
+ * the structure if specified, and returns an array indicating whether each key or node was
9589
+ * successfully inserted.
9590
+ * @param keysOrNodesOrEntries - An iterable containing keys, nodes, or entries to be added to the
9591
+ * data structure.
9584
9592
  * @param [values] - An optional iterable of values to be associated with the keys or nodes being
9585
9593
  * added. If provided, the values will be assigned to the corresponding keys or nodes in the same
9586
9594
  * order. If not provided, undefined will be assigned as the value for each key or node.
9587
- * @param [isBalanceAdd=true] - A boolean flag indicating whether the add operation should be
9588
- * balanced or not. If set to true, the add operation will be balanced using a binary search tree
9589
- * algorithm. If set to false, the add operation will not be balanced and the nodes will be added
9590
- * in the order they appear in the input.
9591
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
9592
- * type of iteration to use when adding multiple keys or nodes. It has a default value of
9593
- * `this.iterationType`, which suggests that it is a property of the current object.
9594
- * @returns The function `addMany` returns an array of nodes (`NODE`) or `undefined` values.
9595
+ * @param [isBalanceAdd=true] - A boolean flag indicating whether the tree should be balanced after
9596
+ * adding the elements. If set to true, the tree will be balanced using a binary search tree
9597
+ * algorithm. If set to false, the elements will be added without balancing the tree. The default
9598
+ * value is true.
9599
+ * @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
9600
+ * specifies the type of iteration to use when adding multiple keys or nodes to the binary tree. It
9601
+ * has a default value of `this.iterationType`, which means it will use the iteration type specified
9602
+ * in the binary tree instance.
9603
+ * @returns The function `addMany` returns an array of booleans indicating whether each key or node
9604
+ * or entry was successfully inserted into the data structure.
9595
9605
  */
9596
9606
  addMany(keysOrNodesOrEntries, values, isBalanceAdd = true, iterationType = this.iterationType) {
9597
9607
  const inserted = [];
@@ -9618,20 +9628,23 @@ var dataStructureTyped = (() => {
9618
9628
  }
9619
9629
  let sorted = [];
9620
9630
  sorted = realBTNExemplars.sort((a, b) => {
9621
- let aR, bR;
9622
- if (this.isEntry(a))
9623
- aR = this.extractor(a[0]);
9624
- else if (this.isRealNode(a))
9625
- aR = this.extractor(a.key);
9631
+ let keyA, keyB;
9632
+ if (this.isEntry(a)) {
9633
+ keyA = a[0];
9634
+ } else if (this.isRealNode(a))
9635
+ keyA = a.key;
9626
9636
  else
9627
- aR = this.extractor(a);
9637
+ keyA = a;
9628
9638
  if (this.isEntry(b))
9629
- bR = this.extractor(b[0]);
9639
+ keyB = b[0];
9630
9640
  else if (this.isRealNode(b))
9631
- bR = this.extractor(b.key);
9641
+ keyB = b.key;
9632
9642
  else
9633
- bR = this.extractor(b);
9634
- return aR - bR;
9643
+ keyB = b;
9644
+ if (keyA !== void 0 && keyA !== null && keyB !== void 0 && keyB !== null) {
9645
+ return this.comparator(keyA, keyB);
9646
+ }
9647
+ return 0;
9635
9648
  });
9636
9649
  const _dfs = (arr) => {
9637
9650
  if (arr.length === 0)
@@ -9666,54 +9679,6 @@ var dataStructureTyped = (() => {
9666
9679
  }
9667
9680
  return inserted;
9668
9681
  }
9669
- /**
9670
- * Time Complexity: O(log n)
9671
- * Space Complexity: O(1)
9672
- */
9673
- /**
9674
- * Time Complexity: O(log n)
9675
- * Space Complexity: O(1)
9676
- *
9677
- * The function `getNodeByKey` searches for a node in a binary tree based on a given key, using
9678
- * either recursive or iterative methods.
9679
- * @param {K} key - The `key` parameter is the key value that we are searching for in the tree.
9680
- * It is used to identify the node that we want to retrieve.
9681
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
9682
- * type of iteration to use when searching for a node in the binary tree. It can have two possible
9683
- * values:
9684
- * @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is
9685
- * found in the binary tree. If no node is found, it returns `undefined`.
9686
- */
9687
- getNodeByKey(key, iterationType = "ITERATIVE") {
9688
- if (!this.isRealNode(this.root))
9689
- return;
9690
- if (iterationType === "RECURSIVE") {
9691
- const dfs = (cur) => {
9692
- if (cur.key === key)
9693
- return cur;
9694
- if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right))
9695
- return;
9696
- if (this.isRealNode(cur.left) && this._compare(cur.key, key) === "GT")
9697
- return dfs(cur.left);
9698
- if (this.isRealNode(cur.right) && this._compare(cur.key, key) === "LT")
9699
- return dfs(cur.right);
9700
- };
9701
- return dfs(this.root);
9702
- } else {
9703
- const stack = [this.root];
9704
- while (stack.length > 0) {
9705
- const cur = stack.pop();
9706
- if (this.isRealNode(cur)) {
9707
- if (this._compare(cur.key, key) === "EQ")
9708
- return cur;
9709
- if (this.isRealNode(cur.left) && this._compare(cur.key, key) === "GT")
9710
- stack.push(cur.left);
9711
- if (this.isRealNode(cur.right) && this._compare(cur.key, key) === "LT")
9712
- stack.push(cur.right);
9713
- }
9714
- }
9715
- }
9716
- }
9717
9682
  /**
9718
9683
  * Time Complexity: O(log n)
9719
9684
  * Space Complexity: O(k + log n)
@@ -9746,6 +9711,7 @@ var dataStructureTyped = (() => {
9746
9711
  beginRoot = this.ensureNode(beginRoot);
9747
9712
  if (!beginRoot)
9748
9713
  return [];
9714
+ callback = this._ensureCallback(identifier, callback);
9749
9715
  const ans = [];
9750
9716
  if (iterationType === "RECURSIVE") {
9751
9717
  const dfs = (cur) => {
@@ -9758,9 +9724,9 @@ var dataStructureTyped = (() => {
9758
9724
  if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right))
9759
9725
  return;
9760
9726
  if (callback === this._DEFAULT_CALLBACK) {
9761
- if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === "GT")
9727
+ if (this.isRealNode(cur.left) && this.comparator(cur.key, identifier) > 0)
9762
9728
  dfs(cur.left);
9763
- if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === "LT")
9729
+ if (this.isRealNode(cur.right) && this.comparator(cur.key, identifier) < 0)
9764
9730
  dfs(cur.right);
9765
9731
  } else {
9766
9732
  this.isRealNode(cur.left) && dfs(cur.left);
@@ -9772,22 +9738,20 @@ var dataStructureTyped = (() => {
9772
9738
  const stack = [beginRoot];
9773
9739
  while (stack.length > 0) {
9774
9740
  const cur = stack.pop();
9775
- if (this.isRealNode(cur)) {
9776
- const callbackResult = callback(cur);
9777
- if (callbackResult === identifier) {
9778
- ans.push(cur);
9779
- if (onlyOne)
9780
- return ans;
9781
- }
9782
- if (callback === this._DEFAULT_CALLBACK) {
9783
- if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === "LT")
9784
- stack.push(cur.right);
9785
- if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === "GT")
9786
- stack.push(cur.left);
9787
- } else {
9788
- this.isRealNode(cur.right) && stack.push(cur.right);
9789
- this.isRealNode(cur.left) && stack.push(cur.left);
9790
- }
9741
+ const callbackResult = callback(cur);
9742
+ if (callbackResult === identifier) {
9743
+ ans.push(cur);
9744
+ if (onlyOne)
9745
+ return ans;
9746
+ }
9747
+ if (callback === this._DEFAULT_CALLBACK) {
9748
+ if (this.isRealNode(cur.right) && this.comparator(cur.key, identifier) < 0)
9749
+ stack.push(cur.right);
9750
+ if (this.isRealNode(cur.left) && this.comparator(cur.key, identifier) > 0)
9751
+ stack.push(cur.left);
9752
+ } else {
9753
+ this.isRealNode(cur.right) && stack.push(cur.right);
9754
+ this.isRealNode(cur.left) && stack.push(cur.left);
9791
9755
  }
9792
9756
  }
9793
9757
  }
@@ -9822,6 +9786,27 @@ var dataStructureTyped = (() => {
9822
9786
  var _a;
9823
9787
  return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) != null ? _a : void 0;
9824
9788
  }
9789
+ /**
9790
+ * Time Complexity: O(log n)
9791
+ * Space Complexity: O(1)
9792
+ */
9793
+ /**
9794
+ * Time Complexity: O(log n)
9795
+ * Space Complexity: O(1)
9796
+ *
9797
+ * The function `getNodeByKey` searches for a node in a binary tree based on a given key, using
9798
+ * either recursive or iterative methods.
9799
+ * @param {K} key - The `key` parameter is the key value that we are searching for in the tree.
9800
+ * It is used to identify the node that we want to retrieve.
9801
+ * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
9802
+ * type of iteration to use when searching for a node in the binary tree. It can have two possible
9803
+ * values:
9804
+ * @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is
9805
+ * found in the binary tree. If no node is found, it returns `undefined`.
9806
+ */
9807
+ getNodeByKey(key, iterationType = "ITERATIVE") {
9808
+ return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType);
9809
+ }
9825
9810
  /**
9826
9811
  * Time complexity: O(n)
9827
9812
  * Space complexity: O(n)
@@ -9897,38 +9882,6 @@ var dataStructureTyped = (() => {
9897
9882
  listLevels(callback = this._DEFAULT_CALLBACK, beginRoot = this.root, iterationType = this.iterationType) {
9898
9883
  return super.listLevels(callback, beginRoot, iterationType, false);
9899
9884
  }
9900
- /**
9901
- * Time Complexity: O(log n)
9902
- * Space Complexity: O(1)
9903
- */
9904
- /**
9905
- * Time Complexity: O(log n)
9906
- * Space Complexity: O(1)
9907
- *
9908
- * The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
9909
- * leftmost node if the comparison result is greater than.
9910
- * @param {K | NODE | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
9911
- * type `K`, `NODE`, or `undefined`. It represents the starting point for finding the last key in
9912
- * the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
9913
- * @returns the key of the rightmost node in the binary tree if the comparison result is less than,
9914
- * the key of the leftmost node if the comparison result is greater than, and the key of the
9915
- * rightmost node otherwise. If no node is found, it returns 0.
9916
- */
9917
- lastKey(beginRoot = this.root) {
9918
- let current = this.ensureNode(beginRoot);
9919
- if (!current)
9920
- return void 0;
9921
- if (this._variant === "STANDARD") {
9922
- while (current.right !== void 0) {
9923
- current = current.right;
9924
- }
9925
- } else {
9926
- while (current.left !== void 0) {
9927
- current = current.left;
9928
- }
9929
- }
9930
- return current.key;
9931
- }
9932
9885
  /**
9933
9886
  * Time Complexity: O(log n)
9934
9887
  * Space Complexity: O(log n)
@@ -9954,18 +9907,18 @@ var dataStructureTyped = (() => {
9954
9907
  * @returns The function `lesserOrGreaterTraverse` returns an array of values of type
9955
9908
  * `ReturnType<C>`, which is the return type of the callback function passed as an argument.
9956
9909
  */
9957
- lesserOrGreaterTraverse(callback = this._DEFAULT_CALLBACK, lesserOrGreater = "LT", targetNode = this.root, iterationType = this.iterationType) {
9958
- targetNode = this.ensureNode(targetNode);
9910
+ lesserOrGreaterTraverse(callback = this._DEFAULT_CALLBACK, lesserOrGreater = -1, targetNode = this.root, iterationType = this.iterationType) {
9911
+ const targetNodeEnsured = this.ensureNode(targetNode);
9959
9912
  const ans = [];
9960
- if (!targetNode)
9913
+ if (!targetNodeEnsured)
9961
9914
  return ans;
9962
9915
  if (!this.root)
9963
9916
  return ans;
9964
- const targetKey = targetNode.key;
9917
+ const targetKey = targetNodeEnsured.key;
9965
9918
  if (iterationType === "RECURSIVE") {
9966
9919
  const dfs = (cur) => {
9967
- const compared = this._compare(cur.key, targetKey);
9968
- if (compared === lesserOrGreater)
9920
+ const compared = this.comparator(cur.key, targetKey);
9921
+ if (Math.sign(compared) === lesserOrGreater)
9969
9922
  ans.push(callback(cur));
9970
9923
  if (this.isRealNode(cur.left))
9971
9924
  dfs(cur.left);
@@ -9979,8 +9932,8 @@ var dataStructureTyped = (() => {
9979
9932
  while (queue.size > 0) {
9980
9933
  const cur = queue.shift();
9981
9934
  if (this.isRealNode(cur)) {
9982
- const compared = this._compare(cur.key, targetKey);
9983
- if (compared === lesserOrGreater)
9935
+ const compared = this.comparator(cur.key, targetKey);
9936
+ if (Math.sign(compared) === lesserOrGreater)
9984
9937
  ans.push(callback(cur));
9985
9938
  if (this.isRealNode(cur.left))
9986
9939
  queue.push(cur.left);
@@ -10117,47 +10070,6 @@ var dataStructureTyped = (() => {
10117
10070
  }
10118
10071
  this._root = v;
10119
10072
  }
10120
- /**
10121
- * The function compares two values using a comparator function and returns whether the first value
10122
- * is greater than, less than, or equal to the second value.
10123
- * @param {K} a - The parameter "a" is of type K.
10124
- * @param {K} b - The parameter "b" in the above code represents a K.
10125
- * @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater
10126
- * than), 'LT' (less than), or 'EQ' (equal).
10127
- */
10128
- _compare(a, b) {
10129
- const extractedA = this.extractor(a);
10130
- const extractedB = this.extractor(b);
10131
- const compared = this.variant === "STANDARD" ? extractedA - extractedB : extractedB - extractedA;
10132
- return compared > 0 ? "GT" : compared < 0 ? "LT" : "EQ";
10133
- }
10134
- /**
10135
- * The function `_lt` compares two values `a` and `b` using an extractor function and returns true if
10136
- * `a` is less than `b` based on the specified variant.
10137
- * @param {K} a - The parameter "a" is of type "K", which means it can be any type. It represents the
10138
- * first value to be compared in the function.
10139
- * @param {K} b - The parameter `b` is of type `K`, which means it can be any type. It is used as one
10140
- * of the arguments for the comparison in the `_lt` function.
10141
- * @returns a boolean value.
10142
- */
10143
- _lt(a, b) {
10144
- const extractedA = this.extractor(a);
10145
- const extractedB = this.extractor(b);
10146
- return this.variant === "STANDARD" ? extractedA < extractedB : extractedA > extractedB;
10147
- }
10148
- /**
10149
- * The function compares two values using a custom extractor function and returns true if the first
10150
- * value is greater than the second value.
10151
- * @param {K} a - The parameter "a" is of type K, which means it can be any type.
10152
- * @param {K} b - The parameter "b" is of type K, which means it can be any type. It is used as one
10153
- * of the arguments for the comparison in the function.
10154
- * @returns a boolean value.
10155
- */
10156
- _gt(a, b) {
10157
- const extractedA = this.extractor(a);
10158
- const extractedB = this.extractor(b);
10159
- return this.variant === "STANDARD" ? extractedA > extractedB : extractedA < extractedB;
10160
- }
10161
10073
  };
10162
10074
 
10163
10075
  // src/data-structures/binary-tree/binary-indexed-tree.ts
@@ -10793,7 +10705,7 @@ var dataStructureTyped = (() => {
10793
10705
  createTree(options) {
10794
10706
  return new _AVLTree([], __spreadValues({
10795
10707
  iterationType: this.iterationType,
10796
- variant: this.variant
10708
+ comparator: this.comparator
10797
10709
  }, options));
10798
10710
  }
10799
10711
  /**
@@ -10849,8 +10761,6 @@ var dataStructureTyped = (() => {
10849
10761
  * @returns The method is returning an array of `BinaryTreeDeleteResult<NODE>`.
10850
10762
  */
10851
10763
  delete(identifier, callback = this._DEFAULT_CALLBACK) {
10852
- if (identifier instanceof AVLTreeNode)
10853
- callback = (node) => node;
10854
10764
  const deletedResults = super.delete(identifier, callback);
10855
10765
  for (const { needBalanced } of deletedResults) {
10856
10766
  if (needBalanced) {
@@ -10870,21 +10780,21 @@ var dataStructureTyped = (() => {
10870
10780
  * if either `srcNode` or `destNode` is undefined.
10871
10781
  */
10872
10782
  _swapProperties(srcNode, destNode) {
10873
- srcNode = this.ensureNode(srcNode);
10874
- destNode = this.ensureNode(destNode);
10875
- if (srcNode && destNode) {
10876
- const { key, value, height } = destNode;
10783
+ const srcNodeEnsured = this.ensureNode(srcNode);
10784
+ const destNodeEnsured = this.ensureNode(destNode);
10785
+ if (srcNodeEnsured && destNodeEnsured) {
10786
+ const { key, value, height } = destNodeEnsured;
10877
10787
  const tempNode = this.createNode(key, value);
10878
10788
  if (tempNode) {
10879
10789
  tempNode.height = height;
10880
- destNode.key = srcNode.key;
10881
- destNode.value = srcNode.value;
10882
- destNode.height = srcNode.height;
10883
- srcNode.key = tempNode.key;
10884
- srcNode.value = tempNode.value;
10885
- srcNode.height = tempNode.height;
10790
+ destNodeEnsured.key = srcNodeEnsured.key;
10791
+ destNodeEnsured.value = srcNodeEnsured.value;
10792
+ destNodeEnsured.height = srcNodeEnsured.height;
10793
+ srcNodeEnsured.key = tempNode.key;
10794
+ srcNodeEnsured.value = tempNode.value;
10795
+ srcNodeEnsured.height = tempNode.height;
10886
10796
  }
10887
- return destNode;
10797
+ return destNodeEnsured;
10888
10798
  }
10889
10799
  return void 0;
10890
10800
  }
@@ -11383,6 +11293,7 @@ var dataStructureTyped = (() => {
11383
11293
  if (identifier === null)
11384
11294
  return [];
11385
11295
  const results = [];
11296
+ callback = this._ensureCallback(identifier, callback);
11386
11297
  const nodeToDelete = this.isRealNode(identifier) ? identifier : this.getNode(identifier, callback);
11387
11298
  if (!nodeToDelete) {
11388
11299
  return results;
@@ -11478,9 +11389,10 @@ var dataStructureTyped = (() => {
11478
11389
  let parent = void 0;
11479
11390
  while (this.isRealNode(current)) {
11480
11391
  parent = current;
11481
- if (node.key < current.key) {
11392
+ const compared = this.comparator(node.key, current.key);
11393
+ if (compared < 0) {
11482
11394
  current = (_a = current.left) != null ? _a : this.NIL;
11483
- } else if (node.key > current.key) {
11395
+ } else if (compared > 0) {
11484
11396
  current = (_b = current.right) != null ? _b : this.NIL;
11485
11397
  } else {
11486
11398
  this._replaceNode(current, node);
@@ -11806,19 +11718,10 @@ var dataStructureTyped = (() => {
11806
11718
  createNode(key, value, count) {
11807
11719
  return new AVLTreeMultiMapNode(key, value, count);
11808
11720
  }
11809
- /**
11810
- * The function creates a new AVLTreeMultiMap object with the specified options and returns it.
11811
- * @param [options] - The `options` parameter is an optional object that contains additional
11812
- * configuration options for creating the `AVLTreeMultiMap` object. It can include properties such as
11813
- * `iterationType` and `variant`, which are used to specify the type of iteration and the variant of
11814
- * the tree, respectively. These properties can be
11815
- * @returns a new instance of the `AVLTreeMultiMap` class, with the provided options merged with the
11816
- * default options. The returned value is casted as `TREE`.
11817
- */
11818
11721
  createTree(options) {
11819
11722
  return new _AVLTreeMultiMap([], __spreadValues({
11820
11723
  iterationType: this.iterationType,
11821
- variant: this.variant
11724
+ comparator: this.comparator
11822
11725
  }, options));
11823
11726
  }
11824
11727
  /**
@@ -11920,6 +11823,7 @@ var dataStructureTyped = (() => {
11920
11823
  const deletedResult = [];
11921
11824
  if (!this.root)
11922
11825
  return deletedResult;
11826
+ callback = this._ensureCallback(identifier, callback);
11923
11827
  const curr = (_a = this.getNode(identifier, callback)) != null ? _a : void 0;
11924
11828
  if (!curr)
11925
11829
  return deletedResult;
@@ -12295,6 +12199,7 @@ var dataStructureTyped = (() => {
12295
12199
  if (identifier === null)
12296
12200
  return [];
12297
12201
  const results = [];
12202
+ callback = this._ensureCallback(identifier, callback);
12298
12203
  const nodeToDelete = this.isRealNode(identifier) ? identifier : this.getNode(identifier, callback);
12299
12204
  if (!nodeToDelete) {
12300
12205
  return results;