min-heap-typed 1.42.3 → 1.42.4
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.
- package/dist/data-structures/binary-tree/avl-tree.d.ts +2 -2
- package/dist/data-structures/binary-tree/avl-tree.js +5 -3
- package/dist/data-structures/binary-tree/binary-tree.d.ts +56 -52
- package/dist/data-structures/binary-tree/binary-tree.js +115 -53
- package/dist/data-structures/binary-tree/bst.d.ts +42 -15
- package/dist/data-structures/binary-tree/bst.js +77 -21
- package/dist/data-structures/binary-tree/rb-tree.d.ts +28 -51
- package/dist/data-structures/binary-tree/rb-tree.js +148 -180
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +10 -10
- package/dist/data-structures/binary-tree/tree-multiset.js +20 -17
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +4 -0
- package/dist/types/data-structures/binary-tree/rb-tree.js +0 -5
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +5 -4
- package/src/data-structures/binary-tree/binary-tree.ts +201 -131
- package/src/data-structures/binary-tree/bst.ts +100 -34
- package/src/data-structures/binary-tree/rb-tree.ts +227 -236
- package/src/data-structures/binary-tree/tree-multiset.ts +24 -23
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/rb-tree.ts +5 -5
|
@@ -34,13 +34,13 @@ export declare class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<
|
|
|
34
34
|
/**
|
|
35
35
|
* The function overrides the add method of a binary tree node and balances the tree after inserting
|
|
36
36
|
* a new node.
|
|
37
|
-
* @param {BTNKey | N |
|
|
37
|
+
* @param {BTNKey | N | undefined} keyOrNode - The `keyOrNode` parameter can accept either a
|
|
38
38
|
* `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
|
|
39
39
|
* @param [value] - The `value` parameter is the value that you want to assign to the new node that you
|
|
40
40
|
* are adding to the binary search tree.
|
|
41
41
|
* @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
|
|
42
42
|
*/
|
|
43
|
-
add(keyOrNode: BTNKey | N | null, value?: V): N |
|
|
43
|
+
add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | undefined;
|
|
44
44
|
/**
|
|
45
45
|
* The function overrides the delete method of a binary tree and balances the tree after deleting a
|
|
46
46
|
* node if necessary.
|
|
@@ -41,13 +41,15 @@ class AVLTree extends bst_1.BST {
|
|
|
41
41
|
/**
|
|
42
42
|
* The function overrides the add method of a binary tree node and balances the tree after inserting
|
|
43
43
|
* a new node.
|
|
44
|
-
* @param {BTNKey | N |
|
|
44
|
+
* @param {BTNKey | N | undefined} keyOrNode - The `keyOrNode` parameter can accept either a
|
|
45
45
|
* `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
|
|
46
46
|
* @param [value] - The `value` parameter is the value that you want to assign to the new node that you
|
|
47
47
|
* are adding to the binary search tree.
|
|
48
48
|
* @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
|
|
49
49
|
*/
|
|
50
50
|
add(keyOrNode, value) {
|
|
51
|
+
if (keyOrNode === null)
|
|
52
|
+
return undefined;
|
|
51
53
|
const inserted = super.add(keyOrNode, value);
|
|
52
54
|
if (inserted)
|
|
53
55
|
this._balancePath(inserted);
|
|
@@ -217,7 +219,7 @@ class AVLTree extends bst_1.BST {
|
|
|
217
219
|
_balanceLR(A) {
|
|
218
220
|
const parentOfA = A.parent;
|
|
219
221
|
const B = A.left;
|
|
220
|
-
let C =
|
|
222
|
+
let C = undefined;
|
|
221
223
|
if (B) {
|
|
222
224
|
C = B.right;
|
|
223
225
|
}
|
|
@@ -301,7 +303,7 @@ class AVLTree extends bst_1.BST {
|
|
|
301
303
|
_balanceRL(A) {
|
|
302
304
|
const parentOfA = A.parent;
|
|
303
305
|
const B = A.right;
|
|
304
|
-
let C =
|
|
306
|
+
let C = undefined;
|
|
305
307
|
if (B) {
|
|
306
308
|
C = B.left;
|
|
307
309
|
}
|
|
@@ -69,11 +69,11 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
69
69
|
* @param {BinaryTreeOptions} [options] - The options for the binary tree.
|
|
70
70
|
*/
|
|
71
71
|
constructor(options?: BinaryTreeOptions);
|
|
72
|
-
protected _root: N | null;
|
|
72
|
+
protected _root: N | null | undefined;
|
|
73
73
|
/**
|
|
74
74
|
* Get the root node of the binary tree.
|
|
75
75
|
*/
|
|
76
|
-
get root(): N | null;
|
|
76
|
+
get root(): N | null | undefined;
|
|
77
77
|
protected _size: number;
|
|
78
78
|
/**
|
|
79
79
|
* Get the number of nodes in the binary tree.
|
|
@@ -101,7 +101,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
101
101
|
* @param {V} value - The value for the new node (optional).
|
|
102
102
|
* @returns {N | null | undefined} - The inserted node, or null if nothing was inserted, or undefined if the operation failed.
|
|
103
103
|
*/
|
|
104
|
-
add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
|
|
104
|
+
add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | null | undefined;
|
|
105
105
|
/**
|
|
106
106
|
* The `addMany` function takes an array of binary tree node IDs or nodes, and optionally an array of corresponding data
|
|
107
107
|
* values, and adds them to the binary tree.
|
|
@@ -112,7 +112,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
112
112
|
* the value of the nodes will be `undefined`.
|
|
113
113
|
* @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
|
|
114
114
|
*/
|
|
115
|
-
addMany(keysOrNodes: (BTNKey | null)[] | (N | null)[], values?: V[]): (N | null | undefined)[];
|
|
115
|
+
addMany(keysOrNodes: (BTNKey | null | undefined)[] | (N | null | undefined)[], values?: V[]): (N | null | undefined)[];
|
|
116
116
|
/**
|
|
117
117
|
* The `refill` function clears the binary tree and adds multiple nodes with the given IDs or nodes and optional data.
|
|
118
118
|
* @param {(BTNKey | N)[]} keysOrNodes - The `keysOrNodes` parameter is an array that can contain either
|
|
@@ -122,27 +122,27 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
122
122
|
* array. Each value in the `data` array will be assigned to the
|
|
123
123
|
* @returns The method is returning a boolean value.
|
|
124
124
|
*/
|
|
125
|
-
refill(keysOrNodes: (BTNKey | null)[] | (N | null)[], data?: Array<V>): boolean;
|
|
125
|
+
refill(keysOrNodes: (BTNKey | null | undefined)[] | (N | null | undefined)[], data?: Array<V>): boolean;
|
|
126
126
|
delete<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C): BinaryTreeDeletedResult<N>[];
|
|
127
|
-
delete<C extends BTNCallback<N, N>>(identifier: N | null, callback?: C): BinaryTreeDeletedResult<N>[];
|
|
127
|
+
delete<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C): BinaryTreeDeletedResult<N>[];
|
|
128
128
|
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C): BinaryTreeDeletedResult<N>[];
|
|
129
129
|
/**
|
|
130
130
|
* The function `getDepth` calculates the depth of a given node in a binary tree relative to a
|
|
131
131
|
* specified root node.
|
|
132
|
-
* @param {BTNKey | N | null} distNode - The `distNode` parameter represents the node
|
|
132
|
+
* @param {BTNKey | N | null | undefined} distNode - The `distNode` parameter represents the node
|
|
133
133
|
* whose depth we want to find in the binary tree. It can be either a node object (`N`), a key value
|
|
134
134
|
* of the node (`BTNKey`), or `null`.
|
|
135
|
-
* @param {BTNKey | N | null} beginRoot - The `beginRoot` parameter represents the
|
|
135
|
+
* @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
|
|
136
136
|
* starting node from which we want to calculate the depth. It can be either a node object or the key
|
|
137
137
|
* of a node in the binary tree. If no value is provided for `beginRoot`, it defaults to the root
|
|
138
138
|
* node of the binary tree.
|
|
139
139
|
* @returns the depth of the `distNode` relative to the `beginRoot`.
|
|
140
140
|
*/
|
|
141
|
-
getDepth(distNode: BTNKey | N | null, beginRoot?: BTNKey | N | null): number;
|
|
141
|
+
getDepth(distNode: BTNKey | N | null | undefined, beginRoot?: BTNKey | N | null | undefined): number;
|
|
142
142
|
/**
|
|
143
143
|
* The `getHeight` function calculates the maximum height of a binary tree using either recursive or
|
|
144
144
|
* iterative approach.
|
|
145
|
-
* @param {BTNKey | N | null} beginRoot - The `beginRoot` parameter represents the
|
|
145
|
+
* @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
|
|
146
146
|
* starting node from which the height of the binary tree is calculated. It can be either a node
|
|
147
147
|
* object (`N`), a key value of a node in the tree (`BTNKey`), or `null` if no starting
|
|
148
148
|
* node is specified. If `
|
|
@@ -151,38 +151,38 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
151
151
|
* possible values:
|
|
152
152
|
* @returns the height of the binary tree.
|
|
153
153
|
*/
|
|
154
|
-
getHeight(beginRoot?: BTNKey | N | null, iterationType?: IterationType): number;
|
|
154
|
+
getHeight(beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): number;
|
|
155
155
|
/**
|
|
156
156
|
* The `getMinHeight` function calculates the minimum height of a binary tree using either a
|
|
157
157
|
* recursive or iterative approach.
|
|
158
|
-
* @param {N | null} beginRoot - The `beginRoot` parameter is the starting node from which we want to
|
|
158
|
+
* @param {N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node from which we want to
|
|
159
159
|
* calculate the minimum height of the tree. It is optional and defaults to the root of the tree if
|
|
160
160
|
* not provided.
|
|
161
161
|
* @param iterationType - The `iterationType` parameter is used to determine the method of iteration
|
|
162
162
|
* to calculate the minimum height of a binary tree. It can have two possible values:
|
|
163
163
|
* @returns The function `getMinHeight` returns the minimum height of a binary tree.
|
|
164
164
|
*/
|
|
165
|
-
getMinHeight(beginRoot?: N | null, iterationType?: IterationType): number;
|
|
165
|
+
getMinHeight(beginRoot?: N | null | undefined, iterationType?: IterationType): number;
|
|
166
166
|
/**
|
|
167
167
|
* The function checks if a binary tree is perfectly balanced by comparing the minimum height and the
|
|
168
168
|
* height of the tree.
|
|
169
|
-
* @param {N | null} beginRoot - The parameter `beginRoot` is of type `N | null`, which means it can
|
|
169
|
+
* @param {N | null | undefined} beginRoot - The parameter `beginRoot` is of type `N | null | undefined`, which means it can
|
|
170
170
|
* either be of type `N` (representing a node in a tree) or `null` (representing an empty tree).
|
|
171
171
|
* @returns The method is returning a boolean value.
|
|
172
172
|
*/
|
|
173
|
-
isPerfectlyBalanced(beginRoot?: N | null): boolean;
|
|
174
|
-
getNodes<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
|
|
175
|
-
getNodes<C extends BTNCallback<N, N>>(identifier: N | null, callback?: C, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
|
|
176
|
-
getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
|
|
177
|
-
has<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | null, iterationType?: IterationType): boolean;
|
|
178
|
-
has<C extends BTNCallback<N, N>>(identifier: N | null, callback?: C, beginRoot?: N | null, iterationType?: IterationType): boolean;
|
|
179
|
-
has<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C, beginRoot?: N | null, iterationType?: IterationType): boolean;
|
|
180
|
-
getNode<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | null, iterationType?: IterationType): N | null;
|
|
181
|
-
getNode<C extends BTNCallback<N, N>>(identifier: N | null, callback?: C, beginRoot?: N | null, iterationType?: IterationType): N | null;
|
|
182
|
-
getNode<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: N | null, iterationType?: IterationType): N | null;
|
|
183
|
-
get<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | null, iterationType?: IterationType): V | undefined;
|
|
184
|
-
get<C extends BTNCallback<N, N>>(identifier: N | null, callback?: C, beginRoot?: N | null, iterationType?: IterationType): V | undefined;
|
|
185
|
-
get<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: N | null, iterationType?: IterationType): V | undefined;
|
|
173
|
+
isPerfectlyBalanced(beginRoot?: N | null | undefined): boolean;
|
|
174
|
+
getNodes<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, onlyOne?: boolean, beginRoot?: N | null | undefined, iterationType?: IterationType): N[];
|
|
175
|
+
getNodes<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, onlyOne?: boolean, beginRoot?: N | null | undefined, iterationType?: IterationType): N[];
|
|
176
|
+
getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, onlyOne?: boolean, beginRoot?: N | null | undefined, iterationType?: IterationType): N[];
|
|
177
|
+
has<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType): boolean;
|
|
178
|
+
has<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType): boolean;
|
|
179
|
+
has<C extends BTNCallback<N>>(identifier: ReturnType<C> | null | undefined, callback: C, beginRoot?: N | null | undefined, iterationType?: IterationType): boolean;
|
|
180
|
+
getNode<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType): N | null | undefined;
|
|
181
|
+
getNode<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType): N | null | undefined;
|
|
182
|
+
getNode<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: N | null | undefined, iterationType?: IterationType): N | null | undefined;
|
|
183
|
+
get<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType): V | undefined;
|
|
184
|
+
get<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType): V | undefined;
|
|
185
|
+
get<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: N | null | undefined, iterationType?: IterationType): V | undefined;
|
|
186
186
|
/**
|
|
187
187
|
* The function `getPathToRoot` returns an array of nodes starting from a given node and traversing
|
|
188
188
|
* up to the root node, with the option to reverse the order of the nodes.
|
|
@@ -197,7 +197,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
197
197
|
/**
|
|
198
198
|
* The function `getLeftMost` returns the leftmost node in a binary tree, either using recursive or
|
|
199
199
|
* iterative traversal.
|
|
200
|
-
* @param {BTNKey | N | null} beginRoot - The `beginRoot` parameter is the starting point
|
|
200
|
+
* @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter is the starting point
|
|
201
201
|
* for finding the leftmost node in a binary tree. It can be either a node object (`N`), a key value
|
|
202
202
|
* of a node (`BTNKey`), or `null` if the tree is empty.
|
|
203
203
|
* @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
|
|
@@ -205,19 +205,19 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
205
205
|
* @returns The function `getLeftMost` returns the leftmost node (`N`) in a binary tree. If there is
|
|
206
206
|
* no leftmost node, it returns `null`.
|
|
207
207
|
*/
|
|
208
|
-
getLeftMost(beginRoot?: BTNKey | N | null, iterationType?: IterationType): N | null;
|
|
208
|
+
getLeftMost(beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): N | null | undefined;
|
|
209
209
|
/**
|
|
210
210
|
* The function `getRightMost` returns the rightmost node in a binary tree, either recursively or
|
|
211
211
|
* iteratively.
|
|
212
|
-
* @param {N | null} beginRoot - The `beginRoot` parameter is the starting node from which we want to
|
|
213
|
-
* find the rightmost node. It is of type `N | null`, which means it can either be a node of type `N`
|
|
212
|
+
* @param {N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node from which we want to
|
|
213
|
+
* find the rightmost node. It is of type `N | null | undefined`, which means it can either be a node of type `N`
|
|
214
214
|
* or `null`. If it is `null`, it means there is no starting node
|
|
215
215
|
* @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
|
|
216
216
|
* be performed when finding the rightmost node in a binary tree. It can have two possible values:
|
|
217
217
|
* @returns The function `getRightMost` returns the rightmost node (`N`) in a binary tree. If the
|
|
218
218
|
* `beginRoot` parameter is `null`, it returns `null`.
|
|
219
219
|
*/
|
|
220
|
-
getRightMost(beginRoot?: N | null, iterationType?: IterationType): N | null;
|
|
220
|
+
getRightMost(beginRoot?: N | null | undefined, iterationType?: IterationType): N | null | undefined;
|
|
221
221
|
/**
|
|
222
222
|
* The function `isSubtreeBST` checks if a given binary tree is a valid binary search tree.
|
|
223
223
|
* @param {N} beginRoot - The `beginRoot` parameter is the root node of the binary tree that you want
|
|
@@ -227,7 +227,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
227
227
|
* possible values:
|
|
228
228
|
* @returns The function `isSubtreeBST` returns a boolean value.
|
|
229
229
|
*/
|
|
230
|
-
isSubtreeBST(beginRoot: N | null, iterationType?: IterationType): boolean;
|
|
230
|
+
isSubtreeBST(beginRoot: N | null | undefined, iterationType?: IterationType): boolean;
|
|
231
231
|
/**
|
|
232
232
|
* The function checks if a binary tree is a binary search tree.
|
|
233
233
|
* @param iterationType - The parameter "iterationType" is used to specify the type of iteration to
|
|
@@ -237,18 +237,21 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
237
237
|
* @returns a boolean value.
|
|
238
238
|
*/
|
|
239
239
|
isBST(iterationType?: IterationType): boolean;
|
|
240
|
-
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKey | N | null, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
|
|
241
|
-
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKey | N | null, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
|
|
242
|
-
subTreeTraverse<C extends BTNCallback<N | null>>(callback?: C, beginRoot?: BTNKey | N | null, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
240
|
+
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
|
|
241
|
+
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
|
|
242
|
+
subTreeTraverse<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
243
|
+
isNode(node: any): node is N;
|
|
244
|
+
isNIL(node: any): boolean;
|
|
245
|
+
isNodeOrNull(node: any): node is (N | null);
|
|
246
|
+
dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
|
|
247
|
+
dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null | undefined, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
|
|
248
|
+
dfs<C extends BTNCallback<N | null | undefined>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
249
|
+
bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
|
|
250
|
+
bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
|
|
251
|
+
bfs<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
252
|
+
listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
|
|
253
|
+
listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[][];
|
|
254
|
+
listLevels<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: N | null | undefined, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
|
|
252
255
|
/**
|
|
253
256
|
* The function returns the predecessor node of a given node in a binary tree.
|
|
254
257
|
* @param {N} node - The parameter "node" represents a node in a binary tree.
|
|
@@ -272,12 +275,12 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
272
275
|
* @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter in the `morris` function
|
|
273
276
|
* determines the order in which the nodes of a binary tree are traversed. It can have one of the
|
|
274
277
|
* following values:
|
|
275
|
-
* @param {N | null} beginRoot - The `beginRoot` parameter is the starting node for the Morris
|
|
278
|
+
* @param {N | null | undefined} beginRoot - The `beginRoot` parameter is the starting node for the Morris
|
|
276
279
|
* traversal. It specifies the root node of the tree from which the traversal should begin. If
|
|
277
280
|
* `beginRoot` is `null`, an empty array will be returned.
|
|
278
281
|
* @returns The `morris` function returns an array of `ReturnType<BTNCallback<N>>` values.
|
|
279
282
|
*/
|
|
280
|
-
morris<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null): ReturnType<C>[];
|
|
283
|
+
morris<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null | undefined): ReturnType<C>[];
|
|
281
284
|
/**
|
|
282
285
|
* The above function is an iterator for a binary tree that can be used to traverse the tree in
|
|
283
286
|
* either an iterative or recursive manner.
|
|
@@ -287,7 +290,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
287
290
|
* @returns The `*[Symbol.iterator]` method returns a generator object that yields the keys of the
|
|
288
291
|
* binary tree nodes in a specific order.
|
|
289
292
|
*/
|
|
290
|
-
[Symbol.iterator](node?: N | null): Generator<BTNKey, void, undefined>;
|
|
293
|
+
[Symbol.iterator](node?: N | null | undefined): Generator<BTNKey, void, undefined>;
|
|
291
294
|
protected defaultOneParamCallback: (node: N) => number;
|
|
292
295
|
/**
|
|
293
296
|
* Swap the data of two nodes in the binary tree.
|
|
@@ -298,7 +301,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
298
301
|
protected _swap(srcNode: N, destNode: N): N;
|
|
299
302
|
/**
|
|
300
303
|
* The function `_addTo` adds a new node to a binary tree if there is an available position.
|
|
301
|
-
* @param {N | null} newNode - The `newNode` parameter represents the node that you want to add to
|
|
304
|
+
* @param {N | null | undefined} newNode - The `newNode` parameter represents the node that you want to add to
|
|
302
305
|
* the binary tree. It can be either a node object or `null`.
|
|
303
306
|
* @param {N} parent - The `parent` parameter represents the parent node to which the new node will
|
|
304
307
|
* be added as a child.
|
|
@@ -307,12 +310,13 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
307
310
|
* the binary tree. If neither the left nor right child is available, the function returns undefined.
|
|
308
311
|
* If the parent node is null, the function also returns undefined.
|
|
309
312
|
*/
|
|
310
|
-
protected _addTo(newNode: N | null, parent: N): N | null | undefined;
|
|
313
|
+
protected _addTo(newNode: N | null | undefined, parent: N): N | null | undefined;
|
|
311
314
|
/**
|
|
312
315
|
* The function sets the root property of an object to a given value, and if the value is not null,
|
|
313
316
|
* it also sets the parent property of the value to undefined.
|
|
314
|
-
* @param {N | null} v - The parameter `v` is of type `N | null`, which means it can either be of
|
|
317
|
+
* @param {N | null | undefined} v - The parameter `v` is of type `N | null | undefined`, which means it can either be of
|
|
315
318
|
* type `N` or `null`.
|
|
316
319
|
*/
|
|
317
|
-
protected _setRoot(v: N | null): void;
|
|
320
|
+
protected _setRoot(v: N | null | undefined): void;
|
|
321
|
+
print(beginRoot?: N | null | undefined): void;
|
|
318
322
|
}
|