data-structure-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.
Files changed (47) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cjs/src/data-structures/binary-tree/avl-tree.d.ts +2 -2
  3. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js +5 -3
  4. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
  5. package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +56 -52
  6. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +115 -53
  7. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
  8. package/dist/cjs/src/data-structures/binary-tree/bst.d.ts +42 -15
  9. package/dist/cjs/src/data-structures/binary-tree/bst.js +77 -21
  10. package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +28 -51
  12. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +148 -180
  13. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
  14. package/dist/cjs/src/data-structures/binary-tree/tree-multiset.d.ts +10 -10
  15. package/dist/cjs/src/data-structures/binary-tree/tree-multiset.js +20 -17
  16. package/dist/cjs/src/data-structures/binary-tree/tree-multiset.js.map +1 -1
  17. package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  18. package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.d.ts +4 -0
  19. package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.js +0 -5
  20. package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.js.map +1 -1
  21. package/dist/mjs/src/data-structures/binary-tree/avl-tree.d.ts +2 -2
  22. package/dist/mjs/src/data-structures/binary-tree/avl-tree.js +5 -3
  23. package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +56 -52
  24. package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +115 -53
  25. package/dist/mjs/src/data-structures/binary-tree/bst.d.ts +42 -15
  26. package/dist/mjs/src/data-structures/binary-tree/bst.js +79 -21
  27. package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +28 -51
  28. package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +148 -184
  29. package/dist/mjs/src/data-structures/binary-tree/tree-multiset.d.ts +10 -10
  30. package/dist/mjs/src/data-structures/binary-tree/tree-multiset.js +19 -17
  31. package/dist/mjs/src/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  32. package/dist/mjs/src/types/data-structures/binary-tree/rb-tree.d.ts +4 -0
  33. package/dist/mjs/src/types/data-structures/binary-tree/rb-tree.js +0 -5
  34. package/dist/umd/data-structure-typed.min.js +1 -1
  35. package/dist/umd/data-structure-typed.min.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/data-structures/binary-tree/avl-tree.ts +5 -4
  38. package/src/data-structures/binary-tree/binary-tree.ts +201 -131
  39. package/src/data-structures/binary-tree/bst.ts +100 -34
  40. package/src/data-structures/binary-tree/rb-tree.ts +227 -236
  41. package/src/data-structures/binary-tree/tree-multiset.ts +24 -23
  42. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  43. package/src/types/data-structures/binary-tree/rb-tree.ts +5 -5
  44. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +20 -1
  45. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +12 -31
  46. package/test/unit/data-structures/binary-tree/bst.test.ts +3 -3
  47. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +205 -159
@@ -52,23 +52,25 @@ class TreeMultiset extends avl_tree_1.AVLTree {
52
52
  /**
53
53
  * The `add` function adds a new node to a binary search tree, updating the count if the key already
54
54
  * exists, and balancing the tree if necessary.
55
- * @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a
55
+ * @param {BTNKey | N | undefined} keyOrNode - The `keyOrNode` parameter can be either a
56
56
  * `BTNKey` (which represents the key of the node to be added), a `N` (which represents a
57
- * node to be added), or `null` (which represents a null node).
57
+ * node to be added), or `undefined` (which represents a undefined node).
58
58
  * @param [value] - The `value` parameter represents the value associated with the key that is being
59
59
  * added to the binary tree.
60
60
  * @param [count=1] - The `count` parameter represents the number of occurrences of the key/value
61
61
  * pair that will be added to the binary tree. It has a default value of 1, which means that if no
62
62
  * count is specified, the default count will be 1.
63
- * @returns The function `add` returns a value of type `N | null | undefined`.
63
+ * @returns The function `add` returns a value of type `N | undefined | undefined`.
64
64
  */
65
65
  add(keyOrNode, value, count = 1) {
66
+ if (keyOrNode === null)
67
+ return undefined;
66
68
  let inserted = undefined, newNode;
67
69
  if (keyOrNode instanceof TreeMultisetNode) {
68
70
  newNode = this.createNode(keyOrNode.key, keyOrNode.value, keyOrNode.count);
69
71
  }
70
- else if (keyOrNode === null) {
71
- newNode = null;
72
+ else if (keyOrNode === undefined) {
73
+ newNode = undefined;
72
74
  }
73
75
  else {
74
76
  newNode = this.createNode(keyOrNode, value, count);
@@ -126,7 +128,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
126
128
  }
127
129
  }
128
130
  else {
129
- // TODO may need to support null inserted
131
+ // TODO may need to support undefined inserted
130
132
  }
131
133
  }
132
134
  else {
@@ -140,8 +142,8 @@ class TreeMultiset extends avl_tree_1.AVLTree {
140
142
  }
141
143
  /**
142
144
  * The function adds a new node to a binary tree if there is an available slot in the parent node.
143
- * @param {N | null} newNode - The `newNode` parameter represents the node that needs to be added to
144
- * the tree. It can be either a node object (`N`) or `null`.
145
+ * @param {N | undefined} newNode - The `newNode` parameter represents the node that needs to be added to
146
+ * the tree. It can be either a node object (`N`) or `undefined`.
145
147
  * @param {N} parent - The `parent` parameter represents the parent node to which the new node will
146
148
  * be added as a child.
147
149
  * @returns The method `_addTo` returns either the `parent.left`, `parent.right`, or `undefined`.
@@ -150,7 +152,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
150
152
  if (parent) {
151
153
  if (parent.left === undefined) {
152
154
  parent.left = newNode;
153
- if (newNode !== null) {
155
+ if (newNode !== undefined) {
154
156
  this._size = this.size + 1;
155
157
  this._setCount(this.count + newNode.count);
156
158
  }
@@ -158,7 +160,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
158
160
  }
159
161
  else if (parent.right === undefined) {
160
162
  parent.right = newNode;
161
- if (newNode !== null) {
163
+ if (newNode !== undefined) {
162
164
  this._size = this.size + 1;
163
165
  this._setCount(this.count + newNode.count);
164
166
  }
@@ -175,12 +177,12 @@ class TreeMultiset extends avl_tree_1.AVLTree {
175
177
  /**
176
178
  * The `addMany` function adds multiple keys or nodes to a TreeMultiset and returns an array of the
177
179
  * inserted nodes.
178
- * @param {(BTNKey | null)[] | (N | null)[]} keysOrNodes - An array of keys or nodes to be
180
+ * @param {(BTNKey | undefined)[] | (N | undefined)[]} keysOrNodes - An array of keys or nodes to be
179
181
  * added to the multiset. Each element can be either a BTNKey or a TreeMultisetNode.
180
182
  * @param {V[]} [data] - The `data` parameter is an optional array of values that correspond
181
183
  * to the keys or nodes being added to the multiset. It is used to associate additional data with
182
184
  * each key or node.
183
- * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
185
+ * @returns The function `addMany` returns an array of `N`, `undefined`, or `undefined` values.
184
186
  */
185
187
  addMany(keysOrNodes, data) {
186
188
  const inserted = [];
@@ -190,7 +192,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
190
192
  inserted.push(this.add(keyOrNode.key, keyOrNode.value, keyOrNode.count));
191
193
  continue;
192
194
  }
193
- if (keyOrNode === null) {
195
+ if (keyOrNode === undefined) {
194
196
  inserted.push(this.add(NaN, undefined, 0));
195
197
  continue;
196
198
  }
@@ -259,14 +261,15 @@ class TreeMultiset extends avl_tree_1.AVLTree {
259
261
  * @returns The method `delete` returns an array of `BinaryTreeDeletedResult<N>` objects.
260
262
  */
261
263
  delete(identifier, callback = this.defaultOneParamCallback, ignoreCount = false) {
264
+ var _a;
262
265
  const bstDeletedResult = [];
263
266
  if (!this.root)
264
267
  return bstDeletedResult;
265
- const curr = this.getNode(identifier, callback);
268
+ const curr = (_a = this.getNode(identifier, callback)) !== null && _a !== void 0 ? _a : undefined;
266
269
  if (!curr)
267
270
  return bstDeletedResult;
268
- const parent = (curr === null || curr === void 0 ? void 0 : curr.parent) ? curr.parent : null;
269
- let needBalanced = null, orgCurrent = curr;
271
+ const parent = (curr === null || curr === void 0 ? void 0 : curr.parent) ? curr.parent : undefined;
272
+ let needBalanced = undefined, orgCurrent = curr;
270
273
  if (curr.count > 1 && !ignoreCount) {
271
274
  curr.count--;
272
275
  this._setCount(this.count - 1);
@@ -289,7 +292,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
289
292
  }
290
293
  }
291
294
  else {
292
- const leftSubTreeRightMost = curr.left ? this.getRightMost(curr.left) : null;
295
+ const leftSubTreeRightMost = curr.left ? this.getRightMost(curr.left) : undefined;
293
296
  if (leftSubTreeRightMost) {
294
297
  const parentOfLeftSubTreeMax = leftSubTreeRightMost.parent;
295
298
  orgCurrent = this._swap(curr, leftSubTreeRightMost);
@@ -1 +1 @@
1
- {"version":3,"file":"tree-multiset.js","sourceRoot":"","sources":["../../../../../src/data-structures/binary-tree/tree-multiset.ts"],"names":[],"mappings":";;;AAQA,uCAAoG;AAEpG,yCAAgD;AAEhD,MAAa,gBAGX,SAAQ,sBAAiB;IAGzB;;;;;;;;;OASG;IACH,YAAY,GAAW,EAAE,KAAS,EAAE,KAAK,GAAG,CAAC;QAC3C,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AApBD,4CAoBC;AAED;;GAEG;AACH,MAAa,YACX,SAAQ,kBAAa;IAGrB;;;;;OAKG;IACH,YAAY,OAA6B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAGT,WAAM,GAAG,CAAC,CAAC;IAFnB,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC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AAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACO,SAAS,CAAC,CAAS;QAC3B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AAvVD,oCAuVC"}
@@ -21,7 +21,7 @@ export declare enum FamilyPosition {
21
21
  export type BTNKey = number;
22
22
  export type BinaryTreeDeletedResult<N> = {
23
23
  deleted: N | null | undefined;
24
- needBalanced: N | null;
24
+ needBalanced: N | null | undefined;
25
25
  };
26
26
  export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
27
27
  export type BinaryTreeOptions = {
@@ -1,4 +1,8 @@
1
+ import { RBTreeNode } from '../../../data-structures';
2
+ import { BSTOptions } from "./bst";
1
3
  export declare enum RBTNColor {
2
4
  RED = 1,
3
5
  BLACK = 0
4
6
  }
7
+ export type RBTreeNodeNested<T> = RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
8
+ export type RBTreeOptions = BSTOptions & {};
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- // import {BinaryTreeOptions} from './binary-tree';
3
- // import {RBTreeNode} from '../../../data-structures';
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
5
3
  exports.RBTNColor = void 0;
6
4
  var RBTNColor;
@@ -8,7 +6,4 @@ var RBTNColor;
8
6
  RBTNColor[RBTNColor["RED"] = 1] = "RED";
9
7
  RBTNColor[RBTNColor["BLACK"] = 0] = "BLACK";
10
8
  })(RBTNColor || (exports.RBTNColor = RBTNColor = {}));
11
- // export type RBTreeNodeNested<T> = RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
12
- //
13
- // export type RBTreeOptions = BinaryTreeOptions & {}
14
9
  //# sourceMappingURL=rb-tree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rb-tree.js","sourceRoot":"","sources":["../../../../../../src/types/data-structures/binary-tree/rb-tree.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,uDAAuD;;;AAEvD,IAAY,SAA+B;AAA3C,WAAY,SAAS;IAAG,uCAAO,CAAA;IAAE,2CAAS,CAAA;AAAA,CAAC,EAA/B,SAAS,yBAAT,SAAS,QAAsB;AAE3C,sxBAAsxB;AACtxB,EAAE;AACF,qDAAqD"}
1
+ {"version":3,"file":"rb-tree.js","sourceRoot":"","sources":["../../../../../../src/types/data-structures/binary-tree/rb-tree.ts"],"names":[],"mappings":";;;AAGA,IAAY,SAA+B;AAA3C,WAAY,SAAS;IAAG,uCAAO,CAAA;IAAE,2CAAS,CAAA;AAAA,CAAC,EAA/B,SAAS,yBAAT,SAAS,QAAsB"}
@@ -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 | null} keyOrNode - The `keyOrNode` parameter can accept either a
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 | null | undefined;
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.
@@ -42,13 +42,15 @@ class AVLTree extends bst_1.BST {
42
42
  /**
43
43
  * The function overrides the add method of a binary tree node and balances the tree after inserting
44
44
  * a new node.
45
- * @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can accept either a
45
+ * @param {BTNKey | N | undefined} keyOrNode - The `keyOrNode` parameter can accept either a
46
46
  * `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
47
47
  * @param [value] - The `value` parameter is the value that you want to assign to the new node that you
48
48
  * are adding to the binary search tree.
49
49
  * @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
50
50
  */
51
51
  add(keyOrNode, value) {
52
+ if (keyOrNode === null)
53
+ return undefined;
52
54
  const inserted = super.add(keyOrNode, value);
53
55
  if (inserted)
54
56
  this._balancePath(inserted);
@@ -218,7 +220,7 @@ class AVLTree extends bst_1.BST {
218
220
  _balanceLR(A) {
219
221
  const parentOfA = A.parent;
220
222
  const B = A.left;
221
- let C = null;
223
+ let C = undefined;
222
224
  if (B) {
223
225
  C = B.right;
224
226
  }
@@ -302,7 +304,7 @@ class AVLTree extends bst_1.BST {
302
304
  _balanceRL(A) {
303
305
  const parentOfA = A.parent;
304
306
  const B = A.right;
305
- let C = null;
307
+ let C = undefined;
306
308
  if (B) {
307
309
  C = B.left;
308
310
  }
@@ -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
- dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
244
- dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
245
- dfs<C extends BTNCallback<N | null>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
246
- bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: N | null, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
247
- bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: N | null, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
248
- bfs<C extends BTNCallback<N | null>>(callback?: C, beginRoot?: N | null, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
249
- listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: N | null, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
250
- listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: N | null, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[][];
251
- listLevels<C extends BTNCallback<N | null>>(callback?: C, beginRoot?: N | null, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
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
  }