data-structure-typed 1.50.7 → 1.50.9

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 (69) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +73 -67
  3. package/benchmark/report.html +1 -37
  4. package/benchmark/report.json +15 -393
  5. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +14 -3
  6. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +17 -6
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.js +33 -34
  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 +22 -3
  12. package/dist/cjs/data-structures/binary-tree/bst.js +78 -39
  13. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +5 -5
  15. package/dist/cjs/data-structures/binary-tree/rb-tree.js +47 -50
  16. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +40 -23
  18. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +44 -28
  19. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  20. package/dist/cjs/data-structures/heap/heap.d.ts +1 -1
  21. package/dist/cjs/data-structures/heap/heap.js +5 -5
  22. package/dist/cjs/types/common.d.ts +6 -29
  23. package/dist/cjs/types/common.js +0 -40
  24. package/dist/cjs/types/common.js.map +1 -1
  25. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -4
  26. package/dist/cjs/types/data-structures/binary-tree/rb-tree.js +0 -6
  27. package/dist/cjs/types/data-structures/binary-tree/rb-tree.js.map +1 -1
  28. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +14 -3
  29. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +17 -6
  30. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +1 -1
  31. package/dist/mjs/data-structures/binary-tree/binary-tree.js +33 -34
  32. package/dist/mjs/data-structures/binary-tree/bst.d.ts +22 -3
  33. package/dist/mjs/data-structures/binary-tree/bst.js +78 -39
  34. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +5 -5
  35. package/dist/mjs/data-structures/binary-tree/rb-tree.js +47 -50
  36. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +40 -23
  37. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +44 -28
  38. package/dist/mjs/data-structures/heap/heap.d.ts +1 -1
  39. package/dist/mjs/data-structures/heap/heap.js +5 -5
  40. package/dist/mjs/types/common.d.ts +6 -29
  41. package/dist/mjs/types/common.js +1 -39
  42. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -4
  43. package/dist/mjs/types/data-structures/binary-tree/rb-tree.js +1 -5
  44. package/dist/umd/data-structure-typed.js +212 -206
  45. package/dist/umd/data-structure-typed.min.js +2 -2
  46. package/dist/umd/data-structure-typed.min.js.map +1 -1
  47. package/package.json +6 -6
  48. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +20 -7
  49. package/src/data-structures/binary-tree/binary-tree.ts +54 -45
  50. package/src/data-structures/binary-tree/bst.ts +86 -42
  51. package/src/data-structures/binary-tree/rb-tree.ts +49 -49
  52. package/src/data-structures/binary-tree/tree-multi-map.ts +48 -29
  53. package/src/data-structures/heap/heap.ts +5 -5
  54. package/src/types/common.ts +6 -30
  55. package/src/types/data-structures/binary-tree/rb-tree.ts +1 -1
  56. package/test/integration/all-in-one.test.ts +4 -4
  57. package/test/integration/avl-tree.test.ts +1 -1
  58. package/test/integration/bst.test.ts +2 -2
  59. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +20 -15
  60. package/test/performance/data-structures/binary-tree/binary-tree.test.ts +1 -1
  61. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +13 -22
  62. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +15 -23
  63. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +8 -8
  64. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +127 -74
  65. package/test/unit/data-structures/binary-tree/bst.test.ts +20 -20
  66. package/test/unit/data-structures/binary-tree/overall.test.ts +7 -7
  67. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +31 -26
  68. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +26 -34
  69. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +3 -3
@@ -110,12 +110,9 @@ var dataStructureTyped = (() => {
110
110
  AbstractVertex: () => AbstractVertex,
111
111
  BST: () => BST,
112
112
  BSTNode: () => BSTNode,
113
- BSTVariant: () => BSTVariant,
114
113
  BinaryIndexedTree: () => BinaryIndexedTree,
115
114
  BinaryTree: () => BinaryTree,
116
115
  BinaryTreeNode: () => BinaryTreeNode,
117
- CP: () => CP,
118
- CRUD: () => CRUD,
119
116
  Character: () => Character,
120
117
  Deque: () => Deque,
121
118
  DirectedEdge: () => DirectedEdge,
@@ -123,14 +120,12 @@ var dataStructureTyped = (() => {
123
120
  DirectedVertex: () => DirectedVertex,
124
121
  DoublyLinkedList: () => DoublyLinkedList,
125
122
  DoublyLinkedListNode: () => DoublyLinkedListNode,
126
- FamilyPosition: () => FamilyPosition,
127
123
  FibonacciHeap: () => FibonacciHeap,
128
124
  FibonacciHeapNode: () => FibonacciHeapNode,
129
125
  HashMap: () => HashMap,
130
126
  Heap: () => Heap,
131
127
  IterableElementBase: () => IterableElementBase,
132
128
  IterableEntryBase: () => IterableEntryBase,
133
- IterationType: () => IterationType,
134
129
  LinkedHashMap: () => LinkedHashMap,
135
130
  LinkedListQueue: () => LinkedListQueue,
136
131
  MapEdge: () => MapEdge,
@@ -144,7 +139,6 @@ var dataStructureTyped = (() => {
144
139
  Navigator: () => Navigator,
145
140
  PriorityQueue: () => PriorityQueue,
146
141
  Queue: () => Queue,
147
- RBTNColor: () => RBTNColor,
148
142
  RedBlackTree: () => RedBlackTree,
149
143
  RedBlackTreeNode: () => RedBlackTreeNode,
150
144
  SegmentTree: () => SegmentTree,
@@ -4836,23 +4830,23 @@ var dataStructureTyped = (() => {
4836
4830
  * Space Complexity: O(log n)
4837
4831
  *
4838
4832
  * Depth-first search (DFS) method, different traversal orders can be selected。
4839
- * @param order - Traverse order parameter: 'in' (in-order), 'pre' (pre-order) or 'post' (post-order).
4833
+ * @param order - Traverse order parameter: 'IN' (in-order), 'PRE' (pre-order) or 'POST' (post-order).
4840
4834
  * @returns An array containing elements traversed in the specified order.
4841
4835
  */
4842
- dfs(order = "pre") {
4836
+ dfs(order = "PRE") {
4843
4837
  const result = [];
4844
4838
  const _dfs = (index) => {
4845
4839
  const left = 2 * index + 1, right = left + 1;
4846
4840
  if (index < this.size) {
4847
- if (order === "in") {
4841
+ if (order === "IN") {
4848
4842
  _dfs(left);
4849
4843
  result.push(this.elements[index]);
4850
4844
  _dfs(right);
4851
- } else if (order === "pre") {
4845
+ } else if (order === "PRE") {
4852
4846
  result.push(this.elements[index]);
4853
4847
  _dfs(left);
4854
4848
  _dfs(right);
4855
- } else if (order === "post") {
4849
+ } else if (order === "POST") {
4856
4850
  _dfs(left);
4857
4851
  _dfs(right);
4858
4852
  result.push(this.elements[index]);
@@ -7656,48 +7650,6 @@ var dataStructureTyped = (() => {
7656
7650
  }
7657
7651
  };
7658
7652
 
7659
- // src/types/data-structures/binary-tree/rb-tree.ts
7660
- var RBTNColor = /* @__PURE__ */ ((RBTNColor2) => {
7661
- RBTNColor2[RBTNColor2["RED"] = 1] = "RED";
7662
- RBTNColor2[RBTNColor2["BLACK"] = 0] = "BLACK";
7663
- return RBTNColor2;
7664
- })(RBTNColor || {});
7665
-
7666
- // src/types/common.ts
7667
- var BSTVariant = /* @__PURE__ */ ((BSTVariant2) => {
7668
- BSTVariant2["STANDARD"] = "STANDARD";
7669
- BSTVariant2["INVERSE"] = "INVERSE";
7670
- return BSTVariant2;
7671
- })(BSTVariant || {});
7672
- var CP = /* @__PURE__ */ ((CP2) => {
7673
- CP2["lt"] = "lt";
7674
- CP2["eq"] = "eq";
7675
- CP2["gt"] = "gt";
7676
- return CP2;
7677
- })(CP || {});
7678
- var IterationType = /* @__PURE__ */ ((IterationType2) => {
7679
- IterationType2["ITERATIVE"] = "ITERATIVE";
7680
- IterationType2["RECURSIVE"] = "RECURSIVE";
7681
- return IterationType2;
7682
- })(IterationType || {});
7683
- var FamilyPosition = /* @__PURE__ */ ((FamilyPosition2) => {
7684
- FamilyPosition2["ROOT"] = "ROOT";
7685
- FamilyPosition2["LEFT"] = "LEFT";
7686
- FamilyPosition2["RIGHT"] = "RIGHT";
7687
- FamilyPosition2["ROOT_LEFT"] = "ROOT_LEFT";
7688
- FamilyPosition2["ROOT_RIGHT"] = "ROOT_RIGHT";
7689
- FamilyPosition2["ISOLATED"] = "ISOLATED";
7690
- FamilyPosition2["MAL_NODE"] = "MAL_NODE";
7691
- return FamilyPosition2;
7692
- })(FamilyPosition || {});
7693
- var CRUD = /* @__PURE__ */ ((CRUD2) => {
7694
- CRUD2["CREATED"] = "CREATED";
7695
- CRUD2["READ"] = "READ";
7696
- CRUD2["UPDATED"] = "UPDATED";
7697
- CRUD2["DELETED"] = "DELETED";
7698
- return CRUD2;
7699
- })(CRUD || {});
7700
-
7701
7653
  // src/data-structures/binary-tree/binary-tree.ts
7702
7654
  var BinaryTreeNode = class {
7703
7655
  /**
@@ -7762,14 +7714,14 @@ var dataStructureTyped = (() => {
7762
7714
  get familyPosition() {
7763
7715
  const that = this;
7764
7716
  if (!this.parent) {
7765
- return this.left || this.right ? "ROOT" /* ROOT */ : "ISOLATED" /* ISOLATED */;
7717
+ return this.left || this.right ? "ROOT" : "ISOLATED";
7766
7718
  }
7767
7719
  if (this.parent.left === that) {
7768
- return this.left || this.right ? "ROOT_LEFT" /* ROOT_LEFT */ : "LEFT" /* LEFT */;
7720
+ return this.left || this.right ? "ROOT_LEFT" : "LEFT";
7769
7721
  } else if (this.parent.right === that) {
7770
- return this.left || this.right ? "ROOT_RIGHT" /* ROOT_RIGHT */ : "RIGHT" /* RIGHT */;
7722
+ return this.left || this.right ? "ROOT_RIGHT" : "RIGHT";
7771
7723
  }
7772
- return "MAL_NODE" /* MAL_NODE */;
7724
+ return "MAL_NODE";
7773
7725
  }
7774
7726
  };
7775
7727
  var BinaryTree = class _BinaryTree extends IterableEntryBase {
@@ -7784,8 +7736,8 @@ var dataStructureTyped = (() => {
7784
7736
  */
7785
7737
  constructor(keysOrNodesOrEntries = [], options) {
7786
7738
  super();
7787
- __publicField(this, "iterationType", "ITERATIVE" /* ITERATIVE */);
7788
- __publicField(this, "_extractor", (key) => Number(key));
7739
+ __publicField(this, "iterationType", "ITERATIVE");
7740
+ __publicField(this, "_extractor", (key) => typeof key === "number" ? key : Number(key));
7789
7741
  __publicField(this, "_root");
7790
7742
  __publicField(this, "_size");
7791
7743
  __publicField(this, "_defaultOneParamCallback", (node) => node ? node.key : void 0);
@@ -7887,11 +7839,11 @@ var dataStructureTyped = (() => {
7887
7839
  * `null`, or `undefined`. It represents a key used to identify a node in a binary tree.
7888
7840
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
7889
7841
  * type of iteration to be used when searching for a node by key. It has a default value of
7890
- * `IterationType.ITERATIVE`.
7842
+ * `'ITERATIVE'`.
7891
7843
  * @returns either the node corresponding to the given key if it is a valid node key, or the key
7892
7844
  * itself if it is not a valid node key.
7893
7845
  */
7894
- ensureNode(keyOrNodeOrEntry, iterationType = "ITERATIVE" /* ITERATIVE */) {
7846
+ ensureNode(keyOrNodeOrEntry, iterationType = "ITERATIVE") {
7895
7847
  let res;
7896
7848
  if (this.isRealNode(keyOrNodeOrEntry)) {
7897
7849
  res = keyOrNodeOrEntry;
@@ -8107,9 +8059,9 @@ var dataStructureTyped = (() => {
8107
8059
  }
8108
8060
  } else if (parent) {
8109
8061
  const { familyPosition: fp } = curr;
8110
- if (fp === "LEFT" /* LEFT */ || fp === "ROOT_LEFT" /* ROOT_LEFT */) {
8062
+ if (fp === "LEFT" || fp === "ROOT_LEFT") {
8111
8063
  parent.left = curr.right;
8112
- } else if (fp === "RIGHT" /* RIGHT */ || fp === "ROOT_RIGHT" /* ROOT_RIGHT */) {
8064
+ } else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
8113
8065
  parent.right = curr.right;
8114
8066
  }
8115
8067
  needBalanced = parent;
@@ -8157,7 +8109,7 @@ var dataStructureTyped = (() => {
8157
8109
  if (!beginRoot)
8158
8110
  return [];
8159
8111
  const ans = [];
8160
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8112
+ if (iterationType === "RECURSIVE") {
8161
8113
  const _traverse = (cur) => {
8162
8114
  if (callback(cur) === identifier) {
8163
8115
  ans.push(cur);
@@ -8236,10 +8188,10 @@ var dataStructureTyped = (() => {
8236
8188
  * @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is
8237
8189
  * found in the binary tree. If no node is found, it returns `undefined`.
8238
8190
  */
8239
- getNodeByKey(key, iterationType = "ITERATIVE" /* ITERATIVE */) {
8191
+ getNodeByKey(key, iterationType = "ITERATIVE") {
8240
8192
  if (!this.root)
8241
8193
  return void 0;
8242
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8194
+ if (iterationType === "RECURSIVE") {
8243
8195
  const _dfs = (cur) => {
8244
8196
  if (cur.key === key)
8245
8197
  return cur;
@@ -8392,7 +8344,7 @@ var dataStructureTyped = (() => {
8392
8344
  beginRoot = this.ensureNode(beginRoot);
8393
8345
  if (!beginRoot)
8394
8346
  return true;
8395
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8347
+ if (iterationType === "RECURSIVE") {
8396
8348
  const dfs = (cur, min, max) => {
8397
8349
  if (!this.isRealNode(cur))
8398
8350
  return true;
@@ -8479,7 +8431,7 @@ var dataStructureTyped = (() => {
8479
8431
  beginRoot = this.ensureNode(beginRoot);
8480
8432
  if (!this.isRealNode(beginRoot))
8481
8433
  return -1;
8482
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8434
+ if (iterationType === "RECURSIVE") {
8483
8435
  const _getMaxHeight = (cur) => {
8484
8436
  if (!this.isRealNode(cur))
8485
8437
  return -1;
@@ -8524,7 +8476,7 @@ var dataStructureTyped = (() => {
8524
8476
  beginRoot = this.ensureNode(beginRoot);
8525
8477
  if (!beginRoot)
8526
8478
  return -1;
8527
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8479
+ if (iterationType === "RECURSIVE") {
8528
8480
  const _getMinHeight = (cur) => {
8529
8481
  if (!this.isRealNode(cur))
8530
8482
  return 0;
@@ -8616,7 +8568,7 @@ var dataStructureTyped = (() => {
8616
8568
  beginRoot = this.ensureNode(beginRoot);
8617
8569
  if (!this.isRealNode(beginRoot))
8618
8570
  return beginRoot;
8619
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8571
+ if (iterationType === "RECURSIVE") {
8620
8572
  const _traverse = (cur) => {
8621
8573
  if (!this.isRealNode(cur.left))
8622
8574
  return cur;
@@ -8657,7 +8609,7 @@ var dataStructureTyped = (() => {
8657
8609
  beginRoot = this.ensureNode(beginRoot);
8658
8610
  if (!beginRoot)
8659
8611
  return beginRoot;
8660
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8612
+ if (iterationType === "RECURSIVE") {
8661
8613
  const _traverse = (cur) => {
8662
8614
  if (!this.isRealNode(cur.right))
8663
8615
  return cur;
@@ -8754,15 +8706,15 @@ var dataStructureTyped = (() => {
8754
8706
  * `false`, null or undefined
8755
8707
  * @returns an array of values that are the return values of the callback function.
8756
8708
  */
8757
- dfs(callback = this._defaultOneParamCallback, pattern = "in", beginRoot = this.root, iterationType = "ITERATIVE" /* ITERATIVE */, includeNull = false) {
8709
+ dfs(callback = this._defaultOneParamCallback, pattern = "IN", beginRoot = this.root, iterationType = "ITERATIVE", includeNull = false) {
8758
8710
  beginRoot = this.ensureNode(beginRoot);
8759
8711
  if (!beginRoot)
8760
8712
  return [];
8761
8713
  const ans = [];
8762
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8714
+ if (iterationType === "RECURSIVE") {
8763
8715
  const _traverse = (node) => {
8764
8716
  switch (pattern) {
8765
- case "in":
8717
+ case "IN":
8766
8718
  if (includeNull) {
8767
8719
  if (this.isRealNode(node) && this.isNodeOrNull(node.left))
8768
8720
  _traverse(node.left);
@@ -8777,7 +8729,7 @@ var dataStructureTyped = (() => {
8777
8729
  _traverse(node.right);
8778
8730
  }
8779
8731
  break;
8780
- case "pre":
8732
+ case "PRE":
8781
8733
  if (includeNull) {
8782
8734
  this.isNodeOrNull(node) && ans.push(callback(node));
8783
8735
  if (this.isRealNode(node) && this.isNodeOrNull(node.left))
@@ -8792,7 +8744,7 @@ var dataStructureTyped = (() => {
8792
8744
  _traverse(node.right);
8793
8745
  }
8794
8746
  break;
8795
- case "post":
8747
+ case "POST":
8796
8748
  if (includeNull) {
8797
8749
  if (this.isRealNode(node) && this.isNodeOrNull(node.left))
8798
8750
  _traverse(node.left);
@@ -8827,17 +8779,17 @@ var dataStructureTyped = (() => {
8827
8779
  ans.push(callback(cur.node));
8828
8780
  } else {
8829
8781
  switch (pattern) {
8830
- case "in":
8782
+ case "IN":
8831
8783
  cur.node && stack.push({ opt: 0, node: cur.node.right });
8832
8784
  stack.push({ opt: 1, node: cur.node });
8833
8785
  cur.node && stack.push({ opt: 0, node: cur.node.left });
8834
8786
  break;
8835
- case "pre":
8787
+ case "PRE":
8836
8788
  cur.node && stack.push({ opt: 0, node: cur.node.right });
8837
8789
  cur.node && stack.push({ opt: 0, node: cur.node.left });
8838
8790
  stack.push({ opt: 1, node: cur.node });
8839
8791
  break;
8840
- case "post":
8792
+ case "POST":
8841
8793
  stack.push({ opt: 1, node: cur.node });
8842
8794
  cur.node && stack.push({ opt: 0, node: cur.node.right });
8843
8795
  cur.node && stack.push({ opt: 0, node: cur.node.left });
@@ -8883,7 +8835,7 @@ var dataStructureTyped = (() => {
8883
8835
  if (!beginRoot)
8884
8836
  return [];
8885
8837
  const ans = [];
8886
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8838
+ if (iterationType === "RECURSIVE") {
8887
8839
  const queue = new Queue([beginRoot]);
8888
8840
  const traverse = (level) => {
8889
8841
  if (queue.size === 0)
@@ -8957,7 +8909,7 @@ var dataStructureTyped = (() => {
8957
8909
  const levelsNodes = [];
8958
8910
  if (!beginRoot)
8959
8911
  return levelsNodes;
8960
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
8912
+ if (iterationType === "RECURSIVE") {
8961
8913
  const _recursive = (node, level) => {
8962
8914
  if (!levelsNodes[level])
8963
8915
  levelsNodes[level] = [];
@@ -9021,7 +8973,7 @@ var dataStructureTyped = (() => {
9021
8973
  * `callback` function on each node in the binary tree. The type of the array nodes is determined
9022
8974
  * by the return type of the `callback` function.
9023
8975
  */
9024
- morris(callback = this._defaultOneParamCallback, pattern = "in", beginRoot = this.root) {
8976
+ morris(callback = this._defaultOneParamCallback, pattern = "IN", beginRoot = this.root) {
9025
8977
  beginRoot = this.ensureNode(beginRoot);
9026
8978
  if (beginRoot === null)
9027
8979
  return [];
@@ -9048,7 +9000,7 @@ var dataStructureTyped = (() => {
9048
9000
  _reverseEdge(tail);
9049
9001
  };
9050
9002
  switch (pattern) {
9051
- case "in":
9003
+ case "IN":
9052
9004
  while (cur) {
9053
9005
  if (cur.left) {
9054
9006
  const predecessor = this.getPredecessor(cur);
@@ -9064,7 +9016,7 @@ var dataStructureTyped = (() => {
9064
9016
  cur = cur.right;
9065
9017
  }
9066
9018
  break;
9067
- case "pre":
9019
+ case "PRE":
9068
9020
  while (cur) {
9069
9021
  if (cur.left) {
9070
9022
  const predecessor = this.getPredecessor(cur);
@@ -9082,7 +9034,7 @@ var dataStructureTyped = (() => {
9082
9034
  cur = cur.right;
9083
9035
  }
9084
9036
  break;
9085
- case "post":
9037
+ case "POST":
9086
9038
  while (cur) {
9087
9039
  if (cur.left) {
9088
9040
  const predecessor = this.getPredecessor(cur);
@@ -9242,7 +9194,7 @@ var dataStructureTyped = (() => {
9242
9194
  *_getIterator(node = this.root) {
9243
9195
  if (!node)
9244
9196
  return;
9245
- if (this.iterationType === "ITERATIVE" /* ITERATIVE */) {
9197
+ if (this.iterationType === "ITERATIVE") {
9246
9198
  const stack = [];
9247
9199
  let current = node;
9248
9200
  while (current || stack.length > 0) {
@@ -9441,7 +9393,7 @@ var dataStructureTyped = (() => {
9441
9393
  constructor(keysOrNodesOrEntries = [], options) {
9442
9394
  super([], options);
9443
9395
  __publicField(this, "_root");
9444
- __publicField(this, "_variant", "STANDARD" /* STANDARD */);
9396
+ __publicField(this, "_variant", "STANDARD");
9445
9397
  if (options) {
9446
9398
  const { variant } = options;
9447
9399
  if (variant)
@@ -9531,10 +9483,10 @@ var dataStructureTyped = (() => {
9531
9483
  * @param {K | NODE | undefined} keyOrNodeOrEntry - The `key` parameter can be of type `K`, `NODE`, or
9532
9484
  * `undefined`.
9533
9485
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
9534
- * type of iteration to be performed. It has a default value of `IterationType.ITERATIVE`.
9486
+ * type of iteration to be performed. It has a default value of `'ITERATIVE'`.
9535
9487
  * @returns either a node object (NODE) or undefined.
9536
9488
  */
9537
- ensureNode(keyOrNodeOrEntry, iterationType = "ITERATIVE" /* ITERATIVE */) {
9489
+ ensureNode(keyOrNodeOrEntry, iterationType = "ITERATIVE") {
9538
9490
  let res;
9539
9491
  if (this.isRealNode(keyOrNodeOrEntry)) {
9540
9492
  res = keyOrNodeOrEntry;
@@ -9582,10 +9534,10 @@ var dataStructureTyped = (() => {
9582
9534
  }
9583
9535
  let current = this.root;
9584
9536
  while (current !== void 0) {
9585
- if (this._compare(current.key, newNode.key) === "eq" /* eq */) {
9537
+ if (this._compare(current.key, newNode.key) === "EQ") {
9586
9538
  this._replaceNode(current, newNode);
9587
9539
  return true;
9588
- } else if (this._compare(current.key, newNode.key) === "gt" /* gt */) {
9540
+ } else if (this._compare(current.key, newNode.key) === "GT") {
9589
9541
  if (current.left === void 0) {
9590
9542
  current.left = newNode;
9591
9543
  this._size++;
@@ -9693,7 +9645,7 @@ var dataStructureTyped = (() => {
9693
9645
  }
9694
9646
  }
9695
9647
  };
9696
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
9648
+ if (iterationType === "RECURSIVE") {
9697
9649
  _dfs(sorted);
9698
9650
  } else {
9699
9651
  _iterate();
@@ -9718,18 +9670,18 @@ var dataStructureTyped = (() => {
9718
9670
  * @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is
9719
9671
  * found in the binary tree. If no node is found, it returns `undefined`.
9720
9672
  */
9721
- getNodeByKey(key, iterationType = "ITERATIVE" /* ITERATIVE */) {
9673
+ getNodeByKey(key, iterationType = "ITERATIVE") {
9722
9674
  if (!this.isRealNode(this.root))
9723
9675
  return void 0;
9724
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
9676
+ if (iterationType === "RECURSIVE") {
9725
9677
  const _dfs = (cur) => {
9726
9678
  if (cur.key === key)
9727
9679
  return cur;
9728
9680
  if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right))
9729
9681
  return;
9730
- if (this._compare(cur.key, key) === "gt" /* gt */ && this.isRealNode(cur.left))
9682
+ if (this._compare(cur.key, key) === "GT" && this.isRealNode(cur.left))
9731
9683
  return _dfs(cur.left);
9732
- if (this._compare(cur.key, key) === "lt" /* lt */ && this.isRealNode(cur.right))
9684
+ if (this._compare(cur.key, key) === "LT" && this.isRealNode(cur.right))
9733
9685
  return _dfs(cur.right);
9734
9686
  };
9735
9687
  return _dfs(this.root);
@@ -9738,11 +9690,11 @@ var dataStructureTyped = (() => {
9738
9690
  while (queue.size > 0) {
9739
9691
  const cur = queue.shift();
9740
9692
  if (this.isRealNode(cur)) {
9741
- if (this._compare(cur.key, key) === "eq" /* eq */)
9693
+ if (this._compare(cur.key, key) === "EQ")
9742
9694
  return cur;
9743
- if (this._compare(cur.key, key) === "gt" /* gt */)
9695
+ if (this._compare(cur.key, key) === "GT")
9744
9696
  this.isRealNode(cur.left) && queue.push(cur.left);
9745
- if (this._compare(cur.key, key) === "lt" /* lt */)
9697
+ if (this._compare(cur.key, key) === "LT")
9746
9698
  this.isRealNode(cur.right) && queue.push(cur.right);
9747
9699
  }
9748
9700
  }
@@ -9781,7 +9733,7 @@ var dataStructureTyped = (() => {
9781
9733
  if (!beginRoot)
9782
9734
  return [];
9783
9735
  const ans = [];
9784
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
9736
+ if (iterationType === "RECURSIVE") {
9785
9737
  const _traverse = (cur) => {
9786
9738
  const callbackResult = callback(cur);
9787
9739
  if (callbackResult === identifier) {
@@ -9792,10 +9744,10 @@ var dataStructureTyped = (() => {
9792
9744
  if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right))
9793
9745
  return;
9794
9746
  if (callback === this._defaultOneParamCallback) {
9795
- if (this._compare(cur.key, identifier) === "gt" /* gt */)
9796
- this.isRealNode(cur.left) && _traverse(cur.left);
9797
- if (this._compare(cur.key, identifier) === "lt" /* lt */)
9798
- this.isRealNode(cur.right) && _traverse(cur.right);
9747
+ if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === "GT")
9748
+ _traverse(cur.left);
9749
+ if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === "LT")
9750
+ _traverse(cur.right);
9799
9751
  } else {
9800
9752
  this.isRealNode(cur.left) && _traverse(cur.left);
9801
9753
  this.isRealNode(cur.right) && _traverse(cur.right);
@@ -9803,9 +9755,9 @@ var dataStructureTyped = (() => {
9803
9755
  };
9804
9756
  _traverse(beginRoot);
9805
9757
  } else {
9806
- const queue = new Queue([beginRoot]);
9807
- while (queue.size > 0) {
9808
- const cur = queue.shift();
9758
+ const stack = [beginRoot];
9759
+ while (stack.length > 0) {
9760
+ const cur = stack.pop();
9809
9761
  if (this.isRealNode(cur)) {
9810
9762
  const callbackResult = callback(cur);
9811
9763
  if (callbackResult === identifier) {
@@ -9814,13 +9766,13 @@ var dataStructureTyped = (() => {
9814
9766
  return ans;
9815
9767
  }
9816
9768
  if (callback === this._defaultOneParamCallback) {
9817
- if (this._compare(cur.key, identifier) === "gt" /* gt */)
9818
- this.isRealNode(cur.left) && queue.push(cur.left);
9819
- if (this._compare(cur.key, identifier) === "lt" /* lt */)
9820
- this.isRealNode(cur.right) && queue.push(cur.right);
9769
+ if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === "LT")
9770
+ stack.push(cur.right);
9771
+ if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === "GT")
9772
+ stack.push(cur.left);
9821
9773
  } else {
9822
- this.isRealNode(cur.left) && queue.push(cur.left);
9823
- this.isRealNode(cur.right) && queue.push(cur.right);
9774
+ this.isRealNode(cur.right) && stack.push(cur.right);
9775
+ this.isRealNode(cur.left) && stack.push(cur.left);
9824
9776
  }
9825
9777
  }
9826
9778
  }
@@ -9850,7 +9802,7 @@ var dataStructureTyped = (() => {
9850
9802
  * following values:
9851
9803
  * @returns The method is returning an array of the return type of the callback function.
9852
9804
  */
9853
- dfs(callback = this._defaultOneParamCallback, pattern = "in", beginRoot = this.root, iterationType = "ITERATIVE" /* ITERATIVE */) {
9805
+ dfs(callback = this._defaultOneParamCallback, pattern = "IN", beginRoot = this.root, iterationType = "ITERATIVE") {
9854
9806
  return super.dfs(callback, pattern, beginRoot, iterationType, false);
9855
9807
  }
9856
9808
  /**
@@ -9923,7 +9875,7 @@ var dataStructureTyped = (() => {
9923
9875
  let current = this.ensureNode(beginRoot);
9924
9876
  if (!current)
9925
9877
  return void 0;
9926
- if (this._variant === "STANDARD" /* STANDARD */) {
9878
+ if (this._variant === "STANDARD") {
9927
9879
  while (current.right !== void 0) {
9928
9880
  current = current.right;
9929
9881
  }
@@ -9959,7 +9911,7 @@ var dataStructureTyped = (() => {
9959
9911
  * @returns The function `lesserOrGreaterTraverse` returns an array of values of type
9960
9912
  * `ReturnType<C>`, which is the return type of the callback function passed as an argument.
9961
9913
  */
9962
- lesserOrGreaterTraverse(callback = this._defaultOneParamCallback, lesserOrGreater = "lt" /* lt */, targetNode = this.root, iterationType = this.iterationType) {
9914
+ lesserOrGreaterTraverse(callback = this._defaultOneParamCallback, lesserOrGreater = "LT", targetNode = this.root, iterationType = this.iterationType) {
9963
9915
  targetNode = this.ensureNode(targetNode);
9964
9916
  const ans = [];
9965
9917
  if (!targetNode)
@@ -9967,7 +9919,7 @@ var dataStructureTyped = (() => {
9967
9919
  if (!this.root)
9968
9920
  return ans;
9969
9921
  const targetKey = targetNode.key;
9970
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
9922
+ if (iterationType === "RECURSIVE") {
9971
9923
  const _traverse = (cur) => {
9972
9924
  const compared = this._compare(cur.key, targetKey);
9973
9925
  if (compared === lesserOrGreater)
@@ -10012,11 +9964,11 @@ var dataStructureTyped = (() => {
10012
9964
  * @returns The function `perfectlyBalance` returns a boolean value.
10013
9965
  */
10014
9966
  perfectlyBalance(iterationType = this.iterationType) {
10015
- const sorted = this.dfs((node) => node, "in"), n = sorted.length;
9967
+ const sorted = this.dfs((node) => node, "IN"), n = sorted.length;
10016
9968
  this.clear();
10017
9969
  if (sorted.length < 1)
10018
9970
  return false;
10019
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
9971
+ if (iterationType === "RECURSIVE") {
10020
9972
  const buildBalanceBST = (l, r) => {
10021
9973
  if (l > r)
10022
9974
  return;
@@ -10073,7 +10025,7 @@ var dataStructureTyped = (() => {
10073
10025
  if (!this.root)
10074
10026
  return true;
10075
10027
  let balanced = true;
10076
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
10028
+ if (iterationType === "RECURSIVE") {
10077
10029
  const _height = (cur) => {
10078
10030
  if (!cur)
10079
10031
  return 0;
@@ -10127,14 +10079,41 @@ var dataStructureTyped = (() => {
10127
10079
  * is greater than, less than, or equal to the second value.
10128
10080
  * @param {K} a - The parameter "a" is of type K.
10129
10081
  * @param {K} b - The parameter "b" in the above code represents a K.
10130
- * @returns a value of type CP (ComparisonResult). The possible return values are CP.gt (greater
10131
- * than), CP.lt (less than), or CP.eq (equal).
10082
+ * @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater
10083
+ * than), 'LT' (less than), or 'EQ' (equal).
10132
10084
  */
10133
10085
  _compare(a, b) {
10134
10086
  const extractedA = this.extractor(a);
10135
10087
  const extractedB = this.extractor(b);
10136
- const compared = this.variant === "STANDARD" /* STANDARD */ ? extractedA - extractedB : extractedB - extractedA;
10137
- return compared > 0 ? "gt" /* gt */ : compared < 0 ? "lt" /* lt */ : "eq" /* eq */;
10088
+ const compared = this.variant === "STANDARD" ? extractedA - extractedB : extractedB - extractedA;
10089
+ return compared > 0 ? "GT" : compared < 0 ? "LT" : "EQ";
10090
+ }
10091
+ /**
10092
+ * The function `_lt` compares two values `a` and `b` using an extractor function and returns true if
10093
+ * `a` is less than `b` based on the specified variant.
10094
+ * @param {K} a - The parameter "a" is of type "K", which means it can be any type. It represents the
10095
+ * first value to be compared in the function.
10096
+ * @param {K} b - The parameter `b` is of type `K`, which means it can be any type. It is used as one
10097
+ * of the arguments for the comparison in the `_lt` function.
10098
+ * @returns a boolean value.
10099
+ */
10100
+ _lt(a, b) {
10101
+ const extractedA = this.extractor(a);
10102
+ const extractedB = this.extractor(b);
10103
+ return this.variant === "STANDARD" ? extractedA < extractedB : extractedA > extractedB;
10104
+ }
10105
+ /**
10106
+ * The function compares two values using a custom extractor function and returns true if the first
10107
+ * value is greater than the second value.
10108
+ * @param {K} a - The parameter "a" is of type K, which means it can be any type.
10109
+ * @param {K} b - The parameter "b" is of type K, which means it can be any type. It is used as one
10110
+ * of the arguments for the comparison in the function.
10111
+ * @returns a boolean value.
10112
+ */
10113
+ _gt(a, b) {
10114
+ const extractedA = this.extractor(a);
10115
+ const extractedB = this.extractor(b);
10116
+ return this.variant === "STANDARD" ? extractedA > extractedB : extractedA < extractedB;
10138
10117
  }
10139
10118
  };
10140
10119
 
@@ -11164,9 +11143,9 @@ var dataStructureTyped = (() => {
11164
11143
  * associated with the key in the Red-Black Tree Node. It is not required and can be omitted when
11165
11144
  * creating a new instance of the Red-Black Tree Node.
11166
11145
  * @param {RBTNColor} color - The `color` parameter is used to specify the color of the Red-Black
11167
- * Tree Node. It is an optional parameter with a default value of `RBTNColor.BLACK`.
11146
+ * Tree Node. It is an optional parameter with a default value of `'BLACK'`.
11168
11147
  */
11169
- constructor(key, value, color = 0 /* BLACK */) {
11148
+ constructor(key, value, color = "BLACK") {
11170
11149
  super(key, value);
11171
11150
  __publicField(this, "_color");
11172
11151
  this._color = color;
@@ -11227,12 +11206,12 @@ var dataStructureTyped = (() => {
11227
11206
  * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
11228
11207
  * associated with the key in the node. It is not required and can be omitted if not needed.
11229
11208
  * @param {RBTNColor} color - The "color" parameter is used to specify the color of the node in a
11230
- * Red-Black Tree. It is an optional parameter with a default value of "RBTNColor.BLACK". The color
11231
- * can be either "RBTNColor.RED" or "RBTNColor.BLACK".
11209
+ * Red-Black Tree. It is an optional parameter with a default value of "'BLACK'". The color
11210
+ * can be either "'RED'" or "'BLACK'".
11232
11211
  * @returns The method is returning a new instance of a RedBlackTreeNode with the specified key,
11233
11212
  * value, and color.
11234
11213
  */
11235
- createNode(key, value, color = 0 /* BLACK */) {
11214
+ createNode(key, value, color = "BLACK") {
11236
11215
  return new RedBlackTreeNode(key, value, color);
11237
11216
  }
11238
11217
  /**
@@ -11272,10 +11251,10 @@ var dataStructureTyped = (() => {
11272
11251
  if (key === void 0 || key === null) {
11273
11252
  return;
11274
11253
  } else {
11275
- node = this.createNode(key, value2, 1 /* RED */);
11254
+ node = this.createNode(key, value2, "RED");
11276
11255
  }
11277
11256
  } else if (!this.isNode(keyOrNodeOrEntry)) {
11278
- node = this.createNode(keyOrNodeOrEntry, value, 1 /* RED */);
11257
+ node = this.createNode(keyOrNodeOrEntry, value, "RED");
11279
11258
  } else {
11280
11259
  return;
11281
11260
  }
@@ -11342,9 +11321,7 @@ var dataStructureTyped = (() => {
11342
11321
  */
11343
11322
  getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
11344
11323
  var _a;
11345
- if (identifier instanceof RedBlackTreeNode)
11346
- callback = (node) => node;
11347
- return (_a = super.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) != null ? _a : void 0;
11324
+ return (_a = this.getNodes(identifier, callback, true, beginRoot, iterationType)[0]) != null ? _a : void 0;
11348
11325
  }
11349
11326
  /**
11350
11327
  * Time Complexity: O(1)
@@ -11383,16 +11360,16 @@ var dataStructureTyped = (() => {
11383
11360
  if (!this.isRealNode(newNode))
11384
11361
  return false;
11385
11362
  const insertStatus = this._insert(newNode);
11386
- if (insertStatus === "CREATED" /* CREATED */) {
11363
+ if (insertStatus === "CREATED") {
11387
11364
  if (this.isRealNode(this._root)) {
11388
- this._root.color = 0 /* BLACK */;
11365
+ this._root.color = "BLACK";
11389
11366
  } else {
11390
11367
  return false;
11391
11368
  }
11392
11369
  this._size++;
11393
11370
  return true;
11394
11371
  } else
11395
- return insertStatus === "UPDATED" /* UPDATED */;
11372
+ return insertStatus === "UPDATED";
11396
11373
  }
11397
11374
  /**
11398
11375
  * Time Complexity: O(log n)
@@ -11455,7 +11432,7 @@ var dataStructureTyped = (() => {
11455
11432
  }
11456
11433
  }
11457
11434
  this._size--;
11458
- if (originalColor === 0 /* BLACK */) {
11435
+ if (originalColor === "BLACK") {
11459
11436
  this._deleteFixup(replacementNode);
11460
11437
  }
11461
11438
  results.push({ deleted: nodeToDelete, needBalanced: void 0 });
@@ -11519,7 +11496,7 @@ var dataStructureTyped = (() => {
11519
11496
  current = (_b = current.right) != null ? _b : this.SENTINEL;
11520
11497
  } else {
11521
11498
  this._replaceNode(current, node);
11522
- return "UPDATED" /* UPDATED */;
11499
+ return "UPDATED";
11523
11500
  }
11524
11501
  }
11525
11502
  node.parent = parent;
@@ -11532,9 +11509,9 @@ var dataStructureTyped = (() => {
11532
11509
  }
11533
11510
  node.left = this.SENTINEL;
11534
11511
  node.right = this.SENTINEL;
11535
- node.color = 1 /* RED */;
11512
+ node.color = "RED";
11536
11513
  this._insertFixup(node);
11537
- return "CREATED" /* CREATED */;
11514
+ return "CREATED";
11538
11515
  }
11539
11516
  /**
11540
11517
  * Time Complexity: O(1)
@@ -11575,13 +11552,13 @@ var dataStructureTyped = (() => {
11575
11552
  */
11576
11553
  _insertFixup(z) {
11577
11554
  var _a, _b, _c, _d;
11578
- while (((_a = z == null ? void 0 : z.parent) == null ? void 0 : _a.color) === 1 /* RED */) {
11555
+ while (((_a = z == null ? void 0 : z.parent) == null ? void 0 : _a.color) === "RED") {
11579
11556
  if (z.parent === ((_b = z.parent.parent) == null ? void 0 : _b.left)) {
11580
11557
  const y = z.parent.parent.right;
11581
- if ((y == null ? void 0 : y.color) === 1 /* RED */) {
11582
- z.parent.color = 0 /* BLACK */;
11583
- y.color = 0 /* BLACK */;
11584
- z.parent.parent.color = 1 /* RED */;
11558
+ if ((y == null ? void 0 : y.color) === "RED") {
11559
+ z.parent.color = "BLACK";
11560
+ y.color = "BLACK";
11561
+ z.parent.parent.color = "RED";
11585
11562
  z = z.parent.parent;
11586
11563
  } else {
11587
11564
  if (z === z.parent.right) {
@@ -11589,17 +11566,17 @@ var dataStructureTyped = (() => {
11589
11566
  this._leftRotate(z);
11590
11567
  }
11591
11568
  if (z && this.isRealNode(z.parent) && this.isRealNode(z.parent.parent)) {
11592
- z.parent.color = 0 /* BLACK */;
11593
- z.parent.parent.color = 1 /* RED */;
11569
+ z.parent.color = "BLACK";
11570
+ z.parent.parent.color = "RED";
11594
11571
  this._rightRotate(z.parent.parent);
11595
11572
  }
11596
11573
  }
11597
11574
  } else {
11598
11575
  const y = (_d = (_c = z == null ? void 0 : z.parent) == null ? void 0 : _c.parent) == null ? void 0 : _d.left;
11599
- if ((y == null ? void 0 : y.color) === 1 /* RED */) {
11600
- z.parent.color = 0 /* BLACK */;
11601
- y.color = 0 /* BLACK */;
11602
- z.parent.parent.color = 1 /* RED */;
11576
+ if ((y == null ? void 0 : y.color) === "RED") {
11577
+ z.parent.color = "BLACK";
11578
+ y.color = "BLACK";
11579
+ z.parent.parent.color = "RED";
11603
11580
  z = z.parent.parent;
11604
11581
  } else {
11605
11582
  if (z === z.parent.left) {
@@ -11607,15 +11584,15 @@ var dataStructureTyped = (() => {
11607
11584
  this._rightRotate(z);
11608
11585
  }
11609
11586
  if (z && this.isRealNode(z.parent) && this.isRealNode(z.parent.parent)) {
11610
- z.parent.color = 0 /* BLACK */;
11611
- z.parent.parent.color = 1 /* RED */;
11587
+ z.parent.color = "BLACK";
11588
+ z.parent.parent.color = "RED";
11612
11589
  this._leftRotate(z.parent.parent);
11613
11590
  }
11614
11591
  }
11615
11592
  }
11616
11593
  }
11617
11594
  if (this.isRealNode(this._root))
11618
- this._root.color = 0 /* BLACK */;
11595
+ this._root.color = "BLACK";
11619
11596
  }
11620
11597
  /**
11621
11598
  * Time Complexity: O(log n)
@@ -11633,66 +11610,66 @@ var dataStructureTyped = (() => {
11633
11610
  */
11634
11611
  _deleteFixup(node) {
11635
11612
  var _a, _b, _c, _d;
11636
- if (!node || node === this.root || node.color === 0 /* BLACK */) {
11613
+ if (!node || node === this.root || node.color === "BLACK") {
11637
11614
  if (node) {
11638
- node.color = 0 /* BLACK */;
11615
+ node.color = "BLACK";
11639
11616
  }
11640
11617
  return;
11641
11618
  }
11642
- while (node && node !== this.root && node.color === 0 /* BLACK */) {
11619
+ while (node && node !== this.root && node.color === "BLACK") {
11643
11620
  const parent = node.parent;
11644
11621
  if (!parent) {
11645
11622
  break;
11646
11623
  }
11647
11624
  if (node === parent.left) {
11648
11625
  let sibling = parent.right;
11649
- if ((sibling == null ? void 0 : sibling.color) === 1 /* RED */) {
11650
- sibling.color = 0 /* BLACK */;
11651
- parent.color = 1 /* RED */;
11626
+ if ((sibling == null ? void 0 : sibling.color) === "RED") {
11627
+ sibling.color = "BLACK";
11628
+ parent.color = "RED";
11652
11629
  this._leftRotate(parent);
11653
11630
  sibling = parent.right;
11654
11631
  }
11655
- if (((_b = (_a = sibling == null ? void 0 : sibling.left) == null ? void 0 : _a.color) != null ? _b : 0 /* BLACK */) === 0 /* BLACK */) {
11632
+ if (((_b = (_a = sibling == null ? void 0 : sibling.left) == null ? void 0 : _a.color) != null ? _b : "BLACK") === "BLACK") {
11656
11633
  if (sibling)
11657
- sibling.color = 1 /* RED */;
11634
+ sibling.color = "RED";
11658
11635
  node = parent;
11659
11636
  } else {
11660
11637
  if (sibling == null ? void 0 : sibling.left)
11661
- sibling.left.color = 0 /* BLACK */;
11638
+ sibling.left.color = "BLACK";
11662
11639
  if (sibling)
11663
11640
  sibling.color = parent.color;
11664
- parent.color = 0 /* BLACK */;
11641
+ parent.color = "BLACK";
11665
11642
  this._rightRotate(parent);
11666
11643
  node = this.root;
11667
11644
  }
11668
11645
  } else {
11669
11646
  let sibling = parent.left;
11670
- if ((sibling == null ? void 0 : sibling.color) === 1 /* RED */) {
11671
- sibling.color = 0 /* BLACK */;
11647
+ if ((sibling == null ? void 0 : sibling.color) === "RED") {
11648
+ sibling.color = "BLACK";
11672
11649
  if (parent)
11673
- parent.color = 1 /* RED */;
11650
+ parent.color = "RED";
11674
11651
  this._rightRotate(parent);
11675
11652
  if (parent)
11676
11653
  sibling = parent.left;
11677
11654
  }
11678
- if (((_d = (_c = sibling == null ? void 0 : sibling.right) == null ? void 0 : _c.color) != null ? _d : 0 /* BLACK */) === 0 /* BLACK */) {
11655
+ if (((_d = (_c = sibling == null ? void 0 : sibling.right) == null ? void 0 : _c.color) != null ? _d : "BLACK") === "BLACK") {
11679
11656
  if (sibling)
11680
- sibling.color = 1 /* RED */;
11657
+ sibling.color = "RED";
11681
11658
  node = parent;
11682
11659
  } else {
11683
11660
  if (sibling == null ? void 0 : sibling.right)
11684
- sibling.right.color = 0 /* BLACK */;
11661
+ sibling.right.color = "BLACK";
11685
11662
  if (sibling)
11686
11663
  sibling.color = parent.color;
11687
11664
  if (parent)
11688
- parent.color = 0 /* BLACK */;
11665
+ parent.color = "BLACK";
11689
11666
  this._leftRotate(parent);
11690
11667
  node = this.root;
11691
11668
  }
11692
11669
  }
11693
11670
  }
11694
11671
  if (node) {
11695
- node.color = 0 /* BLACK */;
11672
+ node.color = "BLACK";
11696
11673
  }
11697
11674
  }
11698
11675
  /**
@@ -11812,7 +11789,19 @@ var dataStructureTyped = (() => {
11812
11789
  get count() {
11813
11790
  return this._count;
11814
11791
  }
11815
- getMutableCount() {
11792
+ /**
11793
+ * Time Complexity: O(n)
11794
+ * Space Complexity: O(1)
11795
+ */
11796
+ /**
11797
+ * Time Complexity: O(n)
11798
+ * Space Complexity: O(1)
11799
+ *
11800
+ * The function calculates the sum of the count property of all nodes in a tree using depth-first
11801
+ * search.
11802
+ * @returns the sum of the count property of all nodes in the tree.
11803
+ */
11804
+ getComputedCount() {
11816
11805
  let sum = 0;
11817
11806
  this.dfs((node) => sum += node.count);
11818
11807
  return sum;
@@ -11958,9 +11947,9 @@ var dataStructureTyped = (() => {
11958
11947
  this._setRoot(curr.right);
11959
11948
  } else {
11960
11949
  const { familyPosition: fp } = curr;
11961
- if (fp === "LEFT" /* LEFT */ || fp === "ROOT_LEFT" /* ROOT_LEFT */) {
11950
+ if (fp === "LEFT" || fp === "ROOT_LEFT") {
11962
11951
  parent.left = curr.right;
11963
- } else if (fp === "RIGHT" /* RIGHT */ || fp === "ROOT_RIGHT" /* ROOT_RIGHT */) {
11952
+ } else if (fp === "RIGHT" || fp === "ROOT_RIGHT") {
11964
11953
  parent.right = curr.right;
11965
11954
  }
11966
11955
  needBalanced = parent;
@@ -12020,11 +12009,11 @@ var dataStructureTyped = (() => {
12020
12009
  * @returns a boolean value.
12021
12010
  */
12022
12011
  perfectlyBalance(iterationType = this.iterationType) {
12023
- const sorted = this.dfs((node) => node, "in"), n = sorted.length;
12012
+ const sorted = this.dfs((node) => node, "IN"), n = sorted.length;
12024
12013
  if (sorted.length < 1)
12025
12014
  return false;
12026
12015
  this.clear();
12027
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
12016
+ if (iterationType === "RECURSIVE") {
12028
12017
  const buildBalanceBST = (l, r) => {
12029
12018
  if (l > r)
12030
12019
  return;
@@ -12117,17 +12106,19 @@ var dataStructureTyped = (() => {
12117
12106
  // src/data-structures/binary-tree/tree-multi-map.ts
12118
12107
  var TreeMultiMapNode = class extends RedBlackTreeNode {
12119
12108
  /**
12120
- * The constructor function initializes an instance of a class with a key, value, and count.
12121
- * @param {K} key - The key parameter is of type K, which represents the type of the key for the
12122
- * constructor. It is required and must be provided when creating an instance of the class.
12123
- * @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
12124
- * value associated with the key in the constructor. If no value is provided, it will be `undefined`.
12125
- * @param [count=1] - The "count" parameter is an optional parameter that specifies the number of
12126
- * times the key-value pair should be repeated. If no value is provided for "count", it defaults to
12127
- * 1.
12128
- */
12129
- constructor(key, value, count = 1) {
12130
- super(key, value);
12109
+ * The constructor function initializes a Red-Black Tree node with a key, value, count, and color.
12110
+ * @param {K} key - The key parameter represents the key of the node in the Red-Black Tree. It is
12111
+ * used to identify and locate the node within the tree.
12112
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
12113
+ * associated with the key in the Red-Black Tree node. It is not required and can be omitted when
12114
+ * creating a new node.
12115
+ * @param [count=1] - The `count` parameter represents the number of occurrences of a particular key
12116
+ * in the Red-Black Tree. It is an optional parameter with a default value of 1.
12117
+ * @param {RBTNColor} [color=BLACK] - The `color` parameter is used to specify the color of the node
12118
+ * in a Red-Black Tree. It is optional and has a default value of `'BLACK'`.
12119
+ */
12120
+ constructor(key, value, count = 1, color = "BLACK") {
12121
+ super(key, value, color);
12131
12122
  __publicField(this, "_count", 1);
12132
12123
  this.count = count;
12133
12124
  }
@@ -12171,24 +12162,39 @@ var dataStructureTyped = (() => {
12171
12162
  get count() {
12172
12163
  return this._count;
12173
12164
  }
12174
- getMutableCount() {
12165
+ /**
12166
+ * Time Complexity: O(n)
12167
+ * Space Complexity: O(1)
12168
+ */
12169
+ /**
12170
+ * Time Complexity: O(n)
12171
+ * Space Complexity: O(1)
12172
+ *
12173
+ * The function calculates the sum of the count property of all nodes in a tree using depth-first
12174
+ * search.
12175
+ * @returns the sum of the count property of all nodes in the tree.
12176
+ */
12177
+ getComputedCount() {
12175
12178
  let sum = 0;
12176
12179
  this.dfs((node) => sum += node.count);
12177
12180
  return sum;
12178
12181
  }
12179
12182
  /**
12180
- * The function creates a new TreeMultiMapNode object with the specified key, value, and count.
12183
+ * The function creates a new TreeMultiMapNode with the specified key, value, color, and count.
12181
12184
  * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
12182
- * which is a generic type that can be replaced with any specific type when using the function.
12183
- * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
12184
- * associated with the key in the node. It is of type `V`, which can be any data type.
12185
- * @param {number} [count] - The `count` parameter represents the number of occurrences of a
12186
- * key-value pair in the TreeMultiMap. It is an optional parameter, so if it is not provided, it will
12187
- * default to 1.
12188
- * @returns a new instance of the TreeMultiMapNode class, casted as NODE.
12185
+ * which is a generic type representing the key type of the node.
12186
+ * @param {V} [value] - The `value` parameter represents the value associated with the key in the
12187
+ * node. It is an optional parameter, which means it can be omitted when calling the `createNode`
12188
+ * function. If provided, it should be of type `V`.
12189
+ * @param {RBTNColor} [color=BLACK] - The color parameter is used to specify the color of the node in
12190
+ * a Red-Black Tree. It can have two possible values: 'RED' or 'BLACK'. The default value is 'BLACK'.
12191
+ * @param {number} [count] - The `count` parameter represents the number of occurrences of a key in
12192
+ * the tree. It is an optional parameter and is used to keep track of the number of values associated
12193
+ * with a key in the tree.
12194
+ * @returns A new instance of the TreeMultiMapNode class is being returned.
12189
12195
  */
12190
- createNode(key, value, count) {
12191
- return new TreeMultiMapNode(key, value, count);
12196
+ createNode(key, value, color = "BLACK", count) {
12197
+ return new TreeMultiMapNode(key, value, count, color);
12192
12198
  }
12193
12199
  /**
12194
12200
  * The function creates a new instance of a TreeMultiMap with the specified options and returns it.
@@ -12225,10 +12231,10 @@ var dataStructureTyped = (() => {
12225
12231
  if (key === void 0 || key === null) {
12226
12232
  return;
12227
12233
  } else {
12228
- node = this.createNode(key, value2, count);
12234
+ node = this.createNode(key, value2, "BLACK", count);
12229
12235
  }
12230
12236
  } else if (!this.isNode(keyOrNodeOrEntry)) {
12231
- node = this.createNode(keyOrNodeOrEntry, value, count);
12237
+ node = this.createNode(keyOrNodeOrEntry, value, "BLACK", count);
12232
12238
  } else {
12233
12239
  return;
12234
12240
  }
@@ -12370,7 +12376,7 @@ var dataStructureTyped = (() => {
12370
12376
  }
12371
12377
  }
12372
12378
  this._size--;
12373
- if (originalColor === 0 /* BLACK */) {
12379
+ if (originalColor === "BLACK") {
12374
12380
  this._deleteFixup(replacementNode);
12375
12381
  }
12376
12382
  results.push({ deleted: nodeToDelete, needBalanced: void 0 });
@@ -12407,11 +12413,11 @@ var dataStructureTyped = (() => {
12407
12413
  * @returns a boolean value.
12408
12414
  */
12409
12415
  perfectlyBalance(iterationType = this.iterationType) {
12410
- const sorted = this.dfs((node) => node, "in"), n = sorted.length;
12416
+ const sorted = this.dfs((node) => node, "IN"), n = sorted.length;
12411
12417
  if (sorted.length < 1)
12412
12418
  return false;
12413
12419
  this.clear();
12414
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
12420
+ if (iterationType === "RECURSIVE") {
12415
12421
  const buildBalanceBST = (l, r) => {
12416
12422
  if (l > r)
12417
12423
  return;
@@ -12473,7 +12479,7 @@ var dataStructureTyped = (() => {
12473
12479
  destNode = this.ensureNode(destNode);
12474
12480
  if (srcNode && destNode) {
12475
12481
  const { key, value, count, color } = destNode;
12476
- const tempNode = this.createNode(key, value, count);
12482
+ const tempNode = this.createNode(key, value, color, count);
12477
12483
  if (tempNode) {
12478
12484
  tempNode.color = color;
12479
12485
  destNode.key = srcNode.key;