data-structure-typed 1.53.9 → 1.54.0

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 (68) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -17
  3. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +1 -20
  4. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  5. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +9 -24
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.js +18 -34
  7. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +40 -37
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.js +68 -53
  10. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/bst.d.ts +36 -50
  12. package/dist/cjs/data-structures/binary-tree/bst.js +45 -60
  13. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +29 -43
  15. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +45 -59
  16. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +33 -45
  18. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +70 -83
  19. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  20. package/dist/cjs/interfaces/binary-tree.d.ts +4 -3
  21. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -2
  22. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -2
  23. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +3 -2
  24. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -2
  25. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +5 -4
  26. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -2
  27. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -17
  28. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +1 -20
  29. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  30. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +9 -24
  31. package/dist/mjs/data-structures/binary-tree/avl-tree.js +18 -35
  32. package/dist/mjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  33. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +40 -37
  34. package/dist/mjs/data-structures/binary-tree/binary-tree.js +68 -53
  35. package/dist/mjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  36. package/dist/mjs/data-structures/binary-tree/bst.d.ts +36 -50
  37. package/dist/mjs/data-structures/binary-tree/bst.js +65 -80
  38. package/dist/mjs/data-structures/binary-tree/bst.js.map +1 -1
  39. package/dist/mjs/data-structures/binary-tree/red-black-tree.d.ts +29 -43
  40. package/dist/mjs/data-structures/binary-tree/red-black-tree.js +44 -59
  41. package/dist/mjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  42. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +33 -45
  43. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +70 -83
  44. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  45. package/dist/mjs/interfaces/binary-tree.d.ts +4 -3
  46. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -2
  47. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -2
  48. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +3 -2
  49. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +3 -2
  50. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +5 -4
  51. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -2
  52. package/dist/umd/data-structure-typed.js +223 -298
  53. package/dist/umd/data-structure-typed.min.js +2 -2
  54. package/dist/umd/data-structure-typed.min.js.map +1 -1
  55. package/package.json +5 -5
  56. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +23 -31
  57. package/src/data-structures/binary-tree/avl-tree.ts +35 -46
  58. package/src/data-structures/binary-tree/binary-tree.ts +105 -66
  59. package/src/data-structures/binary-tree/bst.ts +105 -104
  60. package/src/data-structures/binary-tree/red-black-tree.ts +68 -73
  61. package/src/data-structures/binary-tree/tree-multi-map.ts +98 -102
  62. package/src/interfaces/binary-tree.ts +16 -3
  63. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +4 -2
  64. package/src/types/data-structures/binary-tree/avl-tree.ts +4 -2
  65. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -3
  66. package/src/types/data-structures/binary-tree/bst.ts +4 -2
  67. package/src/types/data-structures/binary-tree/rb-tree.ts +6 -4
  68. package/src/types/data-structures/binary-tree/tree-multi-map.ts +4 -2
@@ -7389,6 +7389,9 @@ var dataStructureTyped = (() => {
7389
7389
  __publicField(this, "parent");
7390
7390
  __publicField(this, "_left");
7391
7391
  __publicField(this, "_right");
7392
+ __publicField(this, "_height", 0);
7393
+ __publicField(this, "_color", "BLACK");
7394
+ __publicField(this, "_count", 1);
7392
7395
  this.key = key;
7393
7396
  this.value = value;
7394
7397
  }
@@ -7410,6 +7413,24 @@ var dataStructureTyped = (() => {
7410
7413
  }
7411
7414
  this._right = v;
7412
7415
  }
7416
+ get height() {
7417
+ return this._height;
7418
+ }
7419
+ set height(value) {
7420
+ this._height = value;
7421
+ }
7422
+ get color() {
7423
+ return this._color;
7424
+ }
7425
+ set color(value) {
7426
+ this._color = value;
7427
+ }
7428
+ get count() {
7429
+ return this._count;
7430
+ }
7431
+ set count(value) {
7432
+ this._count = value;
7433
+ }
7413
7434
  get familyPosition() {
7414
7435
  const that = this;
7415
7436
  if (!this.parent) {
@@ -7486,18 +7507,12 @@ var dataStructureTyped = (() => {
7486
7507
  return new BinaryTreeNode(key, this._isMapMode ? void 0 : value);
7487
7508
  }
7488
7509
  /**
7489
- * Time Complexity: O(1)
7490
- * Space Complexity: O(1)
7491
- *
7492
- * The `createTree` function creates a new binary tree based on the provided options.
7493
- * @param [options] - The `options` parameter in the `createTree` method is of type
7494
- * `BinaryTreeOptions<K, V, R>`. This type likely contains configuration options for creating a
7495
- * binary tree, such as the iteration type, whether the tree is in map mode, and functions for
7496
- * converting entries.
7497
- * @returns The `createTree` method is returning an instance of the `BinaryTree` class with the
7498
- * provided options. The method is creating a new `BinaryTree` object with an empty array as the
7499
- * initial data, and then setting various options such as `iterationType`, `isMapMode`, and
7500
- * `toEntryFn` based on the current object's properties and the provided `options`. Finally, it
7510
+ * The function creates a binary tree with the specified options.
7511
+ * @param [options] - The `options` parameter in the `createTree` function is an optional parameter
7512
+ * that allows you to provide partial configuration options for creating a binary tree. It is of type
7513
+ * `Partial<BinaryTreeOptions<K, V, R>>`, which means you can pass in an object containing a subset
7514
+ * of properties
7515
+ * @returns A new instance of a binary tree with the specified options is being returned.
7501
7516
  */
7502
7517
  createTree(options) {
7503
7518
  return new _BinaryTree([], __spreadValues({
@@ -7506,6 +7521,40 @@ var dataStructureTyped = (() => {
7506
7521
  toEntryFn: this._toEntryFn
7507
7522
  }, options));
7508
7523
  }
7524
+ /**
7525
+ * The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
7526
+ * or returns null.
7527
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
7528
+ * `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeEntryOrRaw`, which
7529
+ * can be of type `BTNRep<K, V, NODE>` or `R`. This parameter represents either a key, a
7530
+ * node, an entry
7531
+ * @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
7532
+ * an optional parameter of type `V`. It represents the value associated with the key in the node
7533
+ * being created. If a `value` is provided, it will be used when creating the node. If
7534
+ * @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
7535
+ * (`OptNodeOrNull<NODE>`) based on the input parameters provided. The function checks the type of the
7536
+ * input parameter (`keyNodeEntryOrRaw`) and processes it accordingly to return a node or null
7537
+ * value.
7538
+ */
7539
+ _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
7540
+ if (keyNodeEntryOrRaw === void 0) return [void 0, void 0];
7541
+ if (keyNodeEntryOrRaw === null) return [null, void 0];
7542
+ if (this.isNode(keyNodeEntryOrRaw)) return [keyNodeEntryOrRaw, value];
7543
+ if (this.isEntry(keyNodeEntryOrRaw)) {
7544
+ const [key, entryValue] = keyNodeEntryOrRaw;
7545
+ if (key === void 0) return [void 0, void 0];
7546
+ else if (key === null) return [null, void 0];
7547
+ const finalValue = value != null ? value : entryValue;
7548
+ return [this.createNode(key, finalValue), finalValue];
7549
+ }
7550
+ if (this.isRaw(keyNodeEntryOrRaw)) {
7551
+ const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
7552
+ const finalValue = value != null ? value : entryValue;
7553
+ if (this.isKey(key)) return [this.createNode(key, finalValue), finalValue];
7554
+ }
7555
+ if (this.isKey(keyNodeEntryOrRaw)) return [this.createNode(keyNodeEntryOrRaw, value), value];
7556
+ return [void 0, void 0];
7557
+ }
7509
7558
  /**
7510
7559
  * Time Complexity: O(n)
7511
7560
  * Space Complexity: O(log n)
@@ -8799,40 +8848,6 @@ var dataStructureTyped = (() => {
8799
8848
  print(options, startNode = this._root) {
8800
8849
  console.log(this.toVisual(startNode, options));
8801
8850
  }
8802
- /**
8803
- * The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
8804
- * or returns null.
8805
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
8806
- * `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeEntryOrRaw`, which
8807
- * can be of type `BTNRep<K, V, NODE>` or `R`. This parameter represents either a key, a
8808
- * node, an entry
8809
- * @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
8810
- * an optional parameter of type `V`. It represents the value associated with the key in the node
8811
- * being created. If a `value` is provided, it will be used when creating the node. If
8812
- * @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
8813
- * (`OptNodeOrNull<NODE>`) based on the input parameters provided. The function checks the type of the
8814
- * input parameter (`keyNodeEntryOrRaw`) and processes it accordingly to return a node or null
8815
- * value.
8816
- */
8817
- _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
8818
- if (keyNodeEntryOrRaw === void 0) return [void 0, void 0];
8819
- if (keyNodeEntryOrRaw === null) return [null, void 0];
8820
- if (this.isNode(keyNodeEntryOrRaw)) return [keyNodeEntryOrRaw, value];
8821
- if (this.isEntry(keyNodeEntryOrRaw)) {
8822
- const [key, entryValue] = keyNodeEntryOrRaw;
8823
- if (key === void 0) return [void 0, void 0];
8824
- else if (key === null) return [null, void 0];
8825
- const finalValue = value != null ? value : entryValue;
8826
- return [this.createNode(key, finalValue), finalValue];
8827
- }
8828
- if (this.isRaw(keyNodeEntryOrRaw)) {
8829
- const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
8830
- const finalValue = value != null ? value : entryValue;
8831
- if (this.isKey(key)) return [this.createNode(key, finalValue), finalValue];
8832
- }
8833
- if (this.isKey(keyNodeEntryOrRaw)) return [this.createNode(keyNodeEntryOrRaw, value), value];
8834
- return [void 0, void 0];
8835
- }
8836
8851
  /**
8837
8852
  * Time complexity: O(n)
8838
8853
  * Space complexity: O(n)
@@ -9340,21 +9355,6 @@ var dataStructureTyped = (() => {
9340
9355
  get isReverse() {
9341
9356
  return this._isReverse;
9342
9357
  }
9343
- /**
9344
- * The function returns the value of the _comparator property.
9345
- * @returns The `_comparator` property is being returned.
9346
- */
9347
- get comparator() {
9348
- return this._comparator;
9349
- }
9350
- /**
9351
- * This function returns the value of the `_specifyComparable` property.
9352
- * @returns The method `specifyComparable()` is being returned, which is a getter method for the
9353
- * `_specifyComparable` property.
9354
- */
9355
- get specifyComparable() {
9356
- return this._specifyComparable;
9357
- }
9358
9358
  /**
9359
9359
  * The function creates a new BSTNode with the given key and value and returns it.
9360
9360
  * @param {K} key - The key parameter is of type K, which represents the type of the key for the node
@@ -9367,17 +9367,12 @@ var dataStructureTyped = (() => {
9367
9367
  return new BSTNode(key, this._isMapMode ? void 0 : value);
9368
9368
  }
9369
9369
  /**
9370
- * Time Complexity: O(1)
9371
- * Space Complexity: O(1)
9372
- *
9373
- * The `createTree` function in TypeScript overrides the default options with the provided options to
9374
- * create a new Binary Search Tree.
9375
- * @param [options] - The `options` parameter in the `createTree` method is an optional object that
9376
- * can contain the following properties:
9377
- * @returns A new instance of a Binary Search Tree (BST) is being returned with the specified options
9378
- * and properties inherited from the current instance.
9370
+ * The function creates a new binary search tree with the specified options.
9371
+ * @param [options] - The `options` parameter is an optional object that allows you to customize the
9372
+ * behavior of the `createTree` method. It accepts a partial `BSTOptions` object, which has the
9373
+ * following properties:
9374
+ * @returns a new instance of the BST class with the provided options.
9379
9375
  */
9380
- // @ts-ignore
9381
9376
  createTree(options) {
9382
9377
  return new _BST([], __spreadValues({
9383
9378
  iterationType: this.iterationType,
@@ -9387,6 +9382,20 @@ var dataStructureTyped = (() => {
9387
9382
  isReverse: this._isReverse
9388
9383
  }, options));
9389
9384
  }
9385
+ /**
9386
+ * The function overrides a method and converts a key, value pair or entry or raw element to a node.
9387
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
9388
+ * type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
9389
+ * element.
9390
+ * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
9391
+ * value associated with a key in a key-value pair.
9392
+ * @returns either a NODE object or undefined.
9393
+ */
9394
+ _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
9395
+ const [node, entryValue] = super._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
9396
+ if (node === null) return [void 0, void 0];
9397
+ return [node, value != null ? value : entryValue];
9398
+ }
9390
9399
  /**
9391
9400
  * Time Complexity: O(log n)
9392
9401
  * Space Complexity: O(log n)
@@ -9460,7 +9469,7 @@ var dataStructureTyped = (() => {
9460
9469
  this._size++;
9461
9470
  return true;
9462
9471
  }
9463
- current = current.left;
9472
+ if (current.left !== null) current = current.left;
9464
9473
  } else {
9465
9474
  if (current.right === void 0) {
9466
9475
  current.right = newNode;
@@ -9468,7 +9477,7 @@ var dataStructureTyped = (() => {
9468
9477
  this._size++;
9469
9478
  return true;
9470
9479
  }
9471
- current = current.right;
9480
+ if (current.right !== null) current = current.right;
9472
9481
  }
9473
9482
  }
9474
9483
  return false;
@@ -9567,18 +9576,6 @@ var dataStructureTyped = (() => {
9567
9576
  }
9568
9577
  return inserted;
9569
9578
  }
9570
- /**
9571
- * Time Complexity: O(n)
9572
- * Space Complexity: O(1)
9573
- *
9574
- * The `merge` function overrides the base class method by adding elements from another
9575
- * binary search tree.
9576
- * @param anotherTree - `anotherTree` is an instance of a Binary Search Tree (BST) with key type `K`,
9577
- * value type `V`, return type `R`, node type `NODE`, and tree type `TREE`.
9578
- */
9579
- merge(anotherTree) {
9580
- this.addMany(anotherTree, [], false);
9581
- }
9582
9579
  /**
9583
9580
  * Time Complexity: O(log n)
9584
9581
  * Space Complexity: O(k + log n)
@@ -9925,7 +9922,7 @@ var dataStructureTyped = (() => {
9925
9922
  while (stack.length > 0 || node) {
9926
9923
  if (node) {
9927
9924
  stack.push(node);
9928
- node = node.left;
9925
+ if (node.left !== null) node = node.left;
9929
9926
  } else {
9930
9927
  node = stack[stack.length - 1];
9931
9928
  if (!node.right || last === node.right) {
@@ -9944,28 +9941,20 @@ var dataStructureTyped = (() => {
9944
9941
  }
9945
9942
  return balanced;
9946
9943
  }
9947
- // @ts-ignore
9948
- map(callback, options, thisArg) {
9949
- const newTree = new _BST([], options);
9950
- let index = 0;
9951
- for (const [key, value] of this) {
9952
- newTree.add(callback.call(thisArg, key, value, index++, this));
9953
- }
9954
- return newTree;
9944
+ /**
9945
+ * The function returns the value of the _comparator property.
9946
+ * @returns The `_comparator` property is being returned.
9947
+ */
9948
+ get comparator() {
9949
+ return this._comparator;
9955
9950
  }
9956
9951
  /**
9957
- * The function overrides a method and converts a key, value pair or entry or raw element to a node.
9958
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
9959
- * type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
9960
- * element.
9961
- * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
9962
- * value associated with a key in a key-value pair.
9963
- * @returns either a NODE object or undefined.
9952
+ * This function returns the value of the `_specifyComparable` property.
9953
+ * @returns The method `specifyComparable()` is being returned, which is a getter method for the
9954
+ * `_specifyComparable` property.
9964
9955
  */
9965
- _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
9966
- const [node, entryValue] = super._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
9967
- if (node === null) return [void 0, void 0];
9968
- return [node, value != null ? value : entryValue];
9956
+ get specifyComparable() {
9957
+ return this._specifyComparable;
9969
9958
  }
9970
9959
  /**
9971
9960
  * The function sets the root of a tree-like structure and updates the parent property of the new
@@ -9981,6 +9970,14 @@ var dataStructureTyped = (() => {
9981
9970
  _compare(a, b) {
9982
9971
  return this._isReverse ? -this._comparator(a, b) : this._comparator(a, b);
9983
9972
  }
9973
+ map(callback, options, thisArg) {
9974
+ const newTree = new _BST([], options);
9975
+ let index = 0;
9976
+ for (const [key, value] of this) {
9977
+ newTree.add(callback.call(thisArg, key, value, index++, this));
9978
+ }
9979
+ return newTree;
9980
+ }
9984
9981
  };
9985
9982
 
9986
9983
  // src/data-structures/binary-tree/binary-indexed-tree.ts
@@ -10558,23 +10555,6 @@ var dataStructureTyped = (() => {
10558
10555
  */
10559
10556
  constructor(key, value) {
10560
10557
  super(key, value);
10561
- __publicField(this, "_height");
10562
- this._height = 0;
10563
- }
10564
- /**
10565
- * The function returns the value of the height property.
10566
- * @returns The height of the object.
10567
- */
10568
- get height() {
10569
- return this._height;
10570
- }
10571
- /**
10572
- * The above function sets the value of the height property.
10573
- * @param {number} value - The value parameter is a number that represents the new height value to be
10574
- * set.
10575
- */
10576
- set height(value) {
10577
- this._height = value;
10578
10558
  }
10579
10559
  };
10580
10560
  var AVLTree = class _AVLTree extends BST {
@@ -10606,16 +10586,12 @@ var dataStructureTyped = (() => {
10606
10586
  return new AVLTreeNode(key, this._isMapMode ? void 0 : value);
10607
10587
  }
10608
10588
  /**
10609
- * The function `createTree` in TypeScript overrides the default AVLTree creation with the provided
10610
- * options.
10611
- * @param [options] - The `options` parameter in the `createTree` function is an object that contains
10612
- * configuration options for creating an AVL tree. These options can include properties such as
10613
- * `iterationType`, `isMapMode`, `specifyComparable`, `toEntryFn`, and `isReverse`. The function
10614
- * creates a
10615
- * @returns An AVLTree object is being returned with the specified options and properties inherited
10616
- * from the current object.
10617
- */
10618
- // @ts-ignore
10589
+ * The function creates a new AVL tree with the specified options and returns it.
10590
+ * @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
10591
+ * passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
10592
+ * being created.
10593
+ * @returns a new AVLTree object.
10594
+ */
10619
10595
  createTree(options) {
10620
10596
  return new _AVLTree([], __spreadValues({
10621
10597
  iterationType: this.iterationType,
@@ -10676,7 +10652,6 @@ var dataStructureTyped = (() => {
10676
10652
  }
10677
10653
  return deletedResults;
10678
10654
  }
10679
- // @ts-ignore
10680
10655
  map(callback, options, thisArg) {
10681
10656
  const newTree = new _AVLTree([], options);
10682
10657
  let index = 0;
@@ -10760,7 +10735,7 @@ var dataStructureTyped = (() => {
10760
10735
  _balanceLL(A) {
10761
10736
  const parentOfA = A.parent;
10762
10737
  const B = A.left;
10763
- A.parent = B;
10738
+ if (B !== null) A.parent = B;
10764
10739
  if (B && B.right) {
10765
10740
  B.right.parent = A;
10766
10741
  }
@@ -10795,11 +10770,11 @@ var dataStructureTyped = (() => {
10795
10770
  if (B) {
10796
10771
  C = B.right;
10797
10772
  }
10798
- if (A) A.parent = C;
10799
- if (B) B.parent = C;
10773
+ if (A && C !== null) A.parent = C;
10774
+ if (B && C !== null) B.parent = C;
10800
10775
  if (C) {
10801
10776
  if (C.left) {
10802
- C.left.parent = B;
10777
+ if (B !== null) C.left.parent = B;
10803
10778
  }
10804
10779
  if (C.right) {
10805
10780
  C.right.parent = A;
@@ -10837,7 +10812,7 @@ var dataStructureTyped = (() => {
10837
10812
  _balanceRR(A) {
10838
10813
  const parentOfA = A.parent;
10839
10814
  const B = A.right;
10840
- A.parent = B;
10815
+ if (B !== null) A.parent = B;
10841
10816
  if (B) {
10842
10817
  if (B.left) {
10843
10818
  B.left.parent = A;
@@ -10876,14 +10851,14 @@ var dataStructureTyped = (() => {
10876
10851
  if (B) {
10877
10852
  C = B.left;
10878
10853
  }
10879
- A.parent = C;
10880
- if (B) B.parent = C;
10854
+ if (C !== null) A.parent = C;
10855
+ if (B && C !== null) B.parent = C;
10881
10856
  if (C) {
10882
10857
  if (C.left) {
10883
10858
  C.left.parent = A;
10884
10859
  }
10885
10860
  if (C.right) {
10886
- C.right.parent = B;
10861
+ if (B !== null) C.right.parent = B;
10887
10862
  }
10888
10863
  C.parent = parentOfA;
10889
10864
  }
@@ -10978,30 +10953,15 @@ var dataStructureTyped = (() => {
10978
10953
  */
10979
10954
  constructor(key, value, color = "BLACK") {
10980
10955
  super(key, value);
10981
- __publicField(this, "_color");
10982
10956
  this._color = color;
10983
10957
  }
10984
- /**
10985
- * The function returns the color value of a variable.
10986
- * @returns The color value stored in the private variable `_color`.
10987
- */
10988
- get color() {
10989
- return this._color;
10990
- }
10991
- /**
10992
- * The function sets the color property to the specified value.
10993
- * @param {RBTNColor} value - The value parameter is of type RBTNColor.
10994
- */
10995
- set color(value) {
10996
- this._color = value;
10997
- }
10998
10958
  };
10999
10959
  var RedBlackTree = class _RedBlackTree extends BST {
11000
10960
  /**
11001
10961
  * This is the constructor function for a Red-Black Tree data structure in TypeScript.
11002
10962
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
11003
10963
  * iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
11004
- * initialize the RedBlackTree with the provided elements.
10964
+ * initialize the RBTree with the provided elements.
11005
10965
  * @param [options] - The `options` parameter is an optional object that can be passed to the
11006
10966
  * constructor. It is of type `RedBlackTreeOptions<K, V, R>`. This object can contain various options for
11007
10967
  * configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
@@ -11040,15 +11000,11 @@ var dataStructureTyped = (() => {
11040
11000
  return new RedBlackTreeNode(key, this._isMapMode ? void 0 : value, color);
11041
11001
  }
11042
11002
  /**
11043
- * The function `createTree` overrides the default implementation to create a Red-Black Tree with
11044
- * specified options in TypeScript.
11045
- * @param [options] - The `options` parameter in the `createTree` method is of type `RedBlackTreeOptions<K,
11046
- * V, R>`, which is a generic type with three type parameters `K`, `V`, and `R`. This parameter
11047
- * allows you to pass additional configuration options when creating a new Red-
11048
- * @returns A new instance of a RedBlackTree with the specified options and properties from the
11049
- * current object is being returned.
11003
+ * The function creates a new Red-Black Tree with the specified options.
11004
+ * @param [options] - The `options` parameter is an optional object that contains additional
11005
+ * configuration options for creating the Red-Black Tree. It has the following properties:
11006
+ * @returns a new instance of a RedBlackTree object.
11050
11007
  */
11051
- // @ts-ignore
11052
11008
  createTree(options) {
11053
11009
  return new _RedBlackTree([], __spreadValues({
11054
11010
  iterationType: this.iterationType,
@@ -11142,8 +11098,10 @@ var dataStructureTyped = (() => {
11142
11098
  let originalColor = nodeToDelete.color;
11143
11099
  let replacementNode;
11144
11100
  if (!this.isRealNode(nodeToDelete.left)) {
11145
- replacementNode = nodeToDelete.right;
11146
- this._transplant(nodeToDelete, nodeToDelete.right);
11101
+ if (nodeToDelete.right !== null) {
11102
+ replacementNode = nodeToDelete.right;
11103
+ this._transplant(nodeToDelete, nodeToDelete.right);
11104
+ }
11147
11105
  } else if (!this.isRealNode(nodeToDelete.right)) {
11148
11106
  replacementNode = nodeToDelete.left;
11149
11107
  this._transplant(nodeToDelete, nodeToDelete.left);
@@ -11151,14 +11109,16 @@ var dataStructureTyped = (() => {
11151
11109
  const successor = this.getLeftMost((node) => node, nodeToDelete.right);
11152
11110
  if (successor) {
11153
11111
  originalColor = successor.color;
11154
- replacementNode = successor.right;
11112
+ if (successor.right !== null) replacementNode = successor.right;
11155
11113
  if (successor.parent === nodeToDelete) {
11156
11114
  if (this.isRealNode(replacementNode)) {
11157
11115
  replacementNode.parent = successor;
11158
11116
  }
11159
11117
  } else {
11160
- this._transplant(successor, successor.right);
11161
- successor.right = nodeToDelete.right;
11118
+ if (successor.right !== null) {
11119
+ this._transplant(successor, successor.right);
11120
+ successor.right = nodeToDelete.right;
11121
+ }
11162
11122
  if (this.isRealNode(successor.right)) {
11163
11123
  successor.right.parent = successor;
11164
11124
  }
@@ -11179,35 +11139,6 @@ var dataStructureTyped = (() => {
11179
11139
  results.push({ deleted: nodeToDelete, needBalanced: void 0 });
11180
11140
  return results;
11181
11141
  }
11182
- /**
11183
- * Time Complexity: O(n)
11184
- * Space Complexity: O(n)
11185
- *
11186
- * The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
11187
- * applying a callback to each entry in the original tree.
11188
- * @param callback - A function that will be called for each entry in the tree, with parameters
11189
- * representing the key, value, index, and the tree itself. It should return an entry for the new
11190
- * tree.
11191
- * @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
11192
- * MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
11193
- * Tree that will be created during the mapping process. These options could include things like
11194
- * custom comparators
11195
- * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
11196
- * the value of `this` when executing the `callback` function. It allows you to set the context
11197
- * (value of `this`) for the callback function. This can be useful when you want to access properties
11198
- * or
11199
- * @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
11200
- * provided callback function.
11201
- */
11202
- // @ts-ignore
11203
- map(callback, options, thisArg) {
11204
- const newTree = new _RedBlackTree([], options);
11205
- let index = 0;
11206
- for (const [key, value] of this) {
11207
- newTree.add(callback.call(thisArg, key, value, index++, this));
11208
- }
11209
- return newTree;
11210
- }
11211
11142
  /**
11212
11143
  * Time Complexity: O(1)
11213
11144
  * Space Complexity: O(1)
@@ -11310,7 +11241,7 @@ var dataStructureTyped = (() => {
11310
11241
  * structure. It can either be a valid node or `undefined`.
11311
11242
  */
11312
11243
  _insertFixup(z) {
11313
- var _a, _b, _c, _d;
11244
+ var _a, _b, _c, _d, _e;
11314
11245
  while (((_a = z == null ? void 0 : z.parent) == null ? void 0 : _a.color) === "RED") {
11315
11246
  if (z.parent === ((_b = z.parent.parent) == null ? void 0 : _b.left)) {
11316
11247
  const y = z.parent.parent.right;
@@ -11331,7 +11262,7 @@ var dataStructureTyped = (() => {
11331
11262
  }
11332
11263
  }
11333
11264
  } else {
11334
- const y = (_d = (_c = z == null ? void 0 : z.parent) == null ? void 0 : _c.parent) == null ? void 0 : _d.left;
11265
+ const y = (_e = (_d = (_c = z == null ? void 0 : z.parent) == null ? void 0 : _c.parent) == null ? void 0 : _d.left) != null ? _e : void 0;
11335
11266
  if ((y == null ? void 0 : y.color) === "RED") {
11336
11267
  z.parent.color = "BLACK";
11337
11268
  y.color = "BLACK";
@@ -11476,6 +11407,34 @@ var dataStructureTyped = (() => {
11476
11407
  x.right = y;
11477
11408
  y.parent = x;
11478
11409
  }
11410
+ /**
11411
+ * Time Complexity: O(n)
11412
+ * Space Complexity: O(n)
11413
+ *
11414
+ * The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
11415
+ * applying a callback to each entry in the original tree.
11416
+ * @param callback - A function that will be called for each entry in the tree, with parameters
11417
+ * representing the key, value, index, and the tree itself. It should return an entry for the new
11418
+ * tree.
11419
+ * @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
11420
+ * MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
11421
+ * Tree that will be created during the mapping process. These options could include things like
11422
+ * custom comparators
11423
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
11424
+ * the value of `this` when executing the `callback` function. It allows you to set the context
11425
+ * (value of `this`) for the callback function. This can be useful when you want to access properties
11426
+ * or
11427
+ * @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
11428
+ * provided callback function.
11429
+ */
11430
+ map(callback, options, thisArg) {
11431
+ const newTree = new _RedBlackTree([], options);
11432
+ let index = 0;
11433
+ for (const [key, value] of this) {
11434
+ newTree.add(callback.call(thisArg, key, value, index++, this));
11435
+ }
11436
+ return newTree;
11437
+ }
11479
11438
  };
11480
11439
 
11481
11440
  // src/data-structures/binary-tree/avl-tree-multi-map.ts
@@ -11492,24 +11451,8 @@ var dataStructureTyped = (() => {
11492
11451
  */
11493
11452
  constructor(key, value, count = 1) {
11494
11453
  super(key, value);
11495
- __publicField(this, "_count", 1);
11496
11454
  this.count = count;
11497
11455
  }
11498
- /**
11499
- * The function returns the value of the protected variable _count.
11500
- * @returns The count property of the object, which is of type number.
11501
- */
11502
- get count() {
11503
- return this._count;
11504
- }
11505
- /**
11506
- * The above function sets the value of the count property.
11507
- * @param {number} value - The value parameter is of type number, which means it can accept any
11508
- * numeric value.
11509
- */
11510
- set count(value) {
11511
- this._count = value;
11512
- }
11513
11456
  };
11514
11457
  var AVLTreeMultiMap = class _AVLTreeMultiMap extends AVLTree {
11515
11458
  /**
@@ -11567,7 +11510,6 @@ var dataStructureTyped = (() => {
11567
11510
  * @returns a new instance of the AVLTreeMultiMap class, with the specified options, as a TREE
11568
11511
  * object.
11569
11512
  */
11570
- // @ts-ignore
11571
11513
  createTree(options) {
11572
11514
  return new _AVLTreeMultiMap([], __spreadValues({
11573
11515
  iterationType: this.iterationType,
@@ -11647,7 +11589,7 @@ var dataStructureTyped = (() => {
11647
11589
  } else {
11648
11590
  if (!curr.left) {
11649
11591
  if (!parent) {
11650
- if (curr.right !== void 0) this._setRoot(curr.right);
11592
+ if (curr.right !== void 0 && curr.right !== null) this._setRoot(curr.right);
11651
11593
  } else {
11652
11594
  const { familyPosition: fp } = curr;
11653
11595
  if (fp === "LEFT" || fp === "ROOT_LEFT") {
@@ -11746,7 +11688,6 @@ var dataStructureTyped = (() => {
11746
11688
  * The function overrides the clone method to create a deep copy of a tree object.
11747
11689
  * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
11748
11690
  */
11749
- // @ts-ignore
11750
11691
  clone() {
11751
11692
  const cloned = this.createTree();
11752
11693
  if (this._isMapMode) this.bfs((node) => cloned.add(node.key, void 0, node.count));
@@ -11772,7 +11713,6 @@ var dataStructureTyped = (() => {
11772
11713
  * `callback` function along with the index and the original tree itself. The transformed entries are
11773
11714
  * then added to the new `AVLTreeMultiMap` instance, which is returned at the end.
11774
11715
  */
11775
- // @ts-ignore
11776
11716
  map(callback, options, thisArg) {
11777
11717
  const newTree = new _AVLTreeMultiMap([], options);
11778
11718
  let index = 0;
@@ -11877,24 +11817,8 @@ var dataStructureTyped = (() => {
11877
11817
  */
11878
11818
  constructor(key, value, count = 1, color = "BLACK") {
11879
11819
  super(key, value, color);
11880
- __publicField(this, "_count", 1);
11881
11820
  this.count = count;
11882
11821
  }
11883
- /**
11884
- * The function returns the value of the private variable _count.
11885
- * @returns The count property of the object, which is of type number.
11886
- */
11887
- get count() {
11888
- return this._count;
11889
- }
11890
- /**
11891
- * The above function sets the value of the count property.
11892
- * @param {number} value - The value parameter is of type number, which means it can accept any
11893
- * numeric value.
11894
- */
11895
- set count(value) {
11896
- this._count = value;
11897
- }
11898
11822
  };
11899
11823
  var TreeMultiMap = class _TreeMultiMap extends RedBlackTree {
11900
11824
  /**
@@ -11956,7 +11880,6 @@ var dataStructureTyped = (() => {
11956
11880
  * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
11957
11881
  * existing `iterationType` property. The returned value is casted as `TREE`.
11958
11882
  */
11959
- // @ts-ignore
11960
11883
  createTree(options) {
11961
11884
  return new _TreeMultiMap([], __spreadValues({
11962
11885
  iterationType: this.iterationType,
@@ -11965,6 +11888,35 @@ var dataStructureTyped = (() => {
11965
11888
  toEntryFn: this._toEntryFn
11966
11889
  }, options));
11967
11890
  }
11891
+ /**
11892
+ * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
11893
+ * node based on the input.
11894
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
11895
+ * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
11896
+ * @param {V} [value] - The `value` parameter is an optional value that represents the value
11897
+ * associated with the key in the node. It is used when creating a new node or updating the value of
11898
+ * an existing node.
11899
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
11900
+ * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
11901
+ * @returns either a NODE object or undefined.
11902
+ */
11903
+ _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
11904
+ if (keyNodeEntryOrRaw === void 0 || keyNodeEntryOrRaw === null) return [void 0, void 0];
11905
+ if (this.isNode(keyNodeEntryOrRaw)) return [keyNodeEntryOrRaw, value];
11906
+ if (this.isEntry(keyNodeEntryOrRaw)) {
11907
+ const [key, entryValue] = keyNodeEntryOrRaw;
11908
+ if (key === void 0 || key === null) return [void 0, void 0];
11909
+ const finalValue = value != null ? value : entryValue;
11910
+ if (this.isKey(key)) return [this.createNode(key, finalValue, "BLACK", count), finalValue];
11911
+ }
11912
+ if (this.isRaw(keyNodeEntryOrRaw)) {
11913
+ const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
11914
+ const finalValue = value != null ? value : entryValue;
11915
+ if (this.isKey(key)) return [this.createNode(key, finalValue, "BLACK", count), finalValue];
11916
+ }
11917
+ if (this.isKey(keyNodeEntryOrRaw)) return [this.createNode(keyNodeEntryOrRaw, value, "BLACK", count), value];
11918
+ return [void 0, void 0];
11919
+ }
11968
11920
  /**
11969
11921
  * The function checks if the input is an instance of the TreeMultiMapNode class.
11970
11922
  * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
@@ -12029,10 +11981,12 @@ var dataStructureTyped = (() => {
12029
11981
  let originalColor = nodeToDelete.color;
12030
11982
  let replacementNode;
12031
11983
  if (!this.isRealNode(nodeToDelete.left)) {
12032
- replacementNode = nodeToDelete.right;
11984
+ if (nodeToDelete.right !== null) replacementNode = nodeToDelete.right;
12033
11985
  if (ignoreCount || nodeToDelete.count <= 1) {
12034
- this._transplant(nodeToDelete, nodeToDelete.right);
12035
- this._count -= nodeToDelete.count;
11986
+ if (nodeToDelete.right !== null) {
11987
+ this._transplant(nodeToDelete, nodeToDelete.right);
11988
+ this._count -= nodeToDelete.count;
11989
+ }
12036
11990
  } else {
12037
11991
  nodeToDelete.count--;
12038
11992
  this._count--;
@@ -12054,15 +12008,17 @@ var dataStructureTyped = (() => {
12054
12008
  const successor = this.getLeftMost((node) => node, nodeToDelete.right);
12055
12009
  if (successor) {
12056
12010
  originalColor = successor.color;
12057
- replacementNode = successor.right;
12011
+ if (successor.right !== null) replacementNode = successor.right;
12058
12012
  if (successor.parent === nodeToDelete) {
12059
12013
  if (this.isRealNode(replacementNode)) {
12060
12014
  replacementNode.parent = successor;
12061
12015
  }
12062
12016
  } else {
12063
12017
  if (ignoreCount || nodeToDelete.count <= 1) {
12064
- this._transplant(successor, successor.right);
12065
- this._count -= nodeToDelete.count;
12018
+ if (successor.right !== null) {
12019
+ this._transplant(successor, successor.right);
12020
+ this._count -= nodeToDelete.count;
12021
+ }
12066
12022
  } else {
12067
12023
  nodeToDelete.count--;
12068
12024
  this._count--;
@@ -12163,66 +12119,12 @@ var dataStructureTyped = (() => {
12163
12119
  * The function overrides the clone method to create a deep copy of a tree object.
12164
12120
  * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
12165
12121
  */
12166
- // @ts-ignore
12167
12122
  clone() {
12168
12123
  const cloned = this.createTree();
12169
12124
  this.bfs((node) => cloned.add(node.key, void 0, node.count));
12170
12125
  if (this._isMapMode) cloned._store = this._store;
12171
12126
  return cloned;
12172
12127
  }
12173
- /**
12174
- * The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
12175
- * modified entries based on a provided callback.
12176
- * @param callback - The `callback` parameter is a function that will be called for each entry in the
12177
- * map. It takes four arguments:
12178
- * @param [options] - The `options` parameter in the `override map` function is of type
12179
- * `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
12180
- * options when creating a new `TreeMultiMap` instance within the `map` function. These options could
12181
- * include things like
12182
- * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
12183
- * the value of `this` when executing the `callback` function. It allows you to set the context
12184
- * (value of `this`) for the callback function when it is called within the `map` function. This
12185
- * @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
12186
- * by the provided callback function.
12187
- */
12188
- // @ts-ignore
12189
- map(callback, options, thisArg) {
12190
- const newTree = new _TreeMultiMap([], options);
12191
- let index = 0;
12192
- for (const [key, value] of this) {
12193
- newTree.add(callback.call(thisArg, key, value, index++, this));
12194
- }
12195
- return newTree;
12196
- }
12197
- /**
12198
- * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
12199
- * node based on the input.
12200
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
12201
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
12202
- * @param {V} [value] - The `value` parameter is an optional value that represents the value
12203
- * associated with the key in the node. It is used when creating a new node or updating the value of
12204
- * an existing node.
12205
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
12206
- * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
12207
- * @returns either a NODE object or undefined.
12208
- */
12209
- _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
12210
- if (keyNodeEntryOrRaw === void 0 || keyNodeEntryOrRaw === null) return [void 0, void 0];
12211
- if (this.isNode(keyNodeEntryOrRaw)) return [keyNodeEntryOrRaw, value];
12212
- if (this.isEntry(keyNodeEntryOrRaw)) {
12213
- const [key, entryValue] = keyNodeEntryOrRaw;
12214
- if (key === void 0 || key === null) return [void 0, void 0];
12215
- const finalValue = value != null ? value : entryValue;
12216
- if (this.isKey(key)) return [this.createNode(key, finalValue, "BLACK", count), finalValue];
12217
- }
12218
- if (this.isRaw(keyNodeEntryOrRaw)) {
12219
- const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
12220
- const finalValue = value != null ? value : entryValue;
12221
- if (this.isKey(key)) return [this.createNode(key, finalValue, "BLACK", count), finalValue];
12222
- }
12223
- if (this.isKey(keyNodeEntryOrRaw)) return [this.createNode(keyNodeEntryOrRaw, value, "BLACK", count), value];
12224
- return [void 0, void 0];
12225
- }
12226
12128
  /**
12227
12129
  * Time Complexity: O(1)
12228
12130
  * Space Complexity: O(1)
@@ -12273,6 +12175,29 @@ var dataStructureTyped = (() => {
12273
12175
  newNode.count = oldNode.count + newNode.count;
12274
12176
  return super._replaceNode(oldNode, newNode);
12275
12177
  }
12178
+ /**
12179
+ * The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
12180
+ * modified entries based on a provided callback.
12181
+ * @param callback - The `callback` parameter is a function that will be called for each entry in the
12182
+ * map. It takes four arguments:
12183
+ * @param [options] - The `options` parameter in the `override map` function is of type
12184
+ * `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
12185
+ * options when creating a new `TreeMultiMap` instance within the `map` function. These options could
12186
+ * include things like
12187
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
12188
+ * the value of `this` when executing the `callback` function. It allows you to set the context
12189
+ * (value of `this`) for the callback function when it is called within the `map` function. This
12190
+ * @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
12191
+ * by the provided callback function.
12192
+ */
12193
+ map(callback, options, thisArg) {
12194
+ const newTree = new _TreeMultiMap([], options);
12195
+ let index = 0;
12196
+ for (const [key, value] of this) {
12197
+ newTree.add(callback.call(thisArg, key, value, index++, this));
12198
+ }
12199
+ return newTree;
12200
+ }
12276
12201
  };
12277
12202
 
12278
12203
  // src/data-structures/priority-queue/priority-queue.ts