data-structure-typed 1.49.9 → 1.50.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 (79) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +192 -200
  3. package/benchmark/report.html +13 -13
  4. package/benchmark/report.json +158 -152
  5. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -7
  7. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -9
  8. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +5 -22
  10. package/dist/cjs/data-structures/binary-tree/binary-tree.js +9 -80
  11. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/bst.d.ts +89 -27
  13. package/dist/cjs/data-structures/binary-tree/bst.js +131 -46
  14. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +0 -7
  16. package/dist/cjs/data-structures/binary-tree/rb-tree.js +1 -10
  17. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +0 -7
  19. package/dist/cjs/data-structures/binary-tree/tree-multimap.js +2 -11
  20. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  21. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  22. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  23. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  24. package/dist/cjs/data-structures/hash/hash-map.d.ts +3 -3
  25. package/dist/cjs/data-structures/hash/hash-map.js +6 -6
  26. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  27. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  28. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  29. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  30. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  31. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  32. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  33. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  34. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -7
  35. package/dist/mjs/data-structures/binary-tree/avl-tree.js +0 -9
  36. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +5 -22
  37. package/dist/mjs/data-structures/binary-tree/binary-tree.js +9 -80
  38. package/dist/mjs/data-structures/binary-tree/bst.d.ts +89 -27
  39. package/dist/mjs/data-structures/binary-tree/bst.js +131 -46
  40. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +0 -7
  41. package/dist/mjs/data-structures/binary-tree/rb-tree.js +1 -10
  42. package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +0 -7
  43. package/dist/mjs/data-structures/binary-tree/tree-multimap.js +2 -11
  44. package/dist/mjs/data-structures/hash/hash-map.d.ts +3 -3
  45. package/dist/mjs/data-structures/hash/hash-map.js +15 -15
  46. package/dist/umd/data-structure-typed.js +143 -153
  47. package/dist/umd/data-structure-typed.min.js +2 -2
  48. package/dist/umd/data-structure-typed.min.js.map +1 -1
  49. package/package.json +12 -41
  50. package/src/data-structures/base/iterable-base.ts +6 -6
  51. package/src/data-structures/binary-tree/avl-tree.ts +7 -18
  52. package/src/data-structures/binary-tree/binary-tree.ts +111 -149
  53. package/src/data-structures/binary-tree/bst.ts +159 -56
  54. package/src/data-structures/binary-tree/rb-tree.ts +7 -18
  55. package/src/data-structures/binary-tree/tree-multimap.ts +8 -19
  56. package/src/data-structures/graph/abstract-graph.ts +14 -15
  57. package/src/data-structures/graph/directed-graph.ts +6 -7
  58. package/src/data-structures/graph/undirected-graph.ts +6 -7
  59. package/src/data-structures/hash/hash-map.ts +23 -22
  60. package/src/data-structures/heap/heap.ts +1 -1
  61. package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
  62. package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
  63. package/src/data-structures/queue/deque.ts +3 -3
  64. package/src/data-structures/queue/queue.ts +1 -1
  65. package/src/data-structures/stack/stack.ts +1 -1
  66. package/src/data-structures/trie/trie.ts +1 -1
  67. package/src/types/data-structures/graph/abstract-graph.ts +8 -8
  68. package/test/integration/all-in-one.test.ts +1 -1
  69. package/test/integration/index.html +2 -2
  70. package/test/performance/data-structures/queue/deque.test.ts +8 -2
  71. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +2 -2
  72. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +38 -9
  73. package/test/unit/data-structures/binary-tree/bst.test.ts +8 -12
  74. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +4 -4
  75. package/test/unit/data-structures/graph/abstract-graph.test.ts +2 -1
  76. package/test/unit/data-structures/hash/hash-map.test.ts +4 -2
  77. package/test/unit/data-structures/queue/deque.test.ts +8 -6
  78. package/test/unit/data-structures/queue/queue.test.ts +1 -1
  79. package/test/unit/unrestricted-interconversion.test.ts +143 -10
@@ -9,21 +9,6 @@ import { isWeakKey, rangeCheck } from '../../utils';
9
9
  export class HashMap extends IterableEntryBase {
10
10
  _store = {};
11
11
  _objMap = new Map();
12
- _toEntryFn = (rawElement) => {
13
- if (this.isEntry(rawElement)) {
14
- // TODO, For performance optimization, it may be necessary to only inspect the first element traversed.
15
- return rawElement;
16
- }
17
- else {
18
- throw new Error("If the provided rawCollection does not adhere to the [key, value] type format, the toEntryFn in the constructor's options parameter needs to specified.");
19
- }
20
- };
21
- get toEntryFn() {
22
- return this._toEntryFn;
23
- }
24
- isEntry(rawElement) {
25
- return Array.isArray(rawElement) && rawElement.length === 2;
26
- }
27
12
  /**
28
13
  * The constructor function initializes a HashMap object with an optional initial collection and
29
14
  * options.
@@ -46,10 +31,25 @@ export class HashMap extends IterableEntryBase {
46
31
  this.setMany(rawCollection);
47
32
  }
48
33
  }
34
+ _toEntryFn = (rawElement) => {
35
+ if (this.isEntry(rawElement)) {
36
+ // TODO, For performance optimization, it may be necessary to only inspect the first element traversed.
37
+ return rawElement;
38
+ }
39
+ else {
40
+ throw new Error("If the provided rawCollection does not adhere to the [key, value] type format, the toEntryFn in the constructor's options parameter needs to specified.");
41
+ }
42
+ };
43
+ get toEntryFn() {
44
+ return this._toEntryFn;
45
+ }
49
46
  _size = 0;
50
47
  get size() {
51
48
  return this._size;
52
49
  }
50
+ isEntry(rawElement) {
51
+ return Array.isArray(rawElement) && rawElement.length === 2;
52
+ }
53
53
  isEmpty() {
54
54
  return this.size === 0;
55
55
  }
@@ -622,12 +622,12 @@ var dataStructureTyped = (() => {
622
622
  get toEntryFn() {
623
623
  return this._toEntryFn;
624
624
  }
625
- isEntry(rawElement) {
626
- return Array.isArray(rawElement) && rawElement.length === 2;
627
- }
628
625
  get size() {
629
626
  return this._size;
630
627
  }
628
+ isEntry(rawElement) {
629
+ return Array.isArray(rawElement) && rawElement.length === 2;
630
+ }
631
631
  isEmpty() {
632
632
  return this.size === 0;
633
633
  }
@@ -7136,7 +7136,7 @@ var dataStructureTyped = (() => {
7136
7136
  }
7137
7137
  } else if (this.isNode(keyOrNodeOrEntry)) {
7138
7138
  node = keyOrNodeOrEntry;
7139
- } else if (this.isNotNodeInstance(keyOrNodeOrEntry)) {
7139
+ } else if (!this.isNode(keyOrNodeOrEntry)) {
7140
7140
  node = this.createNode(keyOrNodeOrEntry, value);
7141
7141
  } else {
7142
7142
  return;
@@ -7224,15 +7224,6 @@ var dataStructureTyped = (() => {
7224
7224
  isNodeOrNull(node) {
7225
7225
  return this.isRealNode(node) || node === null;
7226
7226
  }
7227
- /**
7228
- * The function "isNotNodeInstance" checks if a potential key is a K.
7229
- * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
7230
- * data type.
7231
- * @returns a boolean value indicating whether the potentialKey is of type number or not.
7232
- */
7233
- isNotNodeInstance(potentialKey) {
7234
- return !(potentialKey instanceof BinaryTreeNode);
7235
- }
7236
7227
  /**
7237
7228
  * Time Complexity O(log n) - O(n)
7238
7229
  * Space Complexity O(1)
@@ -7777,7 +7768,7 @@ var dataStructureTyped = (() => {
7777
7768
  *
7778
7769
  * The function `getPathToRoot` returns an array of nodes from a given node to the root of a tree
7779
7770
  * structure, with the option to reverse the order of the nodes.
7780
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
7771
+ * @param {K | N | null | undefined} beginNode - The `beginRoot` parameter represents the
7781
7772
  * starting node from which you want to find the path to the root. It can be of type `K`, `N`,
7782
7773
  * `null`, or `undefined`.
7783
7774
  * @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
@@ -7785,16 +7776,16 @@ var dataStructureTyped = (() => {
7785
7776
  * reversed before returning it. If `isReverse` is set to `false`, the path will be returned as is
7786
7777
  * @returns The function `getPathToRoot` returns an array of nodes (`N[]`).
7787
7778
  */
7788
- getPathToRoot(beginRoot, isReverse = true) {
7779
+ getPathToRoot(beginNode, isReverse = true) {
7789
7780
  const result = [];
7790
- beginRoot = this.ensureNode(beginRoot);
7791
- if (!beginRoot)
7781
+ beginNode = this.ensureNode(beginNode);
7782
+ if (!beginNode)
7792
7783
  return result;
7793
- while (beginRoot.parent) {
7794
- result.push(beginRoot);
7795
- beginRoot = beginRoot.parent;
7784
+ while (beginNode.parent) {
7785
+ result.push(beginNode);
7786
+ beginNode = beginNode.parent;
7796
7787
  }
7797
- result.push(beginRoot);
7788
+ result.push(beginNode);
7798
7789
  return isReverse ? result.reverse() : result;
7799
7790
  }
7800
7791
  /**
@@ -7929,65 +7920,6 @@ var dataStructureTyped = (() => {
7929
7920
  return isStandardBST || isInverseBST;
7930
7921
  }
7931
7922
  }
7932
- /**
7933
- * Time complexity: O(n)
7934
- * Space complexity: O(log n)
7935
- *
7936
- * The function `subTreeTraverse` traverses a binary tree and applies a callback function to each
7937
- * node, either recursively or iteratively.
7938
- * @param {C} callback - The `callback` parameter is a function that will be called for each node in
7939
- * the subtree traversal. It takes a single parameter, which is the current node being traversed, and
7940
- * returns a value of any type.
7941
- * @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
7942
- * starting node or key from which the subtree traversal should begin. It can be of type `K`,
7943
- * `N`, `null`, or `undefined`. If not provided, the `root` property of the current object is used as
7944
- * the default value.
7945
- * @param iterationType - The `iterationType` parameter determines the type of traversal to be
7946
- * performed on the subtree. It can have two possible values:
7947
- * @param [includeNull=false] - The `includeNull` parameter is a boolean value that determines
7948
- * whether to include null values in the traversal. If `includeNull` is set to `true`, the
7949
- * traversal will include null values, otherwise it will skip them.
7950
- * @returns The function `subTreeTraverse` returns an array of values that are the result of invoking
7951
- * the `callback` function on each node in the subtree. The type of the array nodes is determined
7952
- * by the return type of the `callback` function.
7953
- */
7954
- subTreeTraverse(callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType, includeNull = false) {
7955
- beginRoot = this.ensureNode(beginRoot);
7956
- const ans = [];
7957
- if (!beginRoot)
7958
- return ans;
7959
- if (iterationType === "RECURSIVE" /* RECURSIVE */) {
7960
- const _traverse = (cur) => {
7961
- if (cur !== void 0) {
7962
- ans.push(callback(cur));
7963
- if (includeNull) {
7964
- cur && this.isNodeOrNull(cur.left) && _traverse(cur.left);
7965
- cur && this.isNodeOrNull(cur.right) && _traverse(cur.right);
7966
- } else {
7967
- cur && cur.left && _traverse(cur.left);
7968
- cur && cur.right && _traverse(cur.right);
7969
- }
7970
- }
7971
- };
7972
- _traverse(beginRoot);
7973
- } else {
7974
- const stack = [beginRoot];
7975
- while (stack.length > 0) {
7976
- const cur = stack.pop();
7977
- if (cur !== void 0) {
7978
- ans.push(callback(cur));
7979
- if (includeNull) {
7980
- cur && this.isNodeOrNull(cur.right) && stack.push(cur.right);
7981
- cur && this.isNodeOrNull(cur.left) && stack.push(cur.left);
7982
- } else {
7983
- cur && cur.right && stack.push(cur.right);
7984
- cur && cur.left && stack.push(cur.left);
7985
- }
7986
- }
7987
- }
7988
- }
7989
- return ans;
7990
- }
7991
7923
  /**
7992
7924
  * Time complexity: O(n)
7993
7925
  * Space complexity: O(n)
@@ -8759,7 +8691,7 @@ var dataStructureTyped = (() => {
8759
8691
  } else {
8760
8692
  node = this.createNode(key, value2);
8761
8693
  }
8762
- } else if (this.isNotNodeInstance(keyOrNodeOrEntry)) {
8694
+ } else if (!this.isNode(keyOrNodeOrEntry)) {
8763
8695
  node = this.createNode(keyOrNodeOrEntry, value);
8764
8696
  } else {
8765
8697
  return;
@@ -8796,15 +8728,6 @@ var dataStructureTyped = (() => {
8796
8728
  }
8797
8729
  return res;
8798
8730
  }
8799
- /**
8800
- * The function "isNotNodeInstance" checks if a potential key is a K.
8801
- * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
8802
- * data type.
8803
- * @returns a boolean value indicating whether the potentialKey is of type number or not.
8804
- */
8805
- isNotNodeInstance(potentialKey) {
8806
- return !(potentialKey instanceof BSTNode);
8807
- }
8808
8731
  /**
8809
8732
  * The function checks if an keyOrNodeOrEntry is an instance of BSTNode.
8810
8733
  * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is a variable of type `KeyOrNodeOrEntry<K, V, N>`.
@@ -8962,39 +8885,6 @@ var dataStructureTyped = (() => {
8962
8885
  }
8963
8886
  return inserted;
8964
8887
  }
8965
- /**
8966
- * Time Complexity: O(n log n)
8967
- * Space Complexity: O(n)
8968
- * Adding each element individually in a balanced tree. Additional space is required for the sorted array.
8969
- */
8970
- /**
8971
- * Time Complexity: O(n log n)
8972
- * Space Complexity: O(n)
8973
- *
8974
- * The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
8975
- * leftmost node if the comparison result is greater than.
8976
- * @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
8977
- * type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
8978
- * the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
8979
- * @returns the key of the rightmost node in the binary tree if the comparison result is less than,
8980
- * the key of the leftmost node if the comparison result is greater than, and the key of the
8981
- * rightmost node otherwise. If no node is found, it returns 0.
8982
- */
8983
- lastKey(beginRoot = this.root) {
8984
- let current = this.ensureNode(beginRoot);
8985
- if (!current)
8986
- return void 0;
8987
- if (this._variant === "STANDARD" /* STANDARD */) {
8988
- while (current.right !== void 0) {
8989
- current = current.right;
8990
- }
8991
- } else {
8992
- while (current.left !== void 0) {
8993
- current = current.left;
8994
- }
8995
- }
8996
- return current.key;
8997
- }
8998
8888
  /**
8999
8889
  * Time Complexity: O(log n)
9000
8890
  * Space Complexity: O(1)
@@ -9123,6 +9013,133 @@ var dataStructureTyped = (() => {
9123
9013
  }
9124
9014
  return ans;
9125
9015
  }
9016
+ // /**
9017
+ // * The function overrides the subTreeTraverse method and returns the result of calling the super
9018
+ // * method with the provided arguments.
9019
+ // * @param {C} callback - The `callback` parameter is a function that will be called for each node in
9020
+ // * the subtree traversal. It should accept a single parameter of type `N`, which represents a node in
9021
+ // * the tree. The return type of the callback function can be any type.
9022
+ // * @param beginRoot - The `beginRoot` parameter is the starting point for traversing the subtree. It
9023
+ // * can be either a key, a node, or an entry.
9024
+ // * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
9025
+ // * be performed during the traversal of the subtree. It can have one of the following values:
9026
+ // * @returns The method is returning an array of the return type of the callback function.
9027
+ // */
9028
+ // override subTreeTraverse<C extends BTNCallback<N>>(
9029
+ // callback: C = this._defaultOneParamCallback as C,
9030
+ // beginRoot: KeyOrNodeOrEntry<K, V, N> = this.root,
9031
+ // iterationType = this.iterationType
9032
+ // ): ReturnType<C>[] {
9033
+ // return super.subTreeTraverse(callback, beginRoot, iterationType, false);
9034
+ // }
9035
+ /**
9036
+ * Time complexity: O(n)
9037
+ * Space complexity: O(n)
9038
+ */
9039
+ /**
9040
+ * Time complexity: O(n)
9041
+ * Space complexity: O(n)
9042
+ *
9043
+ * The function overrides the depth-first search method and returns an array of the return types of
9044
+ * the callback function.
9045
+ * @param {C} callback - The `callback` parameter is a function that will be called for each node
9046
+ * during the depth-first search traversal. It is an optional parameter and if not provided, a
9047
+ * default callback function will be used.
9048
+ * @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter specifies the order in which the
9049
+ * nodes are visited during the depth-first search. It can have one of the following values:
9050
+ * @param beginRoot - The `beginRoot` parameter is used to specify the starting point for the
9051
+ * Depth-First Search (DFS) traversal. It can be either a key, a node, or an entry in the tree. If no
9052
+ * value is provided, the DFS traversal will start from the root of the tree.
9053
+ * @param {IterationType} iterationType - The `iterationType` parameter specifies the type of
9054
+ * iteration to be used during the Depth-First Search (DFS) traversal. It can have one of the
9055
+ * following values:
9056
+ * @returns The method is returning an array of the return type of the callback function.
9057
+ */
9058
+ dfs(callback = this._defaultOneParamCallback, pattern = "in", beginRoot = this.root, iterationType = "ITERATIVE" /* ITERATIVE */) {
9059
+ return super.dfs(callback, pattern, beginRoot, iterationType, false);
9060
+ }
9061
+ /**
9062
+ * Time complexity: O(n)
9063
+ * Space complexity: O(n)
9064
+ */
9065
+ /**
9066
+ * Time complexity: O(n)
9067
+ * Space complexity: O(n)
9068
+ *
9069
+ * The function overrides the breadth-first search method and returns an array of the return types of
9070
+ * the callback function.
9071
+ * @param {C} callback - The `callback` parameter is a function that will be called for each node
9072
+ * visited during the breadth-first search traversal. It is an optional parameter and if not
9073
+ * provided, a default callback function will be used.
9074
+ * @param beginRoot - The `beginRoot` parameter is the starting point for the breadth-first search
9075
+ * traversal. It can be either a key, a node, or an entry in the tree. If not specified, the root of
9076
+ * the tree is used as the starting point.
9077
+ * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
9078
+ * be performed during the breadth-first search (BFS) traversal. It determines the order in which the
9079
+ * nodes are visited.
9080
+ * @returns The method is returning an array of the return type of the callback function.
9081
+ */
9082
+ bfs(callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
9083
+ return super.bfs(callback, beginRoot, iterationType, false);
9084
+ }
9085
+ /**
9086
+ * Time complexity: O(n)
9087
+ * Space complexity: O(n)
9088
+ */
9089
+ /**
9090
+ * Time complexity: O(n)
9091
+ * Space complexity: O(n)
9092
+ *
9093
+ * The function overrides the listLevels method and returns an array of arrays containing the return
9094
+ * type of the callback function for each level of the tree.
9095
+ * @param {C} callback - The `callback` parameter is a generic type `C` that extends
9096
+ * `BTNCallback<N>`. It represents a callback function that will be called for each node in the tree
9097
+ * during the level listing process.
9098
+ * @param beginRoot - The `beginRoot` parameter is used to specify the starting point for listing the
9099
+ * levels of a binary tree. It can be either a key, a node, or an entry in the binary tree. If not
9100
+ * provided, the root of the binary tree is used as the starting point.
9101
+ * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
9102
+ * be performed on the tree. It determines the order in which the nodes are visited during the
9103
+ * iteration.
9104
+ * @returns The method is returning a two-dimensional array of the return type of the callback
9105
+ * function.
9106
+ */
9107
+ listLevels(callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
9108
+ return super.listLevels(callback, beginRoot, iterationType, false);
9109
+ }
9110
+ /**
9111
+ * Time Complexity: O(n log n)
9112
+ * Space Complexity: O(n)
9113
+ * Adding each element individually in a balanced tree. Additional space is required for the sorted array.
9114
+ */
9115
+ /**
9116
+ * Time Complexity: O(n log n)
9117
+ * Space Complexity: O(n)
9118
+ *
9119
+ * The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
9120
+ * leftmost node if the comparison result is greater than.
9121
+ * @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
9122
+ * type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
9123
+ * the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
9124
+ * @returns the key of the rightmost node in the binary tree if the comparison result is less than,
9125
+ * the key of the leftmost node if the comparison result is greater than, and the key of the
9126
+ * rightmost node otherwise. If no node is found, it returns 0.
9127
+ */
9128
+ lastKey(beginRoot = this.root) {
9129
+ let current = this.ensureNode(beginRoot);
9130
+ if (!current)
9131
+ return void 0;
9132
+ if (this._variant === "STANDARD" /* STANDARD */) {
9133
+ while (current.right !== void 0) {
9134
+ current = current.right;
9135
+ }
9136
+ } else {
9137
+ while (current.left !== void 0) {
9138
+ current = current.left;
9139
+ }
9140
+ }
9141
+ return current.key;
9142
+ }
9126
9143
  /**
9127
9144
  * Time Complexity: O(log n)
9128
9145
  * Space Complexity: O(log n)
@@ -9807,15 +9824,6 @@ var dataStructureTyped = (() => {
9807
9824
  isNode(keyOrNodeOrEntry) {
9808
9825
  return keyOrNodeOrEntry instanceof AVLTreeNode;
9809
9826
  }
9810
- /**
9811
- * The function "isNotNodeInstance" checks if a potential key is a K.
9812
- * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
9813
- * data type.
9814
- * @returns a boolean value indicating whether the potentialKey is of type number or not.
9815
- */
9816
- isNotNodeInstance(potentialKey) {
9817
- return !(potentialKey instanceof AVLTreeNode);
9818
- }
9819
9827
  /**
9820
9828
  * Time Complexity: O(log n)
9821
9829
  * Space Complexity: O(1)
@@ -10264,7 +10272,7 @@ var dataStructureTyped = (() => {
10264
10272
  } else {
10265
10273
  node = this.createNode(key, value2, 1 /* RED */);
10266
10274
  }
10267
- } else if (this.isNotNodeInstance(keyOrNodeOrEntry)) {
10275
+ } else if (!this.isNode(keyOrNodeOrEntry)) {
10268
10276
  node = this.createNode(keyOrNodeOrEntry, value, 1 /* RED */);
10269
10277
  } else {
10270
10278
  return;
@@ -10289,15 +10297,6 @@ var dataStructureTyped = (() => {
10289
10297
  return false;
10290
10298
  return node instanceof RedBlackTreeNode;
10291
10299
  }
10292
- /**
10293
- * The function "isNotNodeInstance" checks if a potential key is a K.
10294
- * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
10295
- * data type.
10296
- * @returns a boolean value indicating whether the potentialKey is of type number or not.
10297
- */
10298
- isNotNodeInstance(potentialKey) {
10299
- return !(potentialKey instanceof RedBlackTreeNode);
10300
- }
10301
10300
  /**
10302
10301
  * Time Complexity: O(log n)
10303
10302
  * Space Complexity: O(1)
@@ -10757,7 +10756,7 @@ var dataStructureTyped = (() => {
10757
10756
  // TODO the _count is not accurate after nodes count modified
10758
10757
  get count() {
10759
10758
  let sum = 0;
10760
- this.subTreeTraverse((node) => sum += node.count);
10759
+ this.dfs((node) => sum += node.count);
10761
10760
  return sum;
10762
10761
  }
10763
10762
  /**
@@ -10802,7 +10801,7 @@ var dataStructureTyped = (() => {
10802
10801
  } else {
10803
10802
  node = this.createNode(key, value2, count);
10804
10803
  }
10805
- } else if (this.isNotNodeInstance(keyOrNodeOrEntry)) {
10804
+ } else if (!this.isNode(keyOrNodeOrEntry)) {
10806
10805
  node = this.createNode(keyOrNodeOrEntry, value, count);
10807
10806
  } else {
10808
10807
  return;
@@ -10818,15 +10817,6 @@ var dataStructureTyped = (() => {
10818
10817
  isNode(keyOrNodeOrEntry) {
10819
10818
  return keyOrNodeOrEntry instanceof TreeMultimapNode;
10820
10819
  }
10821
- /**
10822
- * The function "isNotNodeInstance" checks if a potential key is a K.
10823
- * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
10824
- * data type.
10825
- * @returns a boolean value indicating whether the potentialKey is of type number or not.
10826
- */
10827
- isNotNodeInstance(potentialKey) {
10828
- return !(potentialKey instanceof TreeMultimapNode);
10829
- }
10830
10820
  /**
10831
10821
  * Time Complexity: O(log n)
10832
10822
  * Space Complexity: O(1)