data-structure-typed 1.54.2 → 1.54.3

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 (91) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/LICENSE +2 -2
  3. package/README.md +14 -1
  4. package/README_zh-CN.md +1 -1
  5. package/benchmark/report.html +4 -1
  6. package/benchmark/report.json +76 -17
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.d.ts +21 -20
  8. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js +8 -7
  9. package/dist/cjs/data-structures/binary-tree/avl-tree-counter.js.map +1 -1
  10. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -12
  11. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +2 -2
  12. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  13. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +25 -21
  14. package/dist/cjs/data-structures/binary-tree/avl-tree.js +12 -8
  15. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  16. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +111 -225
  17. package/dist/cjs/data-structures/binary-tree/binary-tree.js +177 -144
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  19. package/dist/cjs/data-structures/binary-tree/bst.d.ts +59 -53
  20. package/dist/cjs/data-structures/binary-tree/bst.js +75 -119
  21. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  22. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +18 -18
  23. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +6 -6
  24. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  25. package/dist/cjs/data-structures/binary-tree/tree-counter.d.ts +19 -19
  26. package/dist/cjs/data-structures/binary-tree/tree-counter.js +12 -12
  27. package/dist/cjs/data-structures/binary-tree/tree-counter.js.map +1 -1
  28. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +12 -12
  29. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +2 -2
  30. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  31. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -0
  32. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +1 -1
  33. package/dist/cjs/utils/utils.d.ts +2 -2
  34. package/dist/esm/data-structures/binary-tree/avl-tree-counter.d.ts +21 -20
  35. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js +9 -8
  36. package/dist/esm/data-structures/binary-tree/avl-tree-counter.js.map +1 -1
  37. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -12
  38. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +3 -3
  39. package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  40. package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +25 -21
  41. package/dist/esm/data-structures/binary-tree/avl-tree.js +13 -9
  42. package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -1
  43. package/dist/esm/data-structures/binary-tree/binary-tree.d.ts +111 -225
  44. package/dist/esm/data-structures/binary-tree/binary-tree.js +181 -148
  45. package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -1
  46. package/dist/esm/data-structures/binary-tree/bst.d.ts +59 -53
  47. package/dist/esm/data-structures/binary-tree/bst.js +76 -120
  48. package/dist/esm/data-structures/binary-tree/bst.js.map +1 -1
  49. package/dist/esm/data-structures/binary-tree/red-black-tree.d.ts +18 -18
  50. package/dist/esm/data-structures/binary-tree/red-black-tree.js +7 -7
  51. package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -1
  52. package/dist/esm/data-structures/binary-tree/tree-counter.d.ts +19 -19
  53. package/dist/esm/data-structures/binary-tree/tree-counter.js +13 -13
  54. package/dist/esm/data-structures/binary-tree/tree-counter.js.map +1 -1
  55. package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +12 -12
  56. package/dist/esm/data-structures/binary-tree/tree-multi-map.js +3 -3
  57. package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  58. package/dist/esm/types/data-structures/binary-tree/binary-tree.d.ts +1 -0
  59. package/dist/esm/types/data-structures/binary-tree/bst.d.ts +1 -1
  60. package/dist/esm/utils/utils.d.ts +2 -2
  61. package/dist/umd/data-structure-typed.js +296 -279
  62. package/dist/umd/data-structure-typed.min.js +5 -12
  63. package/dist/umd/data-structure-typed.min.js.map +1 -1
  64. package/package.json +7 -7
  65. package/src/data-structures/binary-tree/avl-tree-counter.ts +30 -23
  66. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +25 -15
  67. package/src/data-structures/binary-tree/avl-tree.ts +35 -29
  68. package/src/data-structures/binary-tree/binary-tree.ts +469 -252
  69. package/src/data-structures/binary-tree/bst.ts +141 -143
  70. package/src/data-structures/binary-tree/red-black-tree.ts +27 -35
  71. package/src/data-structures/binary-tree/tree-counter.ts +33 -27
  72. package/src/data-structures/binary-tree/tree-multi-map.ts +25 -17
  73. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -0
  74. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  75. package/src/utils/utils.ts +2 -2
  76. package/test/integration/compile.mjs +21 -21
  77. package/test/performance/data-structures/binary-tree/avl-tree.test.mjs +71 -0
  78. package/test/performance/data-structures/binary-tree/red-black-tree.test.mjs +81 -0
  79. package/test/performance/{reportor.js → reportor.mjs} +264 -8
  80. package/test/performance/reportor.ts +1 -1
  81. package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +7 -7
  82. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +4 -5
  83. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +72 -5
  84. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +132 -82
  85. package/test/unit/data-structures/binary-tree/bst.test.ts +12 -12
  86. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +4 -12
  87. package/test/unit/data-structures/binary-tree/tree-counter.test.ts +4 -4
  88. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +5 -5
  89. package/test/utils/json2html.ts +0 -154
  90. package/test/performance/data-structures/binary-tree/avl-tree.test.js +0 -45
  91. /package/test/performance/data-structures/binary-tree/{rb-tree.test.ts → red-black-tree.test.ts} +0 -0
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeDeleteResult, BinaryTreeOptions, BinaryTreePrintOptions, BTNEntry, BTNRep, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodeDisplayLayout, NodePredicate, OptNodeOrNull, RBTNColor, ToEntryFn } from '../../types';
8
+ import type { BinaryTreeDeleteResult, BinaryTreeOptions, BinaryTreePrintOptions, BTNEntry, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodeDisplayLayout, NodePredicate, OptNodeOrNull, RBTNColor, ToEntryFn } from '../../types';
9
9
  import { IBinaryTree } from '../../interfaces';
10
10
  import { IterableEntryBase } from '../base';
11
11
  import { Range } from '../../common';
@@ -15,6 +15,9 @@ import { Range } from '../../common';
15
15
  * @template BinaryTreeNode<K, V> - The type of the family relationship in the binary tree.
16
16
  */
17
17
  export declare class BinaryTreeNode<K = any, V = any> {
18
+ key: K;
19
+ value?: V;
20
+ parent?: BinaryTreeNode<K, V>;
18
21
  /**
19
22
  * The constructor function initializes an object with a key and an optional value in TypeScript.
20
23
  * @param {K} key - The `key` parameter in the constructor function is used to store the key value
@@ -24,15 +27,12 @@ export declare class BinaryTreeNode<K = any, V = any> {
24
27
  * default to `undefined`.
25
28
  */
26
29
  constructor(key: K, value?: V);
27
- key: K;
28
- value?: V;
29
- parent?: BinaryTreeNode<K, V>;
30
- _left?: OptNodeOrNull<BinaryTreeNode<K, V>>;
31
- get left(): OptNodeOrNull<BinaryTreeNode<K, V>>;
32
- set left(v: OptNodeOrNull<BinaryTreeNode<K, V>>);
33
- _right?: OptNodeOrNull<BinaryTreeNode<K, V>>;
34
- get right(): OptNodeOrNull<BinaryTreeNode<K, V>>;
35
- set right(v: OptNodeOrNull<BinaryTreeNode<K, V>>);
30
+ _left?: BinaryTreeNode<K, V> | null | undefined;
31
+ get left(): BinaryTreeNode<K, V> | null | undefined;
32
+ set left(v: BinaryTreeNode<K, V> | null | undefined);
33
+ _right?: BinaryTreeNode<K, V> | null | undefined;
34
+ get right(): BinaryTreeNode<K, V> | null | undefined;
35
+ set right(v: BinaryTreeNode<K, V> | null | undefined);
36
36
  _height: number;
37
37
  get height(): number;
38
38
  set height(value: number);
@@ -52,23 +52,25 @@ export declare class BinaryTreeNode<K = any, V = any> {
52
52
  * 5. Leaf Nodes: Nodes without children are leaves.
53
53
  */
54
54
  export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, R, MK, MV, MR> {
55
+ iterationType: IterationType;
55
56
  /**
56
57
  * This TypeScript constructor function initializes a binary tree with optional options and adds
57
58
  * elements based on the provided input.
58
59
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
59
- * iterable that can contain either objects of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. It
60
+ * iterable that can contain either objects of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. It
60
61
  * is used to initialize the binary tree with keys, nodes, entries, or raw data.
61
62
  * @param [options] - The `options` parameter in the constructor is an optional object that can
62
63
  * contain the following properties:
63
64
  */
64
- constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, BinaryTreeNode<K, V>> | R>, options?: BinaryTreeOptions<K, V, R>);
65
- iterationType: IterationType;
65
+ constructor(keysNodesEntriesOrRaws?: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: BinaryTreeOptions<K, V, R>);
66
66
  protected _isMapMode: boolean;
67
67
  get isMapMode(): boolean;
68
+ protected _isDuplicate: boolean;
69
+ get isDuplicate(): boolean;
68
70
  protected _store: Map<K, V | undefined>;
69
71
  get store(): Map<K, V | undefined>;
70
- protected _root?: OptNodeOrNull<BinaryTreeNode<K, V>>;
71
- get root(): OptNodeOrNull<BinaryTreeNode<K, V>>;
72
+ protected _root?: BinaryTreeNode<K, V> | null | undefined;
73
+ get root(): BinaryTreeNode<K, V> | null | undefined;
72
74
  protected _size: number;
73
75
  get size(): number;
74
76
  protected _NIL: BinaryTreeNode<K, V>;
@@ -106,8 +108,8 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
106
108
  *
107
109
  * The function `ensureNode` in TypeScript checks if a given input is a node, entry, key, or raw
108
110
  * value and returns the corresponding node or null.
109
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
110
- * parameter in the `ensureNode` function can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. It
111
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `keyNodeOrEntry`
112
+ * parameter in the `ensureNode` function can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. It
111
113
  * is used to determine whether the input is a key, node, entry, or raw data. The
112
114
  * @param {IterationType} iterationType - The `iterationType` parameter in the `ensureNode` function
113
115
  * is used to specify the type of iteration to be performed. It has a default value of
@@ -115,13 +117,13 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
115
117
  * @returns The `ensureNode` function returns either a node, `null`, or `undefined` based on the
116
118
  * conditions specified in the code snippet.
117
119
  */
118
- ensureNode(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): OptNodeOrNull<BinaryTreeNode<K, V>>;
120
+ ensureNode(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeNode<K, V> | null | undefined;
119
121
  /**
120
122
  * Time Complexity: O(1)
121
123
  * Space Complexity: O(1)
122
124
  *
123
125
  * The function isNode checks if the input is an instance of BinaryTreeNode.
124
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The parameter
126
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
125
127
  * `keyNodeOrEntry` can be either a key, a node, an entry, or raw data. The function is
126
128
  * checking if the input is an instance of a `BinaryTreeNode` and returning a boolean value
127
129
  * accordingly.
@@ -130,99 +132,99 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
130
132
  * it is not an instance of `BinaryTreeNode`, the function returns `false`, indicating that the input
131
133
  * is not a node.
132
134
  */
133
- isNode(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): keyNodeOrEntry is BinaryTreeNode<K, V>;
135
+ isNode(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is BinaryTreeNode<K, V>;
134
136
  /**
135
137
  * Time Complexity: O(1)
136
138
  * Space Complexity: O(1)
137
139
  *
138
140
  * The function `isRaw` checks if the input parameter is of type `R` by verifying if it is an object.
139
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | R} keyNodeEntryOrRaw - BTNRep<K, V, BinaryTreeNode<K, V>>
141
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R} keyNodeEntryOrRaw - K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined
140
142
  * @returns The function `isRaw` is checking if the `keyNodeEntryOrRaw` parameter is of type `R` by
141
143
  * checking if it is an object. If the parameter is an object, the function will return `true`,
142
144
  * indicating that it is of type `R`.
143
145
  */
144
- isRaw(keyNodeEntryOrRaw: BTNRep<K, V, BinaryTreeNode<K, V>> | R): keyNodeEntryOrRaw is R;
146
+ isRaw(keyNodeEntryOrRaw: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R): keyNodeEntryOrRaw is R;
145
147
  /**
146
148
  * Time Complexity: O(1)
147
149
  * Space Complexity: O(1)
148
150
  *
149
151
  * The function `isRealNode` checks if a given input is a valid node in a binary tree.
150
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
151
- * parameter in the `isRealNode` function can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`.
152
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `keyNodeOrEntry`
153
+ * parameter in the `isRealNode` function can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`.
152
154
  * The function checks if the input parameter is a `BinaryTreeNode<K, V>` type by verifying if it is not equal
153
155
  * @returns The function `isRealNode` is checking if the input `keyNodeOrEntry` is a valid
154
156
  * node by comparing it to `this._NIL`, `null`, and `undefined`. If the input is not one of these
155
157
  * values, it then calls the `isNode` method to further determine if the input is a node. The
156
158
  * function will return a boolean value indicating whether the
157
159
  */
158
- isRealNode(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): keyNodeOrEntry is BinaryTreeNode<K, V>;
160
+ isRealNode(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is BinaryTreeNode<K, V>;
159
161
  /**
160
162
  * Time Complexity: O(1)
161
163
  * Space Complexity: O(1)
162
164
  *
163
165
  * The function checks if a given input is a valid node or null.
164
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The parameter
166
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
165
167
  * `keyNodeOrEntry` in the `isRealNodeOrNull` function can be of type `BTNRep<K,
166
168
  * V, BinaryTreeNode<K, V>>` or `R`. It is a union type that can either be a key, a node, an entry, or
167
169
  * @returns The function `isRealNodeOrNull` is returning a boolean value. It checks if the input
168
170
  * `keyNodeOrEntry` is either `null` or a real node, and returns `true` if it is a node or
169
171
  * `null`, and `false` otherwise.
170
172
  */
171
- isRealNodeOrNull(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
173
+ isRealNodeOrNull(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
172
174
  /**
173
175
  * Time Complexity: O(1)
174
176
  * Space Complexity: O(1)
175
177
  *
176
178
  * The function isNIL checks if a given key, node, entry, or raw value is equal to the _NIL value.
177
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - BTNRep<K, V,
179
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - BTNRep<K, V,
178
180
  * BinaryTreeNode<K, V>>
179
181
  * @returns The function is checking if the `keyNodeOrEntry` parameter is equal to the `_NIL`
180
182
  * property of the current object and returning a boolean value based on that comparison.
181
183
  */
182
- isNIL(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): boolean;
184
+ isNIL(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): boolean;
183
185
  /**
184
186
  * Time Complexity: O(1)
185
187
  * Space Complexity: O(1)
186
188
  *
187
189
  * The function `isRange` checks if the input parameter is an instance of the `Range` class.
188
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>> | Range<K>}
189
- * keyNodeEntryOrPredicate - The `keyNodeEntryOrPredicate` parameter in the `isRange` function can be
190
- * of type `BTNRep<K, V, BinaryTreeNode<K, V>>`, `NodePredicate<BinaryTreeNode<K, V>>`, or
190
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>> | Range<K>} keyNodeEntryOrPredicate
191
+ * - The `keyNodeEntryOrPredicate` parameter in the `isRange` function can be
192
+ * of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `, `NodePredicate<BinaryTreeNode<K, V>>`, or
191
193
  * `Range<K>`. The function checks if the `keyNodeEntry
192
194
  * @returns The `isRange` function is checking if the `keyNodeEntryOrPredicate` parameter is an
193
195
  * instance of the `Range` class. If it is an instance of `Range`, the function will return `true`,
194
196
  * indicating that the parameter is a `Range<K>`. If it is not an instance of `Range`, the function
195
197
  * will return `false`.
196
198
  */
197
- isRange(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>> | Range<K>): keyNodeEntryOrPredicate is Range<K>;
199
+ isRange(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>> | Range<K>): keyNodeEntryOrPredicate is Range<K>;
198
200
  /**
199
201
  * Time Complexity: O(1)
200
202
  * Space Complexity: O(1)
201
203
  *
202
204
  * The function determines whether a given key, node, entry, or raw data is a leaf node in a binary
203
205
  * tree.
204
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The parameter
205
- * `keyNodeOrEntry` can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. It represents a
206
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The parameter
207
+ * `keyNodeOrEntry` can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. It represents a
206
208
  * key, node, entry, or raw data in a binary tree structure. The function `isLeaf` checks whether the
207
209
  * provided
208
210
  * @returns The function `isLeaf` returns a boolean value indicating whether the input
209
211
  * `keyNodeOrEntry` is a leaf node in a binary tree.
210
212
  */
211
- isLeaf(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): boolean;
213
+ isLeaf(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): boolean;
212
214
  /**
213
215
  * Time Complexity: O(1)
214
216
  * Space Complexity: O(1)
215
217
  *
216
218
  * The function `isEntry` checks if the input is a BTNEntry object by verifying if it is an array
217
219
  * with a length of 2.
218
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `keyNodeOrEntry`
219
- * parameter in the `isEntry` function can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or type `R`.
220
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `keyNodeOrEntry`
221
+ * parameter in the `isEntry` function can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or type `R`.
220
222
  * The function checks if the provided `keyNodeOrEntry` is of type `BTN
221
223
  * @returns The `isEntry` function is checking if the `keyNodeOrEntry` parameter is an array
222
224
  * with a length of 2. If it is, then it returns `true`, indicating that the parameter is of type
223
225
  * `BTNEntry<K, V>`. If the condition is not met, it returns `false`.
224
226
  */
225
- isEntry(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): keyNodeOrEntry is BTNEntry<K, V>;
227
+ isEntry(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is BTNEntry<K, V>;
226
228
  /**
227
229
  * Time Complexity O(1)
228
230
  * Space Complexity O(1)
@@ -241,7 +243,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
241
243
  *
242
244
  * The `add` function in TypeScript adds a new node to a binary tree while handling duplicate keys
243
245
  * and finding the correct insertion position.
244
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `add` method you provided
246
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `add` method you provided
245
247
  * seems to be for adding a new node to a binary tree structure. The `keyNodeOrEntry`
246
248
  * parameter in the method can accept different types of values:
247
249
  * @param {V} [value] - The `value` parameter in the `add` method represents the value associated
@@ -252,7 +254,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
252
254
  * node was successful, and `false` if the insertion position could not be found or if a duplicate
253
255
  * key was found and the node was replaced instead of inserted.
254
256
  */
255
- add(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>, value?: V): boolean;
257
+ add(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
256
258
  /**
257
259
  * Time Complexity: O(k * n)
258
260
  * Space Complexity: O(k)
@@ -262,7 +264,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
262
264
  * each insertion was successful.
263
265
  * @param keysNodesEntriesOrRaws - `keysNodesEntriesOrRaws` is an iterable that can contain a
264
266
  * mix of keys, nodes, entries, or raw values. Each element in this iterable can be of type
265
- * `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`.
267
+ * `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`.
266
268
  * @param [values] - The `values` parameter in the `addMany` function is an optional parameter that
267
269
  * accepts an iterable of values. These values correspond to the keys or nodes being added in the
268
270
  * `keysNodesEntriesOrRaws` parameter. If provided, the function will iterate over the values and
@@ -271,7 +273,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
271
273
  * node, entry, or raw value was successfully added to the data structure. Each boolean value
272
274
  * corresponds to the success of adding the corresponding key or value in the input iterable.
273
275
  */
274
- addMany(keysNodesEntriesOrRaws: Iterable<BTNRep<K, V, BinaryTreeNode<K, V>> | R>, values?: Iterable<V | undefined>): boolean[];
276
+ addMany(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): boolean[];
275
277
  /**
276
278
  * Time Complexity: O(k * n)
277
279
  * Space Complexity: O(1)
@@ -288,19 +290,19 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
288
290
  * The `refill` function clears the existing data structure and then adds new key-value pairs based
289
291
  * on the provided input.
290
292
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the `refill`
291
- * method can accept an iterable containing a mix of `BTNRep<K, V, BinaryTreeNode<K, V>>` objects or `R`
293
+ * method can accept an iterable containing a mix of `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` objects or `R`
292
294
  * objects.
293
295
  * @param [values] - The `values` parameter in the `refill` method is an optional parameter that
294
296
  * accepts an iterable of values of type `V` or `undefined`.
295
297
  */
296
- refill(keysNodesEntriesOrRaws: Iterable<BTNRep<K, V, BinaryTreeNode<K, V>> | R>, values?: Iterable<V | undefined>): void;
298
+ refill(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): void;
297
299
  /**
298
300
  * Time Complexity: O(n)
299
301
  * Space Complexity: O(1)
300
302
  *
301
303
  * The function `delete` in TypeScript implements the deletion of a node in a binary tree and returns
302
304
  * the deleted node along with information for tree balancing.
303
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry
305
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry
304
306
  * - The `delete` method you provided is used to delete a node from a binary tree based on the key,
305
307
  * node, entry or raw data. The method returns an array of
306
308
  * `BinaryTreeDeleteResult` objects containing information about the deleted node and whether
@@ -309,22 +311,22 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
309
311
  * the array contains information about the node that was deleted (`deleted`) and the node that may
310
312
  * need to be balanced (`needBalanced`).
311
313
  */
312
- delete(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
314
+ delete(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
313
315
  /**
314
316
  * Time Complexity: O(n)
315
317
  * Space Complexity: O(k + log n)
316
318
  *
317
319
  * The `search` function in TypeScript performs a depth-first or breadth-first search on a tree
318
320
  * structure based on a given predicate or key, with options to return multiple results or just one.
319
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate - The
321
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate - The
320
322
  * `keyNodeEntryOrPredicate` parameter in the `search` function can accept three types of values:
321
323
  * @param [onlyOne=false] - The `onlyOne` parameter in the `search` function is a boolean flag that
322
324
  * determines whether the search should stop after finding the first matching node. If `onlyOne` is
323
325
  * set to `true`, the search will return as soon as a matching node is found. If `onlyOne` is
324
326
  * @param {C} callback - The `callback` parameter in the `search` function is a callback function
325
327
  * that will be called on each node that matches the search criteria. It is of type `C`, which
326
- * extends `NodeCallback<BinaryTreeNode<K, V>>`. The default value for `callback` is `this._DEFAULT_NODE_CALLBACK` if
327
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `search` function is
328
+ * extends `NodeCallback<BinaryTreeNode<K, V> | null>`. The default value for `callback` is `this._DEFAULT_NODE_CALLBACK` if
329
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the `search` function is
328
330
  * used to specify the node from which the search operation should begin. It represents the starting
329
331
  * point in the binary tree where the search will be performed. If no specific `startNode` is
330
332
  * provided, the search operation will start from the root
@@ -334,39 +336,18 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
334
336
  * @returns The `search` function returns an array of values that match the provided criteria based
335
337
  * on the search algorithm implemented within the function.
336
338
  */
337
- search<C extends NodeCallback<BinaryTreeNode<K, V>>>(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>, onlyOne?: boolean, callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>[];
338
- /**
339
- * Time Complexity: O(n)
340
- * Space Complexity: O(k + log n)
341
- *
342
- * The function `getNodes` retrieves nodes from a binary tree based on a key, node, entry, raw data,
343
- * or predicate, with options for recursive or iterative traversal.
344
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
345
- * - The `getNodes` function you provided takes several parameters:
346
- * @param [onlyOne=false] - The `onlyOne` parameter in the `getNodes` function is a boolean flag that
347
- * determines whether to return only the first node that matches the criteria specified by the
348
- * `keyNodeEntryOrPredicate` parameter. If `onlyOne` is set to `true`, the function will
349
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
350
- * `getNodes` function is used to specify the starting point for traversing the binary tree. It
351
- * represents the root node of the binary tree or the node from which the traversal should begin. If
352
- * not provided, the default value is set to `this._root
353
- * @param {IterationType} iterationType - The `iterationType` parameter in the `getNodes` function
354
- * determines the type of iteration to be performed when traversing the nodes of a binary tree. It
355
- * can have two possible values:
356
- * @returns The `getNodes` function returns an array of nodes that satisfy the provided condition
357
- * based on the input parameters and the iteration type specified.
358
- */
359
- getNodes(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>, onlyOne?: boolean, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): BinaryTreeNode<K, V>[];
339
+ search<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V> | null>, onlyOne?: boolean, callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
340
+ getNodes(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>, onlyOne?: boolean, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeNode<K, V>[];
360
341
  /**
361
342
  * Time Complexity: O(n)
362
343
  * Space Complexity: O(log n)
363
344
  *
364
345
  * The `getNode` function retrieves a node based on the provided key, node, entry, raw data, or
365
346
  * predicate.
366
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
347
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
367
348
  * - The `keyNodeEntryOrPredicate` parameter in the `getNode` function can accept a key,
368
349
  * node, entry, raw data, or a predicate function.
369
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
350
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
370
351
  * `getNode` function is used to specify the starting point for searching for a node in a binary
371
352
  * tree. If no specific starting point is provided, the default value is set to `this._root`, which
372
353
  * is typically the root node of the binary tree.
@@ -377,17 +358,17 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
377
358
  * @returns The `getNode` function is returning the first node that matches the specified criteria,
378
359
  * or `null` if no matching node is found.
379
360
  */
380
- getNode(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): OptNodeOrNull<BinaryTreeNode<K, V>>;
361
+ getNode(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V> | null>, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeNode<K, V> | null | undefined;
381
362
  /**
382
363
  * Time Complexity: O(n)
383
364
  * Space Complexity: O(log n)
384
365
  *
385
366
  * This function overrides the `get` method to retrieve the value associated with a specified key,
386
367
  * node, entry, raw data, or predicate in a data structure.
387
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
368
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
388
369
  * - The `keyNodeEntryOrPredicate` parameter in the `get` method can accept one of the
389
370
  * following types:
390
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `get`
371
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the `get`
391
372
  * method is used to specify the starting point for searching for a key or node in the binary tree.
392
373
  * If no specific starting point is provided, the default starting point is the root of the binary
393
374
  * tree (`this._root`).
@@ -400,29 +381,8 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
400
381
  * the method returns the corresponding value. If the key or node is not found, it returns
401
382
  * `undefined`.
402
383
  */
403
- get(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>>, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): V | undefined;
404
- /**
405
- * Time Complexity: O(n)
406
- * Space Complexity: O(log n)
407
- *
408
- * The `has` function in TypeScript checks if a specified key, node, entry, raw data, or predicate
409
- * exists in the data structure.
410
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate
411
- * - The `keyNodeEntryOrPredicate` parameter in the `override has` method can accept one of
412
- * the following types:
413
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
414
- * `override` method is used to specify the starting point for the search operation within the data
415
- * structure. It defaults to `this._root` if not provided explicitly.
416
- * @param {IterationType} iterationType - The `iterationType` parameter in the `override has` method
417
- * is used to specify the type of iteration to be performed. It has a default value of
418
- * `this.iterationType`, which means it will use the iteration type defined in the current context if
419
- * no value is provided when calling the method.
420
- * @returns The `override has` method is returning a boolean value. It checks if there are any nodes
421
- * that match the provided key, node, entry, raw data, or predicate in the tree structure. If there
422
- * are matching nodes, it returns `true`, indicating that the tree contains the specified element.
423
- * Otherwise, it returns `false`.
424
- */
425
- has(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): boolean;
384
+ get(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): V | undefined;
385
+ has(keyNodeEntryOrPredicate?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): boolean;
426
386
  /**
427
387
  * Time Complexity: O(1)
428
388
  * Space Complexity: O(1)
@@ -446,7 +406,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
446
406
  *
447
407
  * The function checks if a binary tree is perfectly balanced by comparing its minimum height with
448
408
  * its height.
449
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter is the starting
409
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter is the starting
450
410
  * point for checking if the binary tree is perfectly balanced. It represents the root node of the
451
411
  * binary tree or a specific node from which the balance check should begin.
452
412
  * @returns The method `isPerfectlyBalanced` is returning a boolean value, which indicates whether
@@ -455,14 +415,14 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
455
415
  * height plus 1 is greater than or equal to the height of the tree, then it is considered perfectly
456
416
  * balanced and
457
417
  */
458
- isPerfectlyBalanced(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>): boolean;
418
+ isPerfectlyBalanced(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): boolean;
459
419
  /**
460
420
  * Time Complexity: O(n)
461
421
  * Space Complexity: O(log n)
462
422
  *
463
423
  * The function `isBST` in TypeScript checks if a binary search tree is valid using either recursive
464
424
  * or iterative methods.
465
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `isBST`
425
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the `isBST`
466
426
  * function represents the starting point for checking whether a binary search tree (BST) is valid.
467
427
  * It can be a node in the BST or a reference to the root of the BST. If no specific node is
468
428
  * provided, the function will default to
@@ -474,16 +434,16 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
474
434
  * the tree satisfies the BST property, where for every node, all nodes in its left subtree have keys
475
435
  * less than the node's key, and all nodes in its right subtree have keys greater than the node's
476
436
  */
477
- isBST(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): boolean;
437
+ isBST(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): boolean;
478
438
  /**
479
439
  * Time Complexity: O(n)
480
440
  * Space Complexity: O(log n)
481
441
  *
482
442
  * The `getDepth` function calculates the depth between two nodes in a binary tree.
483
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} dist - The `dist` parameter in the `getDepth`
443
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } dist - The `dist` parameter in the `getDepth`
484
444
  * function represents the node or entry in a binary tree map, or a reference to a node in the tree.
485
445
  * It is the target node for which you want to calculate the depth from the `startNode` node.
486
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
446
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
487
447
  * `getDepth` function represents the starting point from which you want to calculate the depth of a
488
448
  * given node or entry in a binary tree. If no specific starting point is provided, the default value
489
449
  * for `startNode` is set to the root of the binary
@@ -491,14 +451,14 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
491
451
  * `startNode` node in a binary tree. If the `dist` node is not found in the path to the `startNode`
492
452
  * node, it returns the depth of the `dist` node from the root of the tree.
493
453
  */
494
- getDepth(dist: BTNRep<K, V, BinaryTreeNode<K, V>>, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>): number;
454
+ getDepth(dist: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): number;
495
455
  /**
496
456
  * Time Complexity: O(n)
497
457
  * Space Complexity: O(log n)
498
458
  *
499
459
  * The `getHeight` function calculates the maximum height of a binary tree using either a recursive
500
460
  * or iterative approach in TypeScript.
501
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter is the starting
461
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter is the starting
502
462
  * point from which the height of the binary tree will be calculated. It can be a node in the binary
503
463
  * tree or a reference to the root of the tree. If not provided, it defaults to the root of the
504
464
  * binary tree data structure.
@@ -509,14 +469,14 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
509
469
  * root node. The height is calculated based on the maximum depth of the tree, considering either a
510
470
  * recursive approach or an iterative approach depending on the `iterationType` parameter.
511
471
  */
512
- getHeight(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): number;
472
+ getHeight(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): number;
513
473
  /**
514
474
  * Time Complexity: O(n)
515
475
  * Space Complexity: O(log n)
516
476
  *
517
477
  * The `getMinHeight` function calculates the minimum height of a binary tree using either a
518
478
  * recursive or iterative approach in TypeScript.
519
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
479
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
520
480
  * `getMinHeight` function represents the starting node from which the minimum height of the binary
521
481
  * tree will be calculated. It is either a node in the binary tree or a reference to the root of the
522
482
  * tree. If not provided, the default value is the root
@@ -528,7 +488,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
528
488
  * leaf node in the tree. The method uses either a recursive approach or an iterative approach (using
529
489
  * a stack) based on the `iterationType` parameter.
530
490
  */
531
- getMinHeight(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): number;
491
+ getMinHeight(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): number;
532
492
  /**
533
493
  * Time Complexity: O(log n)
534
494
  * Space Complexity: O(log n)
@@ -539,7 +499,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
539
499
  * the path to the root. It is expected to be a function that takes a node as an argument and returns
540
500
  * a value based on that node. The return type of the callback function is determined by the generic
541
501
  * type `C
542
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} beginNode - The `beginNode` parameter in the
502
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } beginNode - The `beginNode` parameter in the
543
503
  * `getPathToRoot` function can be either a key, a node, an entry, or any other value of type `R`.
544
504
  * @param [isReverse=true] - The `isReverse` parameter in the `getPathToRoot` function determines
545
505
  * whether the resulting path from the given `beginNode` to the root should be in reverse order or
@@ -549,7 +509,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
549
509
  * array is either in reverse order or in the original order based on the value of the `isReverse`
550
510
  * parameter.
551
511
  */
552
- getPathToRoot<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(beginNode: BTNRep<K, V, BinaryTreeNode<K, V>>, callback?: C, isReverse?: boolean): ReturnType<C>[];
512
+ getPathToRoot<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(beginNode: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, callback?: C, isReverse?: boolean): ReturnType<C>[];
553
513
  /**
554
514
  * Time Complexity: O(log n)
555
515
  * Space Complexity: O(log n)
@@ -559,7 +519,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
559
519
  * @param {C} callback - The `callback` parameter is a function that will be called with the leftmost
560
520
  * node of a binary tree or with `undefined` if the tree is empty. It is provided with a default
561
521
  * value of `_DEFAULT_NODE_CALLBACK` if not specified.
562
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
522
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
563
523
  * `getLeftMost` function represents the starting point for finding the leftmost node in a binary
564
524
  * tree. It can be either a key, a node, or an entry in the binary tree structure. If no specific
565
525
  * starting point is provided, the function will default
@@ -571,7 +531,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
571
531
  * `NIL`, it returns the result of the callback function applied to `undefined`. If the `startNode`
572
532
  * node is not a real node, it returns the result of the callback
573
533
  */
574
- getLeftMost<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>;
534
+ getLeftMost<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>;
575
535
  /**
576
536
  * Time Complexity: O(log n)
577
537
  * Space Complexity: O(log n)
@@ -582,7 +542,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
582
542
  * of finding the rightmost node in a binary tree. It is of type `NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>`,
583
543
  * which means it is a callback function that can accept either an optional binary tree node or null
584
544
  * as
585
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
545
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
586
546
  * `getRightMost` function represents the starting point for finding the rightmost node in a binary
587
547
  * tree. It can be either a key, a node, or an entry in the binary tree structure. If no specific
588
548
  * starting point is provided, the function will default
@@ -594,7 +554,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
594
554
  * the binary tree structure, determined based on the specified iteration type ('RECURSIVE' or
595
555
  * other).
596
556
  */
597
- getRightMost<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>;
557
+ getRightMost<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>;
598
558
  /**
599
559
  * Time Complexity: O(log n)
600
560
  * Space Complexity: O(log n)
@@ -622,11 +582,11 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
622
582
  * have a right child, the function traverses up the parent nodes until it finds a node that is not
623
583
  * the right child of its parent, and returns that node
624
584
  */
625
- getSuccessor(x?: K | BinaryTreeNode<K, V> | null): OptNodeOrNull<BinaryTreeNode<K, V>>;
626
- dfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, pattern?: DFSOrderPattern, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>[];
627
- dfs<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, pattern?: DFSOrderPattern, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: boolean): ReturnType<C>[];
628
- bfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
629
- bfs<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
585
+ getSuccessor(x?: K | BinaryTreeNode<K, V> | null): BinaryTreeNode<K, V> | null | undefined;
586
+ dfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, pattern?: DFSOrderPattern, onlyOne?: boolean, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
587
+ dfs<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, pattern?: DFSOrderPattern, onlyOne?: boolean, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: boolean): ReturnType<C>[];
588
+ bfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
589
+ bfs<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
630
590
  /**
631
591
  * Time complexity: O(n)
632
592
  * Space complexity: O(n)
@@ -635,7 +595,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
635
595
  * structure based on a specified callback and iteration type.
636
596
  * @param {C} callback - The `callback` parameter is a function that will be called on each leaf node
637
597
  * in the binary tree. It is optional and defaults to a default callback function if not provided.
638
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `leaves`
598
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the `leaves`
639
599
  * method is used to specify the starting point for finding and processing the leaves of a binary
640
600
  * tree. It can be provided as either a key, a node, or an entry in the binary tree structure. If not
641
601
  * explicitly provided, the default value
@@ -645,30 +605,10 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
645
605
  * @returns The `leaves` method returns an array of values that are the result of applying the
646
606
  * provided callback function to each leaf node in the binary tree.
647
607
  */
648
- leaves<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType): ReturnType<C>[];
649
- listLevels<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
650
- listLevels<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
651
- /**
652
- * Time complexity: O(n)
653
- * Space complexity: O(n)
654
- *
655
- * The `morris` function in TypeScript performs a Depth-First Search traversal on a binary tree using
656
- * Morris Traversal algorithm with different order patterns.
657
- * @param {C} callback - The `callback` parameter in the `morris` function is a function that will be
658
- * called on each node in the binary tree during the traversal. It is of type `C`, which extends the
659
- * `NodeCallback<BinaryTreeNode<K, V>>` type. The default value for `callback` is `this._DEFAULT
660
- * @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter in the `morris` function specifies
661
- * the type of Depth-First Search (DFS) order pattern to traverse the binary tree. The possible
662
- * values for the `pattern` parameter are:
663
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `morris`
664
- * function is the starting point for the Morris traversal algorithm. It represents the root node of
665
- * the binary tree or the node from which the traversal should begin. It can be provided as either a
666
- * key, a node, an entry, or a reference
667
- * @returns The `morris` function is returning an array of values that are the result of applying the
668
- * provided callback function to each node in the binary tree in the specified order pattern (IN,
669
- * PRE, or POST).
670
- */
671
- morris<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, pattern?: DFSOrderPattern, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>): ReturnType<C>[];
608
+ leaves<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): ReturnType<C>[];
609
+ listLevels<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
610
+ listLevels<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(callback?: C, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
611
+ morris<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, pattern?: DFSOrderPattern, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): ReturnType<C>[];
672
612
  /**
673
613
  * Time complexity: O(n)
674
614
  * Space complexity: O(n)
@@ -681,7 +621,6 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
681
621
  * the original tree is null, a null node is added to the cloned tree. If a node
682
622
  */
683
623
  clone(): BinaryTree<K, V, R, MK, MV, MR>;
684
- protected _clone(cloned: BinaryTree<K, V, R, MK, MV, MR>): void;
685
624
  /**
686
625
  * Time Complexity: O(n)
687
626
  * Space Complexity: O(n)
@@ -725,7 +664,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
725
664
  *
726
665
  * The function `toVisual` in TypeScript overrides the visual representation of a binary tree with
727
666
  * customizable options for displaying undefined, null, and sentinel nodes.
728
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
667
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
729
668
  * `toVisual` method is used to specify the starting point for visualizing the binary tree structure.
730
669
  * It can be a node, key, entry, or the root of the tree. If no specific starting point is provided,
731
670
  * the default is set to the root
@@ -737,7 +676,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
737
676
  * the lines to the output string. The final output string contains the visual representation of the
738
677
  * binary tree with the specified options.
739
678
  */
740
- toVisual(startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, options?: BinaryTreePrintOptions): string;
679
+ toVisual(startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, options?: BinaryTreePrintOptions): string;
741
680
  /**
742
681
  * Time Complexity: O(n)
743
682
  * Space Complexity: O(n)
@@ -748,74 +687,33 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
748
687
  * printing options for the binary tree. It is an optional parameter that allows you to customize how
749
688
  * the binary tree is printed, such as choosing between different traversal orders or formatting
750
689
  * options.
751
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the
690
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } startNode - The `startNode` parameter in the
752
691
  * `override print` method is used to specify the starting point for printing the binary tree. It can
753
692
  * be either a key, a node, an entry, or the root of the tree. If no specific starting point is
754
693
  * provided, the default value is set to
755
694
  */
756
- print(options?: BinaryTreePrintOptions, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>): void;
695
+ print(options?: BinaryTreePrintOptions, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): void;
696
+ protected _clone(cloned: BinaryTree<K, V, R, MK, MV, MR>): void;
757
697
  /**
758
698
  * Time Complexity: O(1)
759
699
  * Space Complexity: O(1)
760
700
  *
761
701
  * The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
762
702
  * or returns null.
763
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The
703
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The
764
704
  * `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeOrEntry`, which
765
- * can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. This parameter represents either a key, a
705
+ * can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. This parameter represents either a key, a
766
706
  * node, an entry
767
707
  * @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
768
708
  * an optional parameter of type `V`. It represents the value associated with the key in the node
769
709
  * being created. If a `value` is provided, it will be used when creating the node. If
770
710
  * @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
771
- * (`OptNodeOrNull<BinaryTreeNode<K, V>>`) based on the input parameters provided. The function checks the type of the
711
+ * (`BinaryTreeNode<K, V> | null | undefined`) based on the input parameters provided. The function checks the type of the
772
712
  * input parameter (`keyNodeOrEntry`) and processes it accordingly to return a node or null
773
713
  * value.
774
714
  */
775
- protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>, value?: V): [OptNodeOrNull<BinaryTreeNode<K, V>>, V | undefined];
776
- /**
777
- * Time complexity: O(n)
778
- * Space complexity: O(n)
779
- *
780
- * The `_dfs` function performs a depth-first search traversal on a binary tree structure based on
781
- * the specified order pattern and callback function.
782
- * @param {C} callback - The `callback` parameter in the `_dfs` method is a function that will be
783
- * called on each node visited during the depth-first search traversal. It is of type `C`, which
784
- * extends `NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>`. The default value for this parameter is `this._DEFAULT
785
- * @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter in the `_dfs` method specifies the
786
- * order in which the nodes are visited during the Depth-First Search traversal. It can have one of
787
- * the following values:
788
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} startNode - The `startNode` parameter in the `_dfs`
789
- * method is used to specify the starting point for the depth-first search traversal in a binary
790
- * tree. It can be provided as either a `BTNRep` object or a reference to the root node
791
- * of the tree. If no specific
792
- * @param {IterationType} iterationType - The `iterationType` parameter in the `_dfs` method
793
- * specifies the type of iteration to be performed during the Depth-First Search (DFS) traversal of a
794
- * binary tree. It can have two possible values:
795
- * @param [includeNull=false] - The `includeNull` parameter in the `_dfs` method is a boolean flag
796
- * that determines whether null nodes should be included in the depth-first search traversal. If
797
- * `includeNull` is set to `true`, null nodes will be considered during the traversal process. If it
798
- * is set to `false`,
799
- * @param shouldVisitLeft - The `shouldVisitLeft` parameter is a function that takes a node as input
800
- * and returns a boolean value. It is used to determine whether the left child of a node should be
801
- * visited during the depth-first search traversal. By default, it checks if the node is truthy (not
802
- * null or undefined
803
- * @param shouldVisitRight - The `shouldVisitRight` parameter is a function that takes a node as an
804
- * argument and returns a boolean value. It is used to determine whether the right child of a node
805
- * should be visited during the depth-first search traversal. The default implementation checks if
806
- * the node is truthy before visiting the right child
807
- * @param shouldVisitRoot - The `shouldVisitRoot` parameter is a function that takes a node as an
808
- * argument and returns a boolean value. It is used to determine whether the root node should be
809
- * visited during the depth-first search traversal based on certain conditions. The default
810
- * implementation checks if the node is a real node or null based
811
- * @param shouldProcessRoot - The `shouldProcessRoot` parameter is a function that takes a node as an
812
- * argument and returns a boolean value indicating whether the node should be processed during the
813
- * depth-first search traversal. The default implementation checks if the node is a real node or null
814
- * based on the `includeNull` flag. If `
815
- * @returns The function `_dfs` returns an array of the return type of the callback function provided
816
- * as input.
817
- */
818
- protected _dfs<C extends NodeCallback<OptNodeOrNull<BinaryTreeNode<K, V>>>>(callback?: C, pattern?: DFSOrderPattern, startNode?: BTNRep<K, V, BinaryTreeNode<K, V>>, iterationType?: IterationType, includeNull?: boolean, shouldVisitLeft?: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => boolean, shouldVisitRight?: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => boolean, shouldVisitRoot?: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => boolean, shouldProcessRoot?: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => boolean): ReturnType<C>[];
715
+ protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): [BinaryTreeNode<K, V> | null | undefined, V | undefined];
716
+ protected _dfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback: C, pattern?: DFSOrderPattern, onlyOne?: boolean, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType, includeNull?: boolean, shouldVisitLeft?: (node: BinaryTreeNode<K, V> | null | undefined) => boolean, shouldVisitRight?: (node: BinaryTreeNode<K, V> | null | undefined) => boolean, shouldVisitRoot?: (node: BinaryTreeNode<K, V> | null | undefined) => boolean, shouldProcessRoot?: (node: BinaryTreeNode<K, V> | null | undefined) => boolean): ReturnType<C>[];
819
717
  /**
820
718
  * Time Complexity: O(1)
821
719
  * Space Complexity: O(1)
@@ -831,7 +729,7 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
831
729
  * the `iterationType` property. If the `iterationType` is set to 'ITERATIVE', the method uses a
832
730
  * stack to perform an in-order traversal of the tree. If the `iterationType` is not 'ITERATIVE
833
731
  */
834
- protected _getIterator(node?: OptNodeOrNull<BinaryTreeNode<K, V>>): IterableIterator<[K, V | undefined]>;
732
+ protected _getIterator(node?: BinaryTreeNode<K, V> | null | undefined): IterableIterator<[K, V | undefined]>;
835
733
  /**
836
734
  * Time Complexity: O(n)
837
735
  * Space Complexity: O(n)
@@ -847,24 +745,24 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
847
745
  * information about how to display a node in a binary tree. The `NodeDisplayLayout` consists of four
848
746
  * elements:
849
747
  */
850
- protected _displayAux(node: OptNodeOrNull<BinaryTreeNode<K, V>>, options: BinaryTreePrintOptions): NodeDisplayLayout;
851
- protected _DEFAULT_NODE_CALLBACK: (node: OptNodeOrNull<BinaryTreeNode<K, V>>) => K | undefined;
748
+ protected _displayAux(node: BinaryTreeNode<K, V> | null | undefined, options: BinaryTreePrintOptions): NodeDisplayLayout;
749
+ protected _DEFAULT_NODE_CALLBACK: (node: BinaryTreeNode<K, V> | null | undefined) => K | undefined;
852
750
  /**
853
751
  * Time Complexity: O(1)
854
752
  * Space Complexity: O(1)
855
753
  *
856
754
  * The _swapProperties function swaps key and value properties between two nodes in a binary tree.
857
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} srcNode - The `srcNode` parameter in the
755
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } srcNode - The `srcNode` parameter in the
858
756
  * `_swapProperties` method can be either a BTNRep object containing key and value
859
757
  * properties, or it can be of type R.
860
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} destNode - The `destNode` parameter in the
758
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } destNode - The `destNode` parameter in the
861
759
  * `_swapProperties` method represents the node or entry where the properties will be swapped with
862
- * the `srcNode`. It can be of type `BTNRep<K, V, BinaryTreeNode<K, V>>` or `R`. The method ensures that
760
+ * the `srcNode`. It can be of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined ` or `R`. The method ensures that
863
761
  * both `srcNode
864
762
  * @returns The `_swapProperties` method returns either the `destNode` with its key and value swapped
865
763
  * with the `srcNode`, or `undefined` if either `srcNode` or `destNode` is falsy.
866
764
  */
867
- protected _swapProperties(srcNode: BTNRep<K, V, BinaryTreeNode<K, V>>, destNode: BTNRep<K, V, BinaryTreeNode<K, V>>): BinaryTreeNode<K, V> | undefined;
765
+ protected _swapProperties(srcNode: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, destNode: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): BinaryTreeNode<K, V> | undefined;
868
766
  /**
869
767
  * Time Complexity: O(1)
870
768
  * Space Complexity: O(1)
@@ -886,23 +784,11 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
886
784
  *
887
785
  * The function _setRoot sets the root node of a data structure while updating the parent reference
888
786
  * of the previous root node.
889
- * @param v - The parameter `v` in the `_setRoot` method is of type `OptNodeOrNull<BinaryTreeNode<K, V>>`, which means
787
+ * @param v - The parameter `v` in the `_setRoot` method is of type `BinaryTreeNode<K, V> | null | undefined`, which means
890
788
  * it can either be an optional `BinaryTreeNode<K, V>` type or `null`.
891
789
  */
892
- protected _setRoot(v: OptNodeOrNull<BinaryTreeNode<K, V>>): void;
893
- /**
894
- * Time Complexity: O(1)
895
- * Space Complexity: O(1)
896
- *
897
- * The function `_ensurePredicate` in TypeScript ensures that the input is converted into a valid
898
- * predicate function for a binary tree node.
899
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>} keyNodeEntryOrPredicate - The
900
- * `_ensurePredicate` method in the provided code snippet is responsible for ensuring that the input
901
- * parameter `keyNodeEntryOrPredicate` is transformed into a valid predicate function that can be
902
- * used for filtering nodes in a binary tree.
903
- * @returns A NodePredicate<BinaryTreeNode<K, V>> function is being returned.
904
- */
905
- protected _ensurePredicate(keyNodeEntryOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>): NodePredicate<BinaryTreeNode<K, V>>;
790
+ protected _setRoot(v: BinaryTreeNode<K, V> | null | undefined): void;
791
+ protected _ensurePredicate(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>): NodePredicate<BinaryTreeNode<K, V>>;
906
792
  /**
907
793
  * Time Complexity: O(1)
908
794
  * Space Complexity: O(1)
@@ -922,14 +808,14 @@ export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any
922
808
  *
923
809
  * The function `_extractKey` in TypeScript returns the key from a given input, which can be a node,
924
810
  * entry, raw data, or null/undefined.
925
- * @param {BTNRep<K, V, BinaryTreeNode<K, V>>} keyNodeOrEntry - The `_extractKey` method you provided is a
926
- * TypeScript method that takes in a parameter `keyNodeOrEntry` of type `BTNRep<K, V, BinaryTreeNode<K, V>>`,
811
+ * @param {K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined } keyNodeOrEntry - The `_extractKey` method you provided is a
812
+ * TypeScript method that takes in a parameter `keyNodeOrEntry` of type `K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined `,
927
813
  * where `BTNRep` is a generic type with keys `K`, `V`, and `BinaryTreeNode<K, V>`, and `
928
814
  * @returns The `_extractKey` method returns the key value extracted from the `keyNodeOrEntry`
929
815
  * parameter. The return value can be a key value of type `K`, `null`, or `undefined`, depending on
930
816
  * the conditions checked in the method.
931
817
  */
932
- protected _extractKey(keyNodeOrEntry: BTNRep<K, V, BinaryTreeNode<K, V>>): K | null | undefined;
818
+ protected _extractKey(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): K | null | undefined;
933
819
  /**
934
820
  * Time Complexity: O(1)
935
821
  * Space Complexity: O(1)