heap-typed 1.53.9 → 1.54.1

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