linked-list-typed 1.52.5 → 1.52.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/constants/index.d.ts +4 -0
  2. package/dist/constants/index.js +8 -0
  3. package/dist/data-structures/base/iterable-element-base.d.ts +8 -1
  4. package/dist/data-structures/base/iterable-element-base.js +10 -1
  5. package/dist/data-structures/base/iterable-entry-base.d.ts +8 -1
  6. package/dist/data-structures/base/iterable-entry-base.js +10 -10
  7. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +31 -32
  8. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +43 -44
  9. package/dist/data-structures/binary-tree/avl-tree.d.ts +23 -24
  10. package/dist/data-structures/binary-tree/avl-tree.js +71 -64
  11. package/dist/data-structures/binary-tree/binary-indexed-tree.js +2 -2
  12. package/dist/data-structures/binary-tree/binary-tree.d.ts +534 -402
  13. package/dist/data-structures/binary-tree/binary-tree.js +669 -598
  14. package/dist/data-structures/binary-tree/bst.d.ts +72 -65
  15. package/dist/data-structures/binary-tree/bst.js +115 -113
  16. package/dist/data-structures/binary-tree/rb-tree.d.ts +21 -24
  17. package/dist/data-structures/binary-tree/rb-tree.js +40 -39
  18. package/dist/data-structures/binary-tree/segment-tree.d.ts +2 -2
  19. package/dist/data-structures/binary-tree/segment-tree.js +2 -2
  20. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +28 -31
  21. package/dist/data-structures/binary-tree/tree-multi-map.js +44 -43
  22. package/dist/data-structures/graph/abstract-graph.d.ts +2 -2
  23. package/dist/data-structures/graph/abstract-graph.js +7 -4
  24. package/dist/data-structures/graph/directed-graph.d.ts +2 -2
  25. package/dist/data-structures/graph/directed-graph.js +4 -2
  26. package/dist/data-structures/graph/undirected-graph.d.ts +2 -2
  27. package/dist/data-structures/hash/hash-map.d.ts +2 -2
  28. package/dist/data-structures/hash/hash-map.js +1 -1
  29. package/dist/data-structures/heap/heap.js +3 -3
  30. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
  31. package/dist/data-structures/linked-list/doubly-linked-list.js +7 -7
  32. package/dist/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  33. package/dist/data-structures/linked-list/singly-linked-list.js +6 -6
  34. package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  35. package/dist/data-structures/matrix/matrix.d.ts +2 -2
  36. package/dist/data-structures/matrix/navigator.d.ts +2 -2
  37. package/dist/data-structures/matrix/navigator.js +4 -2
  38. package/dist/data-structures/queue/deque.d.ts +3 -3
  39. package/dist/data-structures/queue/deque.js +29 -29
  40. package/dist/data-structures/queue/queue.d.ts +1 -1
  41. package/dist/data-structures/stack/stack.d.ts +2 -2
  42. package/dist/data-structures/trie/trie.d.ts +2 -2
  43. package/dist/data-structures/trie/trie.js +1 -1
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +1 -0
  46. package/dist/interfaces/binary-tree.d.ts +2 -2
  47. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +2 -4
  48. package/dist/types/data-structures/binary-tree/binary-tree.js +0 -6
  49. package/package.json +2 -2
  50. package/src/constants/index.ts +4 -0
  51. package/src/data-structures/base/iterable-element-base.ts +11 -1
  52. package/src/data-structures/base/iterable-entry-base.ts +11 -19
  53. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +47 -50
  54. package/src/data-structures/binary-tree/avl-tree.ts +69 -71
  55. package/src/data-structures/binary-tree/binary-indexed-tree.ts +2 -2
  56. package/src/data-structures/binary-tree/binary-tree.ts +698 -726
  57. package/src/data-structures/binary-tree/bst.ts +123 -129
  58. package/src/data-structures/binary-tree/rb-tree.ts +44 -46
  59. package/src/data-structures/binary-tree/segment-tree.ts +2 -2
  60. package/src/data-structures/binary-tree/tree-multi-map.ts +48 -49
  61. package/src/data-structures/graph/abstract-graph.ts +6 -6
  62. package/src/data-structures/graph/directed-graph.ts +4 -4
  63. package/src/data-structures/graph/undirected-graph.ts +2 -2
  64. package/src/data-structures/hash/hash-map.ts +3 -3
  65. package/src/data-structures/heap/heap.ts +3 -3
  66. package/src/data-structures/linked-list/doubly-linked-list.ts +9 -9
  67. package/src/data-structures/linked-list/singly-linked-list.ts +8 -8
  68. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  69. package/src/data-structures/matrix/matrix.ts +2 -2
  70. package/src/data-structures/matrix/navigator.ts +4 -4
  71. package/src/data-structures/queue/deque.ts +31 -31
  72. package/src/data-structures/queue/queue.ts +1 -1
  73. package/src/data-structures/stack/stack.ts +2 -2
  74. package/src/data-structures/trie/trie.ts +3 -3
  75. package/src/index.ts +2 -1
  76. package/src/interfaces/binary-tree.ts +3 -3
  77. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -5
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNKeyOrNodeOrEntry, Comparator, CP, DFSOrderPattern, IterationType, OptBSTN } from '../../types';
9
- import { BTNEntry } from '../../types';
8
+ import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNEntry, BTNKeyOrNodeOrEntry, BTNPredicate, Comparator, CP, DFSOrderPattern, IterationType, OptBSTN } from '../../types';
10
9
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
11
10
  import { IBinaryTree } from '../../interfaces';
12
11
  export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V>> extends BinaryTreeNode<K, V, NODE> {
@@ -50,13 +49,13 @@ export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE>
50
49
  export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>, TREE extends BST<K, V, R, NODE, TREE> = BST<K, V, R, NODE, BSTNested<K, V, R, NODE>>> extends BinaryTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
51
50
  /**
52
51
  * This is the constructor function for a Binary Search Tree class in TypeScript.
53
- * @param keysOrNodesOrEntriesOrRawElements - The `keysOrNodesOrEntriesOrRawElements` parameter is an
52
+ * @param keysOrNodesOrEntriesOrRaws - The `keysOrNodesOrEntriesOrRaws` parameter is an
54
53
  * iterable that can contain either keys, nodes, entries, or raw elements. These elements will be
55
54
  * added to the binary search tree during the construction of the object.
56
55
  * @param [options] - An optional object that contains additional options for the Binary Search Tree.
57
56
  * It can include a comparator function that defines the order of the elements in the tree.
58
57
  */
59
- constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: BSTOptions<K, V, R>);
58
+ constructor(keysOrNodesOrEntriesOrRaws?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: BSTOptions<K, V, R>);
60
59
  protected _root?: NODE;
61
60
  /**
62
61
  * The function returns the root node of a tree structure.
@@ -79,25 +78,25 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
79
78
  * following properties:
80
79
  * @returns a new instance of the BST class with the provided options.
81
80
  */
82
- createTree(options?: Partial<BSTOptions<K, V, R>>): TREE;
81
+ createTree(options?: BSTOptions<K, V, R>): TREE;
83
82
  /**
84
83
  * The function overrides a method and converts a key, value pair or entry or raw element to a node.
85
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of
84
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - A variable that can be of
86
85
  * type R or BTNKeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw
87
86
  * element.
88
87
  * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
89
88
  * value associated with a key in a key-value pair.
90
89
  * @returns either a NODE object or undefined.
91
90
  */
92
- keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): OptBSTN<NODE>;
91
+ keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V): OptBSTN<NODE>;
93
92
  /**
94
93
  * Time Complexity: O(log n)
95
94
  * Space Complexity: O(log n)
96
95
  *
97
96
  * The function ensures the existence of a node in a data structure and returns it, or undefined if
98
97
  * it doesn't exist.
99
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
100
- * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, which represents the key, node,
98
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
99
+ * `keyOrNodeOrEntryOrRaw` can accept a value of type `R`, which represents the key, node,
101
100
  * entry, or raw element that needs to be ensured in the tree.
102
101
  * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
103
102
  * parameter that specifies the type of iteration to be used when ensuring a node. It has a default
@@ -105,35 +104,43 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
105
104
  * @returns The method is returning either the node that was ensured or `undefined` if the node could
106
105
  * not be ensured.
107
106
  */
108
- ensureNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBSTN<NODE>;
107
+ ensureNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): OptBSTN<NODE>;
109
108
  /**
110
109
  * The function checks if the input is an instance of the BSTNode class.
111
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
112
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
113
- * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
110
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
111
+ * `keyOrNodeOrEntryOrRaw` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
112
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRaw` is
114
113
  * an instance of the `BSTNode` class.
115
114
  */
116
- isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
115
+ isNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R): keyOrNodeOrEntryOrRaw is NODE;
116
+ /**
117
+ * The function "override isKey" checks if a key is comparable based on a given comparator.
118
+ * @param {any} key - The `key` parameter is a value that will be checked to determine if it is of
119
+ * type `K`.
120
+ * @returns The `override isKey(key: any): key is K` function is returning a boolean value based on
121
+ * the result of the `isComparable` function with the condition `this.comparator !==
122
+ * this._DEFAULT_COMPARATOR`.
123
+ */
117
124
  isKey(key: any): key is K;
118
125
  /**
119
126
  * Time Complexity: O(log n)
120
127
  * Space Complexity: O(1)
121
128
  *
122
129
  * The `add` function in TypeScript adds a new node to a binary search tree based on the key value.
123
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
124
- * `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
130
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
131
+ * `keyOrNodeOrEntryOrRaw` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
125
132
  * @param {V} [value] - The `value` parameter is an optional value that can be associated with the
126
133
  * key in the binary search tree. If provided, it will be stored in the node along with the key.
127
134
  * @returns a boolean value.
128
135
  */
129
- add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
136
+ add(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V): boolean;
130
137
  /**
131
138
  * Time Complexity: O(k log n)
132
139
  * Space Complexity: O(k + log n)
133
140
  *
134
141
  * The `addMany` function in TypeScript adds multiple keys or nodes to a data structure and returns
135
142
  * an array indicating whether each key or node was successfully inserted.
136
- * @param keysOrNodesOrEntriesOrRawElements - An iterable containing keys, nodes, entries, or raw
143
+ * @param keysOrNodesOrEntriesOrRaws - An iterable containing keys, nodes, entries, or raw
137
144
  * elements to be added to the data structure.
138
145
  * @param [values] - An optional iterable of values to be associated with the keys or nodes being
139
146
  * added. If provided, the values will be assigned to the corresponding keys or nodes in the same
@@ -148,52 +155,52 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
148
155
  * @returns The function `addMany` returns an array of booleans indicating whether each element was
149
156
  * successfully inserted into the data structure.
150
157
  */
151
- addMany(keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
158
+ addMany(keysOrNodesOrEntriesOrRaws: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
152
159
  /**
153
160
  * Time Complexity: O(log n)
154
161
  * Space Complexity: O(k + log n)
155
162
  *
156
- * The `getNodes` function in TypeScript retrieves nodes from a binary tree based on a given
157
- * identifier and callback function.
158
- * @param {ReturnType<C> | undefined} identifier - The `identifier` parameter is the value that you
159
- * want to search for in the binary tree. It can be of any type that is returned by the callback
160
- * function.
161
- * @param {C} callback - The `callback` parameter is a function that takes a node as input and
162
- * returns a value. This value is used to identify the nodes that match the given identifier. The
163
- * `callback` function is optional and defaults to `this._DEFAULT_CALLBACK`.
164
- * @param [onlyOne=false] - A boolean value indicating whether to return only the first matching node
165
- * or all matching nodes. If set to true, only the first matching node will be returned. If set to
166
- * false, all matching nodes will be returned. The default value is false.
167
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
168
- * point for the search in the binary tree. It can be either a node object, a key-value pair, or an
169
- * entry object. If it is not provided, the `root` of the binary tree is used as the starting point.
170
- * @param {IterationType} iterationType - The `iterationType` parameter determines the type of
171
- * iteration to be performed. It can have two possible values:
172
- * @returns The method `getNodes` returns an array of `NODE` objects.
163
+ * The function `getNodes` in TypeScript overrides the base class method to retrieve nodes based on a
164
+ * given predicate and iteration type.
165
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>} predicate - The `predicate`
166
+ * parameter in the `getNodes` method is used to filter the nodes that will be returned. It can be a
167
+ * key, a node, an entry, or a custom predicate function that determines whether a node should be
168
+ * included in the result.
169
+ * @param [onlyOne=false] - The `onlyOne` parameter in the `getNodes` method is a boolean flag that
170
+ * determines whether to return only the first node that matches the predicate (`true`) or all nodes
171
+ * that match the predicate (`false`). If `onlyOne` is set to `true`, the method will stop iterating
172
+ * and
173
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} beginRoot - The `beginRoot` parameter in the
174
+ * `getNodes` method is used to specify the starting point for traversing the tree when searching for
175
+ * nodes that match a given predicate. It represents the root node of the subtree where the search
176
+ * should begin. If not explicitly provided, the default value for `begin
177
+ * @param {IterationType} iterationType - The `iterationType` parameter in the `getNodes` method
178
+ * specifies the type of iteration to be performed when traversing the nodes of a binary tree. It can
179
+ * have two possible values:
180
+ * @returns The `getNodes` method returns an array of nodes that satisfy the given predicate.
173
181
  */
174
- getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[];
182
+ getNodes(predicate: BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>, onlyOne?: boolean, beginRoot?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): NODE[];
175
183
  /**
176
184
  * Time Complexity: O(log n)
177
185
  * Space Complexity: O(1)
178
186
  *
179
- * The function `getNode` returns the first node that matches the given identifier and callback
180
- * function in a binary search tree.
181
- * @param {ReturnType<C> | undefined} identifier - The `identifier` parameter is the value that you
182
- * want to search for in the binary search tree. It can be of any type that is compatible with the
183
- * type returned by the callback function.
184
- * @param {C} callback - The `callback` parameter is a function that will be used to determine if a
185
- * node matches the desired criteria. It should be a function that takes a node as an argument and
186
- * returns a boolean value indicating whether the node matches the criteria or not. If no callback is
187
- * provided, the default callback will be
188
- * @param beginRoot - The `beginRoot` parameter is the starting point for the search in the binary
189
- * search tree. It can be either a key or a node. If it is a key, the search will start from the node
190
- * with that key. If it is a node, the search will start from that node.
191
- * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
192
- * of iteration to be performed when searching for nodes in the binary search tree. It can have one
193
- * of the following values:
194
- * @returns The method is returning a NODE object or undefined.
187
+ * This function retrieves a node based on a given predicate within a binary search tree structure.
188
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>} predicate - The `predicate`
189
+ * parameter can be of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, `R`, or `BTNPredicate<NODE>`.
190
+ * @param {R | BSTNKeyOrNode<K, NODE>} beginRoot - The `beginRoot` parameter in the `getNode` method
191
+ * is used to specify the starting point for searching nodes in the binary search tree. If no
192
+ * specific starting point is provided, the default value is set to `this._root`, which is the root
193
+ * node of the binary search tree.
194
+ * @param {IterationType} iterationType - The `iterationType` parameter in the `getNode` method is a
195
+ * parameter that specifies the type of iteration to be used. It has a default value of
196
+ * `this.iterationType`, which means it will use the iteration type defined in the class instance if
197
+ * no value is provided when calling the method.
198
+ * @returns The `getNode` method is returning an optional binary search tree node (`OptBSTN<NODE>`).
199
+ * It is using the `getNodes` method to find the node based on the provided predicate, beginning at
200
+ * the specified root node (`beginRoot`) and using the specified iteration type. The method then
201
+ * returns the first node found or `undefined` if no node is found.
195
202
  */
196
- getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): OptBSTN<NODE>;
203
+ getNode(predicate: BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): OptBSTN<NODE>;
197
204
  /**
198
205
  * Time Complexity: O(log n)
199
206
  * Space Complexity: O(1)
@@ -216,11 +223,11 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
216
223
  * the callback function.
217
224
  * @param {C} callback - The `callback` parameter is a function that will be called for each node
218
225
  * during the depth-first search traversal. It is an optional parameter and defaults to
219
- * `this._DEFAULT_CALLBACK`. The type `C` represents the type of the callback function.
226
+ * `this._DEFAULT_BTN_CALLBACK`. The type `C` represents the type of the callback function.
220
227
  * @param {DFSOrderPattern} [pattern=IN] - The "pattern" parameter in the code snippet refers to the
221
228
  * order in which the Depth-First Search (DFS) algorithm visits the nodes in a tree or graph. It can
222
229
  * take one of the following values:
223
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
230
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} beginRoot - The `beginRoot` parameter is the starting
224
231
  * point for the depth-first search traversal. It can be either a root node, a key-value pair, or a
225
232
  * node entry. If not specified, the default value is the root of the tree.
226
233
  * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter specifies the
@@ -228,7 +235,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
228
235
  * following values:
229
236
  * @returns The method is returning an array of the return type of the callback function.
230
237
  */
231
- dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
238
+ dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): ReturnType<C>[];
232
239
  /**
233
240
  * Time complexity: O(n)
234
241
  * Space complexity: O(n)
@@ -238,7 +245,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
238
245
  * @param {C} callback - The `callback` parameter is a function that will be called for each node
239
246
  * visited during the breadth-first search. It should take a single argument, which is the current
240
247
  * node being visited, and it can return a value of any type.
241
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
248
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} beginRoot - The `beginRoot` parameter is the starting
242
249
  * point for the breadth-first search. It can be either a root node, a key-value pair, or an entry
243
250
  * object. If no value is provided, the default value is the root of the tree.
244
251
  * @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
@@ -246,7 +253,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
246
253
  * the following values:
247
254
  * @returns an array of the return type of the callback function.
248
255
  */
249
- bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
256
+ bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): ReturnType<C>[];
250
257
  /**
251
258
  * Time complexity: O(n)
252
259
  * Space complexity: O(n)
@@ -256,7 +263,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
256
263
  * @param {C} callback - The `callback` parameter is a generic type `C` that extends
257
264
  * `BTNCallback<NODE>`. It represents a callback function that will be called for each node in the
258
265
  * tree during the iteration process.
259
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
266
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} beginRoot - The `beginRoot` parameter is the starting
260
267
  * point for listing the levels of the binary tree. It can be either a root node of the tree, a
261
268
  * key-value pair representing a node in the tree, or a key representing a node in the tree. If no
262
269
  * value is provided, the root of
@@ -265,7 +272,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
265
272
  * @returns The method is returning a two-dimensional array of the return type of the callback
266
273
  * function.
267
274
  */
268
- listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[][];
275
+ listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): ReturnType<C>[][];
269
276
  /**
270
277
  * Time complexity: O(n)
271
278
  * Space complexity: O(n)
@@ -278,7 +285,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
278
285
  * @param {CP} lesserOrGreater - The `lesserOrGreater` parameter is used to determine whether to
279
286
  * traverse nodes that are lesser, greater, or both than the `targetNode`. It accepts the values -1,
280
287
  * 0, or 1, where:
281
- * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in
288
+ * @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} targetNode - The `targetNode` parameter is the node in
282
289
  * the binary tree that you want to start traversing from. It can be specified either by providing
283
290
  * the key of the node, the node itself, or an entry containing the key and value of the node. If no
284
291
  * `targetNode` is provided,
@@ -287,7 +294,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
287
294
  * @returns The function `lesserOrGreaterTraverse` returns an array of values of type
288
295
  * `ReturnType<C>`, which is the return type of the callback function passed as an argument.
289
296
  */
290
- lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
297
+ lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): ReturnType<C>[];
291
298
  /**
292
299
  * Time complexity: O(n)
293
300
  * Space complexity: O(n)