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