min-heap-typed 1.42.2 → 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 +57 -53
- package/dist/data-structures/binary-tree/binary-tree.js +116 -54
- 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 +227 -158
- 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/data-structures/graph/abstract-graph.ts +18 -14
- 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,17 +69,16 @@ 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.
|
|
80
80
|
*/
|
|
81
81
|
get size(): number;
|
|
82
|
-
protected defaultOneParamCallback: (node: N) => number;
|
|
83
82
|
/**
|
|
84
83
|
* Creates a new instance of BinaryTreeNode with the given key and value.
|
|
85
84
|
* @param {BTNKey} key - The key for the new node.
|
|
@@ -102,7 +101,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
102
101
|
* @param {V} value - The value for the new node (optional).
|
|
103
102
|
* @returns {N | null | undefined} - The inserted node, or null if nothing was inserted, or undefined if the operation failed.
|
|
104
103
|
*/
|
|
105
|
-
add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
|
|
104
|
+
add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | null | undefined;
|
|
106
105
|
/**
|
|
107
106
|
* The `addMany` function takes an array of binary tree node IDs or nodes, and optionally an array of corresponding data
|
|
108
107
|
* values, and adds them to the binary tree.
|
|
@@ -113,7 +112,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
113
112
|
* the value of the nodes will be `undefined`.
|
|
114
113
|
* @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
|
|
115
114
|
*/
|
|
116
|
-
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)[];
|
|
117
116
|
/**
|
|
118
117
|
* The `refill` function clears the binary tree and adds multiple nodes with the given IDs or nodes and optional data.
|
|
119
118
|
* @param {(BTNKey | N)[]} keysOrNodes - The `keysOrNodes` parameter is an array that can contain either
|
|
@@ -123,27 +122,27 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
123
122
|
* array. Each value in the `data` array will be assigned to the
|
|
124
123
|
* @returns The method is returning a boolean value.
|
|
125
124
|
*/
|
|
126
|
-
refill(keysOrNodes: (BTNKey | null)[] | (N | null)[], data?: Array<V>): boolean;
|
|
125
|
+
refill(keysOrNodes: (BTNKey | null | undefined)[] | (N | null | undefined)[], data?: Array<V>): boolean;
|
|
127
126
|
delete<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C): BinaryTreeDeletedResult<N>[];
|
|
128
|
-
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>[];
|
|
129
128
|
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C): BinaryTreeDeletedResult<N>[];
|
|
130
129
|
/**
|
|
131
130
|
* The function `getDepth` calculates the depth of a given node in a binary tree relative to a
|
|
132
131
|
* specified root node.
|
|
133
|
-
* @param {BTNKey | N | null} distNode - The `distNode` parameter represents the node
|
|
132
|
+
* @param {BTNKey | N | null | undefined} distNode - The `distNode` parameter represents the node
|
|
134
133
|
* whose depth we want to find in the binary tree. It can be either a node object (`N`), a key value
|
|
135
134
|
* of the node (`BTNKey`), or `null`.
|
|
136
|
-
* @param {BTNKey | N | null} beginRoot - The `beginRoot` parameter represents the
|
|
135
|
+
* @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
|
|
137
136
|
* starting node from which we want to calculate the depth. It can be either a node object or the key
|
|
138
137
|
* of a node in the binary tree. If no value is provided for `beginRoot`, it defaults to the root
|
|
139
138
|
* node of the binary tree.
|
|
140
139
|
* @returns the depth of the `distNode` relative to the `beginRoot`.
|
|
141
140
|
*/
|
|
142
|
-
getDepth(distNode: BTNKey | N | null, beginRoot?: BTNKey | N | null): number;
|
|
141
|
+
getDepth(distNode: BTNKey | N | null | undefined, beginRoot?: BTNKey | N | null | undefined): number;
|
|
143
142
|
/**
|
|
144
143
|
* The `getHeight` function calculates the maximum height of a binary tree using either recursive or
|
|
145
144
|
* iterative approach.
|
|
146
|
-
* @param {BTNKey | N | null} beginRoot - The `beginRoot` parameter represents the
|
|
145
|
+
* @param {BTNKey | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
|
|
147
146
|
* starting node from which the height of the binary tree is calculated. It can be either a node
|
|
148
147
|
* object (`N`), a key value of a node in the tree (`BTNKey`), or `null` if no starting
|
|
149
148
|
* node is specified. If `
|
|
@@ -152,38 +151,38 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
152
151
|
* possible values:
|
|
153
152
|
* @returns the height of the binary tree.
|
|
154
153
|
*/
|
|
155
|
-
getHeight(beginRoot?: BTNKey | N | null, iterationType?: IterationType): number;
|
|
154
|
+
getHeight(beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): number;
|
|
156
155
|
/**
|
|
157
156
|
* The `getMinHeight` function calculates the minimum height of a binary tree using either a
|
|
158
157
|
* recursive or iterative approach.
|
|
159
|
-
* @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
|
|
160
159
|
* calculate the minimum height of the tree. It is optional and defaults to the root of the tree if
|
|
161
160
|
* not provided.
|
|
162
161
|
* @param iterationType - The `iterationType` parameter is used to determine the method of iteration
|
|
163
162
|
* to calculate the minimum height of a binary tree. It can have two possible values:
|
|
164
163
|
* @returns The function `getMinHeight` returns the minimum height of a binary tree.
|
|
165
164
|
*/
|
|
166
|
-
getMinHeight(beginRoot?: N | null, iterationType?: IterationType): number;
|
|
165
|
+
getMinHeight(beginRoot?: N | null | undefined, iterationType?: IterationType): number;
|
|
167
166
|
/**
|
|
168
167
|
* The function checks if a binary tree is perfectly balanced by comparing the minimum height and the
|
|
169
168
|
* height of the tree.
|
|
170
|
-
* @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
|
|
171
170
|
* either be of type `N` (representing a node in a tree) or `null` (representing an empty tree).
|
|
172
171
|
* @returns The method is returning a boolean value.
|
|
173
172
|
*/
|
|
174
|
-
isPerfectlyBalanced(beginRoot?: N | null): boolean;
|
|
175
|
-
getNodes<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
|
|
176
|
-
getNodes<C extends BTNCallback<N, N>>(identifier: N | null, callback?: C, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
|
|
177
|
-
getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
|
|
178
|
-
has<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | null, iterationType?: IterationType): boolean;
|
|
179
|
-
has<C extends BTNCallback<N, N>>(identifier: N | null, callback?: C, beginRoot?: N | null, iterationType?: IterationType): boolean;
|
|
180
|
-
has<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C, beginRoot?: N | null, iterationType?: IterationType): boolean;
|
|
181
|
-
getNode<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | null, iterationType?: IterationType): N | null;
|
|
182
|
-
getNode<C extends BTNCallback<N, N>>(identifier: N | null, callback?: C, beginRoot?: N | null, iterationType?: IterationType): N | null;
|
|
183
|
-
getNode<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: N | null, iterationType?: IterationType): N | null;
|
|
184
|
-
get<C extends BTNCallback<N, BTNKey>>(identifier: BTNKey, callback?: C, beginRoot?: N | null, iterationType?: IterationType): V | undefined;
|
|
185
|
-
get<C extends BTNCallback<N, N>>(identifier: N | null, callback?: C, beginRoot?: N | null, iterationType?: IterationType): V | undefined;
|
|
186
|
-
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;
|
|
187
186
|
/**
|
|
188
187
|
* The function `getPathToRoot` returns an array of nodes starting from a given node and traversing
|
|
189
188
|
* up to the root node, with the option to reverse the order of the nodes.
|
|
@@ -198,7 +197,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
198
197
|
/**
|
|
199
198
|
* The function `getLeftMost` returns the leftmost node in a binary tree, either using recursive or
|
|
200
199
|
* iterative traversal.
|
|
201
|
-
* @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
|
|
202
201
|
* for finding the leftmost node in a binary tree. It can be either a node object (`N`), a key value
|
|
203
202
|
* of a node (`BTNKey`), or `null` if the tree is empty.
|
|
204
203
|
* @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
|
|
@@ -206,19 +205,19 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
206
205
|
* @returns The function `getLeftMost` returns the leftmost node (`N`) in a binary tree. If there is
|
|
207
206
|
* no leftmost node, it returns `null`.
|
|
208
207
|
*/
|
|
209
|
-
getLeftMost(beginRoot?: BTNKey | N | null, iterationType?: IterationType): N | null;
|
|
208
|
+
getLeftMost(beginRoot?: BTNKey | N | null | undefined, iterationType?: IterationType): N | null | undefined;
|
|
210
209
|
/**
|
|
211
210
|
* The function `getRightMost` returns the rightmost node in a binary tree, either recursively or
|
|
212
211
|
* iteratively.
|
|
213
|
-
* @param {N | null} beginRoot - The `beginRoot` parameter is the starting node from which we want to
|
|
214
|
-
* 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`
|
|
215
214
|
* or `null`. If it is `null`, it means there is no starting node
|
|
216
215
|
* @param iterationType - The `iterationType` parameter is used to determine the type of iteration to
|
|
217
216
|
* be performed when finding the rightmost node in a binary tree. It can have two possible values:
|
|
218
217
|
* @returns The function `getRightMost` returns the rightmost node (`N`) in a binary tree. If the
|
|
219
218
|
* `beginRoot` parameter is `null`, it returns `null`.
|
|
220
219
|
*/
|
|
221
|
-
getRightMost(beginRoot?: N | null, iterationType?: IterationType): N | null;
|
|
220
|
+
getRightMost(beginRoot?: N | null | undefined, iterationType?: IterationType): N | null | undefined;
|
|
222
221
|
/**
|
|
223
222
|
* The function `isSubtreeBST` checks if a given binary tree is a valid binary search tree.
|
|
224
223
|
* @param {N} beginRoot - The `beginRoot` parameter is the root node of the binary tree that you want
|
|
@@ -228,7 +227,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
228
227
|
* possible values:
|
|
229
228
|
* @returns The function `isSubtreeBST` returns a boolean value.
|
|
230
229
|
*/
|
|
231
|
-
isSubtreeBST(beginRoot: N | null, iterationType?: IterationType): boolean;
|
|
230
|
+
isSubtreeBST(beginRoot: N | null | undefined, iterationType?: IterationType): boolean;
|
|
232
231
|
/**
|
|
233
232
|
* The function checks if a binary tree is a binary search tree.
|
|
234
233
|
* @param iterationType - The parameter "iterationType" is used to specify the type of iteration to
|
|
@@ -238,18 +237,21 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
238
237
|
* @returns a boolean value.
|
|
239
238
|
*/
|
|
240
239
|
isBST(iterationType?: IterationType): boolean;
|
|
241
|
-
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKey | N | null, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
|
|
242
|
-
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKey | N | null, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
|
|
243
|
-
subTreeTraverse<C extends BTNCallback<N | null>>(callback?: C, beginRoot?: BTNKey | N | null, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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>[][];
|
|
253
255
|
/**
|
|
254
256
|
* The function returns the predecessor node of a given node in a binary tree.
|
|
255
257
|
* @param {N} node - The parameter "node" represents a node in a binary tree.
|
|
@@ -273,12 +275,12 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
273
275
|
* @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter in the `morris` function
|
|
274
276
|
* determines the order in which the nodes of a binary tree are traversed. It can have one of the
|
|
275
277
|
* following values:
|
|
276
|
-
* @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
|
|
277
279
|
* traversal. It specifies the root node of the tree from which the traversal should begin. If
|
|
278
280
|
* `beginRoot` is `null`, an empty array will be returned.
|
|
279
281
|
* @returns The `morris` function returns an array of `ReturnType<BTNCallback<N>>` values.
|
|
280
282
|
*/
|
|
281
|
-
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>[];
|
|
282
284
|
/**
|
|
283
285
|
* The above function is an iterator for a binary tree that can be used to traverse the tree in
|
|
284
286
|
* either an iterative or recursive manner.
|
|
@@ -288,7 +290,8 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
|
|
|
288
290
|
* @returns The `*[Symbol.iterator]` method returns a generator object that yields the keys of the
|
|
289
291
|
* binary tree nodes in a specific order.
|
|
290
292
|
*/
|
|
291
|
-
[Symbol.iterator](node?: N | null): Generator<BTNKey, void, undefined>;
|
|
293
|
+
[Symbol.iterator](node?: N | null | undefined): Generator<BTNKey, void, undefined>;
|
|
294
|
+
protected defaultOneParamCallback: (node: N) => number;
|
|
292
295
|
/**
|
|
293
296
|
* Swap the data of two nodes in the binary tree.
|
|
294
297
|
* @param {N} srcNode - The source node to swap.
|
|
@@ -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
|
}
|