data-structure-typed 1.53.0 → 1.53.1

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 (45) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/benchmark/report.html +1 -37
  3. package/benchmark/report.json +23 -383
  4. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +1 -1
  5. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.js +1 -1
  7. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/binary-tree.js +2 -2
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  10. package/dist/cjs/data-structures/binary-tree/bst.js +5 -3
  11. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/rb-tree.js +7 -3
  13. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +1 -1
  15. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  16. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +1 -1
  17. package/dist/mjs/data-structures/binary-tree/avl-tree.js +1 -1
  18. package/dist/mjs/data-structures/binary-tree/binary-tree.js +2 -2
  19. package/dist/mjs/data-structures/binary-tree/bst.js +5 -3
  20. package/dist/mjs/data-structures/binary-tree/rb-tree.js +7 -3
  21. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +1 -1
  22. package/dist/umd/data-structure-typed.js +16 -10
  23. package/dist/umd/data-structure-typed.min.js +2 -2
  24. package/dist/umd/data-structure-typed.min.js.map +1 -1
  25. package/package.json +6 -6
  26. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
  27. package/src/data-structures/binary-tree/avl-tree.ts +1 -1
  28. package/src/data-structures/binary-tree/binary-tree.ts +2 -2
  29. package/src/data-structures/binary-tree/bst.ts +4 -3
  30. package/src/data-structures/binary-tree/rb-tree.ts +7 -2
  31. package/src/data-structures/binary-tree/tree-multi-map.ts +1 -1
  32. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -3
  33. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  34. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +1 -1
  35. package/test/performance/data-structures/binary-tree/binary-tree-overall.test.ts +2 -2
  36. package/test/performance/data-structures/binary-tree/binary-tree.test.ts +1 -1
  37. package/test/performance/data-structures/binary-tree/bst.test.ts +1 -1
  38. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +9 -1
  39. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +8 -8
  40. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +28 -9
  41. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +36 -22
  42. package/test/unit/data-structures/binary-tree/bst.test.ts +33 -14
  43. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +19 -0
  44. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +11 -11
  45. package/test/utils/array.ts +15 -12
@@ -6955,7 +6955,7 @@ var dataStructureTyped = (() => {
6955
6955
  constructor(keysNodesEntriesOrRaws = [], options) {
6956
6956
  super();
6957
6957
  __publicField(this, "iterationType", "ITERATIVE");
6958
- __publicField(this, "_isMapMode", false);
6958
+ __publicField(this, "_isMapMode", true);
6959
6959
  __publicField(this, "_store", /* @__PURE__ */ new Map());
6960
6960
  __publicField(this, "_root");
6961
6961
  __publicField(this, "_size", 0);
@@ -6999,7 +6999,7 @@ var dataStructureTyped = (() => {
6999
6999
  * as NODE.
7000
7000
  */
7001
7001
  createNode(key, value) {
7002
- return new BinaryTreeNode(key, value);
7002
+ return new BinaryTreeNode(key, this._isMapMode ? void 0 : value);
7003
7003
  }
7004
7004
  /**
7005
7005
  * The function creates a binary tree with the specified options.
@@ -8811,7 +8811,7 @@ var dataStructureTyped = (() => {
8811
8811
  * @returns The method is returning a new instance of the BSTNode class, casted as the NODE type.
8812
8812
  */
8813
8813
  createNode(key, value) {
8814
- return new BSTNode(key, value);
8814
+ return new BSTNode(key, this._isMapMode ? void 0 : value);
8815
8815
  }
8816
8816
  /**
8817
8817
  * The function creates a new binary search tree with the specified options.
@@ -8838,9 +8838,9 @@ var dataStructureTyped = (() => {
8838
8838
  * @returns either a NODE object or undefined.
8839
8839
  */
8840
8840
  keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
8841
- const [node, tValue] = super.keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
8841
+ const [node, entryValue] = super.keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
8842
8842
  if (node === null) return [void 0, void 0];
8843
- return [node, tValue != null ? tValue : value];
8843
+ return [node, value != null ? value : entryValue];
8844
8844
  }
8845
8845
  /**
8846
8846
  * Time Complexity: O(log n)
@@ -8906,6 +8906,7 @@ var dataStructureTyped = (() => {
8906
8906
  while (current !== void 0) {
8907
8907
  if (this.comparator(current.key, newNode.key) === 0) {
8908
8908
  this._replaceNode(current, newNode);
8909
+ if (this._isMapMode) this._setValue(current.key, newValue);
8909
8910
  return true;
8910
8911
  } else if (this.comparator(current.key, newNode.key) > 0) {
8911
8912
  if (current.left === void 0) {
@@ -9982,7 +9983,7 @@ var dataStructureTyped = (() => {
9982
9983
  * type NODE.
9983
9984
  */
9984
9985
  createNode(key, value) {
9985
- return new AVLTreeNode(key, value);
9986
+ return new AVLTreeNode(key, this._isMapMode ? void 0 : value);
9986
9987
  }
9987
9988
  /**
9988
9989
  * The function creates a new AVL tree with the specified options and returns it.
@@ -10402,7 +10403,7 @@ var dataStructureTyped = (() => {
10402
10403
  * returned.
10403
10404
  */
10404
10405
  createNode(key, value, color = "BLACK") {
10405
- return new RedBlackTreeNode(key, value, color);
10406
+ return new RedBlackTreeNode(key, this._isMapMode ? void 0 : value, color);
10406
10407
  }
10407
10408
  /**
10408
10409
  * The function creates a new Red-Black Tree with the specified options.
@@ -10505,7 +10506,12 @@ var dataStructureTyped = (() => {
10505
10506
  if (this._isMapMode) this._setValue(newNode.key, newValue);
10506
10507
  this._size++;
10507
10508
  return true;
10508
- } else return insertStatus === "UPDATED";
10509
+ }
10510
+ if (insertStatus === "UPDATED") {
10511
+ if (this._isMapMode) this._setValue(newNode.key, newValue);
10512
+ return true;
10513
+ }
10514
+ return false;
10509
10515
  }
10510
10516
  /**
10511
10517
  * Time Complexity: O(log n)
@@ -10920,7 +10926,7 @@ var dataStructureTyped = (() => {
10920
10926
  * @returns a new instance of the AVLTreeMultiMapNode class, casted as NODE.
10921
10927
  */
10922
10928
  createNode(key, value, count) {
10923
- return new AVLTreeMultiMapNode(key, value, count);
10929
+ return new AVLTreeMultiMapNode(key, this._isMapMode ? void 0 : value, count);
10924
10930
  }
10925
10931
  /**
10926
10932
  * The function creates a new AVLTreeMultiMap object with the specified options and returns it.
@@ -11281,7 +11287,7 @@ var dataStructureTyped = (() => {
11281
11287
  * @returns A new instance of the TreeMultiMapNode class, casted as NODE.
11282
11288
  */
11283
11289
  createNode(key, value, color = "BLACK", count) {
11284
- return new TreeMultiMapNode(key, value, count, color);
11290
+ return new TreeMultiMapNode(key, this._isMapMode ? void 0 : value, count, color);
11285
11291
  }
11286
11292
  /**
11287
11293
  * The function creates a new instance of a TreeMultiMap with the specified options and returns it.