data-structure-typed 1.34.6 → 1.34.8

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 (98) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +74 -35
  3. package/dist/data-structures/binary-tree/abstract-binary-tree.js +70 -70
  4. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
  5. package/dist/data-structures/binary-tree/avl-tree.js +8 -8
  6. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  7. package/dist/data-structures/binary-tree/binary-tree.js +4 -4
  8. package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
  9. package/dist/data-structures/binary-tree/bst.js +59 -59
  10. package/dist/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/data-structures/binary-tree/rb-tree.js +4 -4
  12. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  13. package/dist/data-structures/binary-tree/tree-multiset.js +39 -39
  14. package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
  15. package/dist/data-structures/graph/abstract-graph.js +49 -49
  16. package/dist/data-structures/graph/abstract-graph.js.map +1 -1
  17. package/dist/data-structures/graph/directed-graph.js +33 -33
  18. package/dist/data-structures/graph/directed-graph.js.map +1 -1
  19. package/dist/data-structures/graph/map-graph.js +4 -4
  20. package/dist/data-structures/graph/map-graph.js.map +1 -1
  21. package/dist/data-structures/graph/undirected-graph.js +14 -14
  22. package/dist/data-structures/graph/undirected-graph.js.map +1 -1
  23. package/dist/data-structures/tree/tree.js +5 -5
  24. package/dist/data-structures/tree/tree.js.map +1 -1
  25. package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +71 -71
  26. package/lib/data-structures/binary-tree/abstract-binary-tree.js +110 -110
  27. package/lib/data-structures/binary-tree/avl-tree.d.ts +10 -10
  28. package/lib/data-structures/binary-tree/avl-tree.js +13 -13
  29. package/lib/data-structures/binary-tree/binary-tree.d.ts +6 -6
  30. package/lib/data-structures/binary-tree/binary-tree.js +7 -7
  31. package/lib/data-structures/binary-tree/bst.d.ts +34 -34
  32. package/lib/data-structures/binary-tree/bst.js +80 -80
  33. package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
  34. package/lib/data-structures/binary-tree/rb-tree.js +4 -4
  35. package/lib/data-structures/binary-tree/tree-multiset.d.ts +27 -27
  36. package/lib/data-structures/binary-tree/tree-multiset.js +55 -55
  37. package/lib/data-structures/graph/abstract-graph.d.ts +60 -60
  38. package/lib/data-structures/graph/abstract-graph.js +81 -81
  39. package/lib/data-structures/graph/directed-graph.d.ts +51 -51
  40. package/lib/data-structures/graph/directed-graph.js +63 -63
  41. package/lib/data-structures/graph/map-graph.d.ts +13 -13
  42. package/lib/data-structures/graph/map-graph.js +12 -12
  43. package/lib/data-structures/graph/undirected-graph.d.ts +30 -30
  44. package/lib/data-structures/graph/undirected-graph.js +32 -32
  45. package/lib/data-structures/heap/heap.d.ts +1 -1
  46. package/lib/data-structures/tree/tree.d.ts +4 -4
  47. package/lib/data-structures/tree/tree.js +6 -6
  48. package/lib/interfaces/abstract-binary-tree.d.ts +24 -24
  49. package/lib/interfaces/abstract-graph.d.ts +13 -13
  50. package/lib/interfaces/avl-tree.d.ts +3 -3
  51. package/lib/interfaces/bst.d.ts +8 -8
  52. package/lib/interfaces/directed-graph.d.ts +5 -5
  53. package/lib/interfaces/rb-tree.d.ts +2 -2
  54. package/lib/interfaces/undirected-graph.d.ts +2 -2
  55. package/lib/types/data-structures/abstract-binary-tree.d.ts +3 -3
  56. package/lib/types/data-structures/abstract-graph.d.ts +2 -2
  57. package/lib/types/data-structures/bst.d.ts +2 -2
  58. package/lib/types/data-structures/tree-multiset.d.ts +1 -1
  59. package/lib/types/utils/validate-type.d.ts +8 -8
  60. package/package.json +1 -1
  61. package/scripts/rename_clear_files.sh +29 -0
  62. package/src/data-structures/binary-tree/abstract-binary-tree.ts +147 -147
  63. package/src/data-structures/binary-tree/avl-tree.ts +14 -14
  64. package/src/data-structures/binary-tree/binary-tree.ts +8 -8
  65. package/src/data-structures/binary-tree/bst.ts +98 -90
  66. package/src/data-structures/binary-tree/rb-tree.ts +9 -9
  67. package/src/data-structures/binary-tree/tree-multiset.ts +62 -62
  68. package/src/data-structures/graph/abstract-graph.ts +109 -104
  69. package/src/data-structures/graph/directed-graph.ts +77 -77
  70. package/src/data-structures/graph/map-graph.ts +20 -15
  71. package/src/data-structures/graph/undirected-graph.ts +39 -39
  72. package/src/data-structures/heap/heap.ts +1 -1
  73. package/src/data-structures/tree/tree.ts +7 -7
  74. package/src/interfaces/abstract-binary-tree.ts +24 -24
  75. package/src/interfaces/abstract-graph.ts +13 -13
  76. package/src/interfaces/avl-tree.ts +3 -3
  77. package/src/interfaces/bst.ts +8 -8
  78. package/src/interfaces/directed-graph.ts +5 -5
  79. package/src/interfaces/rb-tree.ts +2 -2
  80. package/src/interfaces/undirected-graph.ts +2 -2
  81. package/src/types/data-structures/abstract-binary-tree.ts +3 -3
  82. package/src/types/data-structures/abstract-graph.ts +2 -2
  83. package/src/types/data-structures/bst.ts +2 -2
  84. package/src/types/data-structures/tree-multiset.ts +1 -1
  85. package/src/types/utils/validate-type.ts +10 -10
  86. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +24 -24
  87. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +3 -3
  88. package/test/unit/data-structures/binary-tree/bst.test.ts +71 -71
  89. package/test/unit/data-structures/binary-tree/overall.test.ts +19 -19
  90. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +72 -72
  91. package/test/unit/data-structures/graph/directed-graph.test.ts +8 -8
  92. package/test/unit/data-structures/graph/map-graph.test.ts +4 -4
  93. package/test/unit/data-structures/graph/overall.test.ts +2 -2
  94. package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
  95. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +0 -1
  96. package/test/unit/data-structures/tree/tree.test.ts +2 -2
  97. package/umd/bundle.min.js +1 -1
  98. package/umd/bundle.min.js.map +1 -1
@@ -5,21 +5,21 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { AbstractBinaryTreeNodeNested, AbstractBinaryTreeNodeProperties, BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../../types';
8
+ import type { AbstractBinaryTreeNodeNested, AbstractBinaryTreeNodeProperties, BinaryTreeDeletedResult, BinaryTreeNodeKey, BinaryTreeNodePropertyName, DFSOrderPattern, NodeOrPropertyName } from '../../types';
9
9
  import { AbstractBinaryTreeOptions, FamilyPosition, LoopType } from '../../types';
10
10
  import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from '../../interfaces';
11
11
  export declare abstract class AbstractBinaryTreeNode<V = any, NEIGHBOR extends AbstractBinaryTreeNode<V, NEIGHBOR> = AbstractBinaryTreeNodeNested<V>> implements IAbstractBinaryTreeNode<V, NEIGHBOR> {
12
12
  /**
13
- * The constructor function initializes a BinaryTreeNode object with an id and an optional value.
14
- * @param {BinaryTreeNodeId} id - The `id` parameter is of type `BinaryTreeNodeId` and represents the unique identifier
13
+ * The constructor function initializes a BinaryTreeNode object with an key and an optional value.
14
+ * @param {BinaryTreeNodeKey} key - The `key` parameter is of type `BinaryTreeNodeKey` and represents the unique identifier
15
15
  * of the binary tree node. It is used to distinguish one node from another in the binary tree.
16
16
  * @param {V} [val] - The "val" parameter is an optional parameter of type V. It represents the value that will be
17
17
  * stored in the binary tree node. If no value is provided, it will be set to undefined.
18
18
  */
19
- protected constructor(id: BinaryTreeNodeId, val?: V);
20
- private _id;
21
- get id(): BinaryTreeNodeId;
22
- set id(v: BinaryTreeNodeId);
19
+ protected constructor(key: BinaryTreeNodeKey, val?: V);
20
+ private _key;
21
+ get key(): BinaryTreeNodeKey;
22
+ set key(v: BinaryTreeNodeKey);
23
23
  private _val;
24
24
  get val(): V | undefined;
25
25
  set val(value: V | undefined);
@@ -54,13 +54,13 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
54
54
  get size(): number;
55
55
  private _loopType;
56
56
  get loopType(): LoopType;
57
- private _visitedId;
58
- get visitedId(): BinaryTreeNodeId[];
57
+ private _visitedKey;
58
+ get visitedKey(): BinaryTreeNodeKey[];
59
59
  private _visitedVal;
60
60
  get visitedVal(): N['val'][];
61
61
  private _visitedNode;
62
62
  get visitedNode(): N[];
63
- abstract createNode(id: BinaryTreeNodeId, val?: N['val']): N | null;
63
+ abstract createNode(key: BinaryTreeNodeKey, val?: N['val']): N | null;
64
64
  /**
65
65
  * The `swapLocation` function swaps the location of two nodes in a binary tree.
66
66
  * @param {N} srcNode - The source node that you want to swap with the destination node.
@@ -70,7 +70,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
70
70
  */
71
71
  swapLocation(srcNode: N, destNode: N): N;
72
72
  /**
73
- * The clear() function resets the root, size, and maxId properties to their initial values.
73
+ * The clear() function resets the root, size, and maxKey properties to their initial values.
74
74
  */
75
75
  clear(): void;
76
76
  /**
@@ -84,57 +84,57 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
84
84
  */
85
85
  /**
86
86
  * The `add` function adds a new node to a binary tree, either by ID or by creating a new node with a given value.
87
- * @param {BinaryTreeNodeId | N | null} idOrNode - The `idOrNode` parameter can be either a `BinaryTreeNodeId`, which
87
+ * @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a `BinaryTreeNodeKey`, which
88
88
  * is a number representing the ID of a binary tree node, or it can be a `N` object, which represents a binary tree
89
89
  * node itself. It can also be `null` if no node is specified.
90
90
  * @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the new node
91
91
  * being added to the binary tree.
92
92
  * @returns The function `add` returns either the inserted node (`N`), `null`, or `undefined`.
93
93
  */
94
- add(idOrNode: BinaryTreeNodeId | N | null, val?: N['val']): N | null | undefined;
94
+ add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined;
95
95
  /**
96
96
  * The `addMany` function takes an array of binary tree node IDs or nodes, and optionally an array of corresponding data
97
97
  * values, and adds them to the binary tree.
98
- * @param {(BinaryTreeNodeId | null)[] | (N | null)[]} idsOrNodes - An array of BinaryTreeNodeId or BinaryTreeNode
98
+ * @param {(BinaryTreeNodeKey | null)[] | (N | null)[]} idsOrNodes - An array of BinaryTreeNodeKey or BinaryTreeNode
99
99
  * objects, or null values.
100
100
  * @param {N['val'][]} [data] - The `data` parameter is an optional array of values (`N['val'][]`) that corresponds to
101
101
  * the nodes or node IDs being added. It is used to set the value of each node being added. If `data` is not provided,
102
102
  * the value of the nodes will be `undefined`.
103
103
  * @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
104
104
  */
105
- addMany(idsOrNodes: (BinaryTreeNodeId | null)[] | (N | null)[], data?: N['val'][]): (N | null | undefined)[];
105
+ addMany(idsOrNodes: (BinaryTreeNodeKey | null)[] | (N | null)[], data?: N['val'][]): (N | null | undefined)[];
106
106
  /**
107
107
  * The `fill` function clears the binary tree and adds multiple nodes with the given IDs or nodes and optional data.
108
- * @param {(BinaryTreeNodeId | N)[]} idsOrNodes - The `idsOrNodes` parameter is an array that can contain either
109
- * `BinaryTreeNodeId` or `N` values.
108
+ * @param {(BinaryTreeNodeKey | N)[]} idsOrNodes - The `idsOrNodes` parameter is an array that can contain either
109
+ * `BinaryTreeNodeKey` or `N` values.
110
110
  * @param {N[] | Array<N['val']>} [data] - The `data` parameter is an optional array of values that will be assigned to
111
111
  * the nodes being added. If provided, the length of the `data` array should be equal to the length of the `idsOrNodes`
112
112
  * array. Each value in the `data` array will be assigned to the
113
113
  * @returns The method is returning a boolean value.
114
114
  */
115
- fill(idsOrNodes: (BinaryTreeNodeId | null)[] | (N | null)[], data?: N[] | Array<N['val']>): boolean;
115
+ fill(idsOrNodes: (BinaryTreeNodeKey | null)[] | (N | null)[], data?: N[] | Array<N['val']>): boolean;
116
116
  /**
117
117
  * The `remove` function in TypeScript is used to delete a node from a binary search tree and returns an array of objects
118
118
  * containing the deleted node and the node that needs to be balanced.
119
- * @param {N | BinaryTreeNodeId} nodeOrId - The `nodeOrId` parameter can be either a node object (`N`) or a binary tree
120
- * node ID (`BinaryTreeNodeId`).
119
+ * @param {N | BinaryTreeNodeKey} nodeOrKey - The `nodeOrKey` parameter can be either a node object (`N`) or a binary tree
120
+ * node ID (`BinaryTreeNodeKey`).
121
121
  * @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
122
122
  */
123
- remove(nodeOrId: N | BinaryTreeNodeId): BinaryTreeDeletedResult<N>[];
123
+ remove(nodeOrKey: N | BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
124
124
  /**
125
125
  * The function calculates the depth of a node in a binary tree.
126
- * @param {N | BinaryTreeNodeId | null} beginRoot - The `beginRoot` parameter can be one of the following:
126
+ * @param {N | BinaryTreeNodeKey | null} beginRoot - The `beginRoot` parameter can be one of the following:
127
127
  * @returns the depth of the given node or binary tree.
128
128
  */
129
- getDepth(beginRoot: N | BinaryTreeNodeId | null): number;
129
+ getDepth(beginRoot: N | BinaryTreeNodeKey | null): number;
130
130
  /**
131
131
  * The `getHeight` function calculates the maximum height of a binary tree, either recursively or iteratively.
132
- * @param {N | BinaryTreeNodeId | null} [beginRoot] - The `beginRoot` parameter is optional and can be of type `N` (a
133
- * generic type representing a node in a binary tree), `BinaryTreeNodeId` (a type representing the ID of a binary tree
132
+ * @param {N | BinaryTreeNodeKey | null} [beginRoot] - The `beginRoot` parameter is optional and can be of type `N` (a
133
+ * generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
134
134
  * node), or `null`.
135
135
  * @returns the height of the binary tree.
136
136
  */
137
- getHeight(beginRoot?: N | BinaryTreeNodeId | null): number;
137
+ getHeight(beginRoot?: N | BinaryTreeNodeKey | null): number;
138
138
  /**
139
139
  * The `getMinHeight` function calculates the minimum height of a binary tree using either a recursive or iterative
140
140
  * approach.
@@ -154,37 +154,37 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
154
154
  isPerfectlyBalanced(beginRoot?: N | null): boolean;
155
155
  /**
156
156
  * The function `getNodes` returns an array of nodes that match a given property name and value in a binary tree.
157
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a
157
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or a
158
158
  * generic type `N`. It represents the property of the binary tree node that you want to search for.
159
159
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
160
- * specifies the property name to use when searching for nodes. If not provided, it defaults to 'id'.
160
+ * specifies the property name to use when searching for nodes. If not provided, it defaults to 'key'.
161
161
  * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
162
162
  * return only one node that matches the given `nodeProperty` or `propertyName`. If `onlyOne` is set to `true`, the
163
163
  * function will stop traversing the tree and return the first matching node. If `only
164
164
  * @returns an array of nodes (type N).
165
165
  */
166
- getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
166
+ getNodes(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
167
167
  /**
168
168
  * The function checks if a binary tree node has a specific property.
169
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or `N`.
169
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or `N`.
170
170
  * It represents the property of the binary tree node that you want to check.
171
171
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
172
- * specifies the name of the property to be checked in the nodes. If not provided, it defaults to 'id'.
172
+ * specifies the name of the property to be checked in the nodes. If not provided, it defaults to 'key'.
173
173
  * @returns a boolean value.
174
174
  */
175
- has(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): boolean;
175
+ has(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): boolean;
176
176
  /**
177
177
  * The function returns the first node that matches the given property name and value, or null if no matching node is
178
178
  * found.
179
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or `N`.
179
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or `N`.
180
180
  * It represents the property of the binary tree node that you want to search for.
181
181
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
182
182
  * specifies the property name to be used for searching the binary tree nodes. If this parameter is not provided, the
183
- * default value is set to `'id'`.
183
+ * default value is set to `'key'`.
184
184
  * @returns either the value of the specified property of the node, or the node itself if no property name is provided.
185
185
  * If no matching node is found, it returns null.
186
186
  */
187
- get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
187
+ get(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): N | null;
188
188
  /**
189
189
  * The function `getPathToRoot` returns an array of nodes representing the path from a given node to the root node, with
190
190
  * an option to reverse the order of the nodes.
@@ -199,7 +199,7 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
199
199
  /**
200
200
  * The function `getLeftMost` returns the leftmost node in a binary tree, starting from a specified node or the root if
201
201
  * no node is specified.
202
- * generic type representing a node in a binary tree), `BinaryTreeNodeId` (a type representing the ID of a binary tree
202
+ * generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
203
203
  * node), or `null`.
204
204
  * @returns The function `getLeftMost` returns the leftmost node in a binary tree. If the `beginRoot` parameter is
205
205
  * provided, it starts the traversal from that node. If `beginRoot` is not provided or is `null`, it starts the traversal
@@ -210,8 +210,8 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
210
210
  /**
211
211
  * The function `getLeftMost` returns the leftmost node in a binary tree, starting from a specified node or the root if
212
212
  * no node is specified.
213
- * @param {N | BinaryTreeNodeId | null} [node] - The `beginRoot` parameter is optional and can be of type `N` (a
214
- * generic type representing a node in a binary tree), `BinaryTreeNodeId` (a type representing the ID of a binary tree
213
+ * @param {N | BinaryTreeNodeKey | null} [node] - The `beginRoot` parameter is optional and can be of type `N` (a
214
+ * generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
215
215
  * node).
216
216
  * @returns The function `getLeftMost` returns the leftmost node in a binary tree. If the `beginRoot` parameter is
217
217
  * provided, it starts the traversal from that node. If `beginRoot` is not provided or is `null`, it starts the traversal
@@ -256,36 +256,36 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
256
256
  getSubTreeSize(subTreeRoot: N | null | undefined): number;
257
257
  /**
258
258
  * The function `subTreeSum` calculates the sum of a specified property in a binary tree or subtree.
259
- * @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
259
+ * @param {N | BinaryTreeNodeKey | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
260
260
  * tree or the ID of a binary tree node. It can also be `null` if there is no subtree.
261
261
  * @param {BinaryTreeNodePropertyName} [propertyName] - propertyName is an optional parameter that specifies the
262
- * property of the binary tree node to use for calculating the sum. It can be either 'id' or 'val'. If propertyName is
263
- * not provided, it defaults to 'id'.
262
+ * property of the binary tree node to use for calculating the sum. It can be either 'key' or 'val'. If propertyName is
263
+ * not provided, it defaults to 'key'.
264
264
  * @returns a number, which is the sum of the values of the specified property in the subtree rooted at `subTreeRoot`.
265
265
  */
266
- subTreeSum(subTreeRoot: N | BinaryTreeNodeId | null, propertyName?: BinaryTreeNodePropertyName): number;
266
+ subTreeSum(subTreeRoot: N | BinaryTreeNodeKey | null, propertyName?: BinaryTreeNodePropertyName): number;
267
267
  /**
268
268
  * The function `subTreeAdd` adds a delta value to a specified property of each node in a subtree.
269
- * @param {N | BinaryTreeNodeId | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
269
+ * @param {N | BinaryTreeNodeKey | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
270
270
  * tree or the ID of a node in the binary tree. It can also be `null` if there is no subtree to add to.
271
271
  * @param {number} delta - The `delta` parameter is a number that represents the amount by which the property value of
272
272
  * each node in the subtree should be incremented.
273
273
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
274
- * specifies the property of the binary tree node that should be modified. If not provided, it defaults to 'id'.
274
+ * specifies the property of the binary tree node that should be modified. If not provided, it defaults to 'key'.
275
275
  * @returns a boolean value.
276
276
  */
277
- subTreeAdd(subTreeRoot: N | BinaryTreeNodeId | null, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
277
+ subTreeAdd(subTreeRoot: N | BinaryTreeNodeKey | null, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
278
278
  /**
279
- * Performs a breadth-first search (BFS) on a binary tree, accumulating properties of each node based on their 'id' property.
279
+ * Performs a breadth-first search (BFS) on a binary tree, accumulating properties of each node based on their 'key' property.
280
280
  * @returns An array of binary tree node IDs.
281
281
  */
282
- BFS(): BinaryTreeNodeId[];
282
+ BFS(): BinaryTreeNodeKey[];
283
283
  /**
284
284
  * Performs a breadth-first search (BFS) on a binary tree, accumulating properties of each node based on the specified property name.
285
- * @param {'id'} nodeOrPropertyName - The name of the property to accumulate.
285
+ * @param {'key'} nodeOrPropertyName - The name of the property to accumulate.
286
286
  * @returns An array of values corresponding to the specified property.
287
287
  */
288
- BFS(nodeOrPropertyName: 'id'): BinaryTreeNodeId[];
288
+ BFS(nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
289
289
  /**
290
290
  * Performs a breadth-first search (BFS) on a binary tree, accumulating the 'val' property of each node.
291
291
  * @param {'val'} nodeOrPropertyName - The name of the property to accumulate.
@@ -299,17 +299,17 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
299
299
  */
300
300
  BFS(nodeOrPropertyName: 'node'): N[];
301
301
  /**
302
- * Performs a depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on their 'id' property.
302
+ * Performs a depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on their 'key' property.
303
303
  * @returns An array of binary tree node IDs.
304
304
  */
305
- DFS(): BinaryTreeNodeId[];
305
+ DFS(): BinaryTreeNodeKey[];
306
306
  /**
307
307
  * Performs a depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on the specified property name.
308
308
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
309
309
  * @param {string} nodeOrPropertyName - The name of the property to accumulate.
310
310
  * @returns An array of values corresponding to the specified property.
311
311
  */
312
- DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
312
+ DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
313
313
  /**
314
314
  * Performs a depth-first search (DFS) traversal on a binary tree and accumulates the 'val' property of each node.
315
315
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
@@ -325,17 +325,17 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
325
325
  */
326
326
  DFS(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
327
327
  /**
328
- * Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on their 'id' property.
328
+ * Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on their 'key' property.
329
329
  * @returns An array of binary tree node IDs.
330
330
  */
331
- DFSIterative(): BinaryTreeNodeId[];
331
+ DFSIterative(): BinaryTreeNodeKey[];
332
332
  /**
333
333
  * Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on the specified property name.
334
334
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
335
335
  * @param {string} nodeOrPropertyName - The name of the property to accumulate.
336
336
  * @returns An array of values corresponding to the specified property.
337
337
  */
338
- DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
338
+ DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
339
339
  /**
340
340
  * Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates the 'val' property of each node.
341
341
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
@@ -351,18 +351,18 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
351
351
  */
352
352
  DFSIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
353
353
  /**
354
- * Performs a level-order traversal on a binary tree starting from the specified node and accumulates properties of each node based on their 'id' property.
354
+ * Performs a level-order traversal on a binary tree starting from the specified node and accumulates properties of each node based on their 'key' property.
355
355
  * @param {N | null} node - The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.
356
356
  * @returns An array of binary tree node IDs.
357
357
  */
358
- levelIterative(node: N | null): BinaryTreeNodeId[];
358
+ levelIterative(node: N | null): BinaryTreeNodeKey[];
359
359
  /**
360
360
  * Performs a level-order traversal on a binary tree starting from the specified node and accumulates properties of each node based on the specified property name.
361
361
  * @param {N | null} node - The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.
362
362
  * @param {string} nodeOrPropertyName - The name of the property to accumulate.
363
363
  * @returns An array of values corresponding to the specified property.
364
364
  */
365
- levelIterative(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
365
+ levelIterative(node: N | null, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
366
366
  /**
367
367
  * Performs a level-order traversal on a binary tree starting from the specified node and accumulates the 'val' property of each node.
368
368
  * @param {N | null} node - The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.
@@ -382,14 +382,14 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
382
382
  * @param {N | null} node - The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.
383
383
  * @returns A 2D array of AbstractBinaryTreeNodeProperty<N> objects.
384
384
  */
385
- listLevels(node: N | null): BinaryTreeNodeId[][];
385
+ listLevels(node: N | null): BinaryTreeNodeKey[][];
386
386
  /**
387
387
  * Collects nodes from a binary tree by a specified property and organizes them into levels.
388
388
  * @param {N | null} node - The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.
389
- * @param {'id} nodeOrPropertyName - The property of the BinaryTreeNode object to collect at each level.
389
+ * @param {'key} nodeOrPropertyName - The property of the BinaryTreeNode object to collect at each level.
390
390
  * @returns A 2D array of values corresponding to the specified property.
391
391
  */
392
- listLevels(node: N | null, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[][];
392
+ listLevels(node: N | null, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[][];
393
393
  /**
394
394
  * Collects nodes from a binary tree by a specified property and organizes them into levels.
395
395
  * @param {N | null} node - The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.
@@ -418,14 +418,14 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
418
418
  * Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm.
419
419
  * @returns An array of binary tree node IDs.
420
420
  */
421
- morris(): BinaryTreeNodeId[];
421
+ morris(): BinaryTreeNodeKey[];
422
422
  /**
423
423
  * Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm and accumulates properties of each node based on the specified property name.
424
424
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
425
- * @param {'id'} nodeOrPropertyName - The name of the property to accumulate.
425
+ * @param {'key'} nodeOrPropertyName - The name of the property to accumulate.
426
426
  * @returns An array of values corresponding to the specified property.
427
427
  */
428
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'id'): BinaryTreeNodeId[];
428
+ morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
429
429
  /**
430
430
  * Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm and accumulates the 'val' property of each node.
431
431
  * @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
@@ -457,10 +457,10 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
457
457
  */
458
458
  protected _setLoopType(value: LoopType): void;
459
459
  /**
460
- * The function sets the value of the `_visitedId` property in a protected manner.
461
- * @param {BinaryTreeNodeId[]} value - value is an array of BinaryTreeNodeId values.
460
+ * The function sets the value of the `_visitedKey` property in a protected manner.
461
+ * @param {BinaryTreeNodeKey[]} value - value is an array of BinaryTreeNodeKey values.
462
462
  */
463
- protected _setVisitedId(value: BinaryTreeNodeId[]): void;
463
+ protected _setVisitedKey(value: BinaryTreeNodeKey[]): void;
464
464
  /**
465
465
  * The function sets the value of the "_visitedVal" property to the given array.
466
466
  * @param value - An array of type N.
@@ -492,17 +492,17 @@ export declare abstract class AbstractBinaryTree<N extends AbstractBinaryTreeNod
492
492
  * a result array.
493
493
  * @param {N} cur - The current node being processed.
494
494
  * @param {(N | null | undefined)[]} result - An array that stores the matching nodes.
495
- * @param {BinaryTreeNodeId | N} nodeProperty - The `nodeProperty` parameter is either a `BinaryTreeNodeId` or a `N`
495
+ * @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter is either a `BinaryTreeNodeKey` or a `N`
496
496
  * type. It represents the property value that we are comparing against in the switch statement.
497
497
  * @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
498
- * specifies the property name to compare against when pushing nodes into the `result` array. It can be either `'id'`
499
- * or `'val'`. If it is not provided or is not equal to `'id'` or `'val'`, the
498
+ * specifies the property name to compare against when pushing nodes into the `result` array. It can be either `'key'`
499
+ * or `'val'`. If it is not provided or is not equal to `'key'` or `'val'`, the
500
500
  * @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
501
501
  * stop after finding the first matching node or continue searching for all matching nodes. If `onlyOne` is set to
502
502
  * `true`, the function will stop after finding the first matching node and return `true`. If `onlyOne
503
503
  * @returns a boolean value indicating whether only one matching node should be pushed into the result array.
504
504
  */
505
- protected _pushByPropertyNameStopOrNot(cur: N, result: (N | null | undefined)[], nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): boolean | undefined;
505
+ protected _pushByPropertyNameStopOrNot(cur: N, result: (N | null | undefined)[], nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): boolean | undefined;
506
506
  /**
507
507
  * The function `_accumulatedByPropertyName` accumulates values from a given node based on the specified property name.
508
508
  * @param {N} node - The `node` parameter is of type `N`, which represents a node in a data structure.