heap-typed 1.52.0 → 1.52.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +11 -11
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
- package/dist/data-structures/binary-tree/avl-tree.d.ts +11 -11
- package/dist/data-structures/binary-tree/avl-tree.js +6 -6
- package/dist/data-structures/binary-tree/binary-tree.d.ts +97 -97
- package/dist/data-structures/binary-tree/binary-tree.js +50 -50
- package/dist/data-structures/binary-tree/bst.d.ts +35 -35
- package/dist/data-structures/binary-tree/bst.js +15 -15
- package/dist/data-structures/binary-tree/rb-tree.d.ts +8 -8
- package/dist/data-structures/binary-tree/rb-tree.js +6 -6
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +10 -10
- package/dist/data-structures/binary-tree/tree-multi-map.js +5 -5
- package/dist/data-structures/graph/directed-graph.js +2 -1
- package/dist/data-structures/queue/deque.d.ts +7 -0
- package/dist/data-structures/queue/deque.js +16 -1
- package/dist/data-structures/queue/queue.d.ts +0 -1
- package/dist/data-structures/queue/queue.js +0 -1
- package/dist/index.js +0 -1
- package/dist/interfaces/binary-tree.d.ts +3 -3
- package/dist/types/common.d.ts +1 -22
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +18 -1
- package/dist/types/data-structures/binary-tree/bst.d.ts +3 -0
- package/dist/types/data-structures/queue/deque.d.ts +1 -0
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +12 -12
- package/src/data-structures/binary-tree/avl-tree.ts +11 -11
- package/src/data-structures/binary-tree/binary-tree.ts +151 -147
- package/src/data-structures/binary-tree/bst.ts +44 -41
- package/src/data-structures/binary-tree/rb-tree.ts +10 -10
- package/src/data-structures/binary-tree/tree-multi-map.ts +10 -10
- package/src/data-structures/graph/directed-graph.ts +2 -1
- package/src/data-structures/queue/deque.ts +15 -1
- package/src/data-structures/queue/queue.ts +0 -1
- package/src/index.ts +0 -1
- package/src/interfaces/binary-tree.ts +3 -3
- package/src/types/common.ts +2 -24
- package/src/types/data-structures/binary-tree/binary-tree.ts +21 -1
- package/src/types/data-structures/binary-tree/bst.ts +7 -0
- package/src/types/data-structures/queue/deque.ts +4 -1
|
@@ -39,7 +39,7 @@ class BinaryTreeNode {
|
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* The function sets the left child of a node and updates its parent reference.
|
|
42
|
-
* @param {NODE
|
|
42
|
+
* @param {OptBTNOrNull<NODE>} v - The parameter `v` can be of type `NODE`, `null`, or
|
|
43
43
|
* `undefined`.
|
|
44
44
|
*/
|
|
45
45
|
set left(v) {
|
|
@@ -58,7 +58,7 @@ class BinaryTreeNode {
|
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* The function sets the right child of a node and updates its parent.
|
|
61
|
-
* @param {NODE
|
|
61
|
+
* @param {OptBTNOrNull<NODE>} v - The parameter `v` can be of type `NODE`, `null`, or
|
|
62
62
|
* `undefined`.
|
|
63
63
|
*/
|
|
64
64
|
set right(v) {
|
|
@@ -96,7 +96,7 @@ exports.BinaryTreeNode = BinaryTreeNode;
|
|
|
96
96
|
class BinaryTree extends base_1.IterableEntryBase {
|
|
97
97
|
/**
|
|
98
98
|
* The constructor function initializes a binary tree object with optional keysOrNodesOrEntriesOrRawElements and options.
|
|
99
|
-
* @param [keysOrNodesOrEntriesOrRawElements] - Optional iterable of
|
|
99
|
+
* @param [keysOrNodesOrEntriesOrRawElements] - Optional iterable of BTNKeyOrNodeOrEntry objects. These objects represent the
|
|
100
100
|
* nodes to be added to the binary tree.
|
|
101
101
|
* @param [options] - The `options` parameter is an optional object that can contain additional
|
|
102
102
|
* configuration options for the binary tree. In this case, it is of type
|
|
@@ -172,8 +172,8 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
172
172
|
/**
|
|
173
173
|
* The function `keyValueOrEntryOrRawElementToNode` converts a key-value pair, entry, or raw element
|
|
174
174
|
* into a node object.
|
|
175
|
-
* @param {R |
|
|
176
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
175
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
176
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
177
177
|
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
|
|
178
178
|
* `keyValueOrEntryOrRawElementToNode` function. It represents the value associated with a key in a
|
|
179
179
|
* key-value pair. If provided, it will be used to create a node with the specified key and value.
|
|
@@ -217,8 +217,8 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
217
217
|
*
|
|
218
218
|
* The `ensureNode` function checks if the input is a valid node and returns it, or converts it to a
|
|
219
219
|
* node if it is a key or entry.
|
|
220
|
-
* @param {R |
|
|
221
|
-
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, `
|
|
220
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
221
|
+
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or
|
|
222
222
|
* a raw element.
|
|
223
223
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
|
|
224
224
|
* parameter that specifies the type of iteration to be used when searching for a node. It has a
|
|
@@ -253,8 +253,8 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
253
253
|
}
|
|
254
254
|
/**
|
|
255
255
|
* The function checks if the input is an instance of the BinaryTreeNode class.
|
|
256
|
-
* @param {R |
|
|
257
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
256
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
257
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
258
258
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
259
259
|
* an instance of the `BinaryTreeNode` class.
|
|
260
260
|
*/
|
|
@@ -263,8 +263,8 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
263
263
|
}
|
|
264
264
|
/**
|
|
265
265
|
* The function checks if a given node is a valid node in a binary search tree.
|
|
266
|
-
* @param {R |
|
|
267
|
-
* `
|
|
266
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
|
|
267
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
268
268
|
* @returns a boolean value.
|
|
269
269
|
*/
|
|
270
270
|
isRealNode(node) {
|
|
@@ -274,8 +274,8 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
276
276
|
* The function checks if a given node is a real node or null.
|
|
277
|
-
* @param {R |
|
|
278
|
-
* `
|
|
277
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
|
|
278
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
279
279
|
* @returns a boolean value.
|
|
280
280
|
*/
|
|
281
281
|
isNodeOrNull(node) {
|
|
@@ -283,8 +283,8 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* The function checks if a given node is equal to the NIL value.
|
|
286
|
-
* @param {R |
|
|
287
|
-
* `
|
|
286
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
|
|
287
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
288
288
|
* @returns a boolean value.
|
|
289
289
|
*/
|
|
290
290
|
isNIL(node) {
|
|
@@ -293,8 +293,8 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
293
293
|
/**
|
|
294
294
|
* The function checks if the input is an array with two elements, indicating it is a binary tree
|
|
295
295
|
* node entry.
|
|
296
|
-
* @param {R |
|
|
297
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
296
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
297
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
298
298
|
* @returns a boolean value.
|
|
299
299
|
*/
|
|
300
300
|
isEntry(keyOrNodeOrEntryOrRawElement) {
|
|
@@ -342,10 +342,10 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
342
342
|
*
|
|
343
343
|
* The `add` function is used to insert a new node into a binary tree, checking for duplicate keys
|
|
344
344
|
* and finding the appropriate insertion position.
|
|
345
|
-
* @param {R |
|
|
345
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
|
|
346
346
|
* `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which represents the key,
|
|
347
347
|
* node, entry, or raw element to be added to the tree. It can also accept a value of type
|
|
348
|
-
* `
|
|
348
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>
|
|
349
349
|
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the
|
|
350
350
|
* key being added to the tree. It represents the value that will be stored in the tree for the given
|
|
351
351
|
* key.
|
|
@@ -447,7 +447,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
447
447
|
*
|
|
448
448
|
* The `refill` function clears the current data and adds new data to the collection.
|
|
449
449
|
* @param keysOrNodesOrEntriesOrRawElements - An iterable collection of keys, nodes, entries, or raw
|
|
450
|
-
* elements. These can be of any type (R) or a specific type (
|
|
450
|
+
* elements. These can be of any type (R) or a specific type (BTNKeyOrNodeOrEntry<K, V, NODE>).
|
|
451
451
|
* @param [values] - The `values` parameter is an optional iterable of values that will be associated
|
|
452
452
|
* with the keys or nodes being added. If provided, the values will be assigned to the corresponding
|
|
453
453
|
* keys or nodes. If not provided, the values will be set to `undefined`.
|
|
@@ -542,7 +542,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
542
542
|
* the identifier or all nodes that match the identifier. If set to true, only the first matching
|
|
543
543
|
* node will be returned. If set to false, all matching nodes will be returned. The default value is
|
|
544
544
|
* false.
|
|
545
|
-
* @param {R |
|
|
545
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
546
546
|
* point for the search. It can be either a node object, a key-value pair, or a key. If it is not
|
|
547
547
|
* provided, the `root` of the data structure is used as the starting point.
|
|
548
548
|
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of
|
|
@@ -601,7 +601,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
601
601
|
* the `C` callback function, or it can be `null` or `undefined`.
|
|
602
602
|
* @param {C} callback - The `callback` parameter is a function that will be used to determine if a
|
|
603
603
|
* node matches the desired criteria. It should return a value that can be used to identify the node.
|
|
604
|
-
* @param {R |
|
|
604
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
605
605
|
* point for searching nodes in a tree structure. It can be either a root node, a key-value pair, or
|
|
606
606
|
* a node entry. If not provided, the search will start from the root of the tree.
|
|
607
607
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
@@ -646,7 +646,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
646
646
|
* callback function `C`. It can also be `null` or `undefined` if no identifier is provided.
|
|
647
647
|
* @param {C} callback - The `callback` parameter is a function that will be used to determine if a
|
|
648
648
|
* node matches the given identifier. It is optional and defaults to `this._DEFAULT_CALLBACK`.
|
|
649
|
-
* @param {R |
|
|
649
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
650
650
|
* point for the search in the binary tree. It can be either a root node of the tree or a key, node,
|
|
651
651
|
* or entry object that exists in the tree. If no specific starting point is provided, the search
|
|
652
652
|
* will begin from the root of the
|
|
@@ -677,7 +677,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
677
677
|
* @param {C} callback - The `callback` parameter is a function that will be used to determine
|
|
678
678
|
* whether a node should be included in the result or not. It is of type `C`, which extends the
|
|
679
679
|
* `BTNCallback<NODE>` type.
|
|
680
|
-
* @param {R |
|
|
680
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
681
681
|
* point for the iteration in the data structure. It can be either a root node, a key-value pair, or
|
|
682
682
|
* a node entry. If not specified, it defaults to the root of the data structure.
|
|
683
683
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
@@ -726,10 +726,10 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
726
726
|
*
|
|
727
727
|
* The function checks if a binary tree is perfectly balanced by comparing the minimum height and the
|
|
728
728
|
* height of the tree.
|
|
729
|
-
* @param {R |
|
|
729
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The parameter `beginRoot` is optional and
|
|
730
730
|
* has a default value of `this.root`. It represents the starting point for checking if the tree is
|
|
731
731
|
* perfectly balanced. It can be either a root node (`R`), a key or node or entry
|
|
732
|
-
* (`
|
|
732
|
+
* (`BTNKeyOrNodeOrEntry<K, V, NODE
|
|
733
733
|
* @returns a boolean value.
|
|
734
734
|
*/
|
|
735
735
|
isPerfectlyBalanced(beginRoot = this.root) {
|
|
@@ -744,7 +744,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
744
744
|
* Space Complexity: O(1)
|
|
745
745
|
*
|
|
746
746
|
* The function `isBST` checks if a binary search tree is valid, either recursively or iteratively.
|
|
747
|
-
* @param {R |
|
|
747
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
748
748
|
* starting point for checking if a binary search tree (BST) is valid. It can be either a root node
|
|
749
749
|
* of the BST, a key value of a node in the BST, or an entry object containing both the key and value
|
|
750
750
|
* of a node in the BST
|
|
@@ -804,10 +804,10 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
804
804
|
* Space Complexity: O(1)
|
|
805
805
|
*
|
|
806
806
|
* The function calculates the depth of a given node or key in a tree-like data structure.
|
|
807
|
-
* @param {R |
|
|
808
|
-
* (representing a root node), or a `
|
|
807
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} dist - The `dist` parameter can be either a `R`
|
|
808
|
+
* (representing a root node), or a `BTNKeyOrNodeOrEntry<K, V, NODE>` (representing a key, node, or
|
|
809
809
|
* entry).
|
|
810
|
-
* @param {R |
|
|
810
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is optional and
|
|
811
811
|
* represents the starting point from which to calculate the depth. It can be either a reference to a
|
|
812
812
|
* node in the tree or a key-value pair or an entry object. If not provided, the default value is
|
|
813
813
|
* `this.root`, which refers to the root node
|
|
@@ -836,9 +836,9 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
836
836
|
*
|
|
837
837
|
* The `getHeight` function calculates the maximum height of a binary tree using either a recursive
|
|
838
838
|
* or iterative approach.
|
|
839
|
-
* @param {R |
|
|
839
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
840
840
|
* starting point for calculating the height of a tree. It can be either a root node (`R`), a key or
|
|
841
|
-
* node or entry (`
|
|
841
|
+
* node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current tree.
|
|
842
842
|
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of
|
|
843
843
|
* iteration used to calculate the height of the tree. It can have two possible values:
|
|
844
844
|
* @returns the maximum height of the binary tree.
|
|
@@ -881,9 +881,9 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
881
881
|
*
|
|
882
882
|
* The `getMinHeight` function calculates the minimum height of a binary tree using either a
|
|
883
883
|
* recursive or iterative approach.
|
|
884
|
-
* @param {R |
|
|
884
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
885
885
|
* starting point for calculating the minimum height of a tree. It can be either a root node (`R`), a
|
|
886
|
-
* key or node or entry (`
|
|
886
|
+
* key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current
|
|
887
887
|
* tree.
|
|
888
888
|
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of
|
|
889
889
|
* iteration to be used when calculating the minimum height of the tree. It can have two possible
|
|
@@ -946,8 +946,8 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
946
946
|
*
|
|
947
947
|
* The function `getPathToRoot` returns an array of nodes starting from a given node and traversing
|
|
948
948
|
* up to the root node, with an option to reverse the order of the nodes.
|
|
949
|
-
* @param {R |
|
|
950
|
-
* type `R` or `
|
|
949
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginNode - The `beginNode` parameter can be either of
|
|
950
|
+
* type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
951
951
|
* @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
|
|
952
952
|
* resulting path should be reversed or not. If `isReverse` is set to `true`, the path will be
|
|
953
953
|
* reversed before returning it. If `isReverse` is set to `false` or not provided, the path will
|
|
@@ -976,9 +976,9 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
976
976
|
*
|
|
977
977
|
* The `getLeftMost` function returns the leftmost node in a binary tree, either using recursive or
|
|
978
978
|
* iterative traversal.
|
|
979
|
-
* @param {R |
|
|
979
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
980
980
|
* starting point for finding the leftmost node in a binary tree. It can be either a root node (`R`),
|
|
981
|
-
* a key or node or entry (`
|
|
981
|
+
* a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
|
|
982
982
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
983
983
|
* of iteration to be performed. It can have two possible values:
|
|
984
984
|
* @returns The function `getLeftMost` returns the leftmost node in a binary tree.
|
|
@@ -1017,9 +1017,9 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1017
1017
|
*
|
|
1018
1018
|
* The `getRightMost` function returns the rightmost node in a binary tree, either recursively or
|
|
1019
1019
|
* iteratively.
|
|
1020
|
-
* @param {R |
|
|
1020
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
1021
1021
|
* starting point for finding the rightmost node in a binary tree. It can be either a root node
|
|
1022
|
-
* (`R`), a key or node or entry (`
|
|
1022
|
+
* (`R`), a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
|
|
1023
1023
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
1024
1024
|
* of iteration to be performed when finding the rightmost node in a binary tree. It can have two
|
|
1025
1025
|
* possible values:
|
|
@@ -1119,7 +1119,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1119
1119
|
* return type of the callback function is determined by the generic type `C`.
|
|
1120
1120
|
* @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter determines the order in which the
|
|
1121
1121
|
* nodes are visited during the depth-first search. It can have one of the following values:
|
|
1122
|
-
* @param {R |
|
|
1122
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
1123
1123
|
* point of the depth-first search. It can be either a node object, a key-value pair, or a key. If it
|
|
1124
1124
|
* is a key or key-value pair, the method will find the corresponding node in the tree and start the
|
|
1125
1125
|
* search from there.
|
|
@@ -1250,7 +1250,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1250
1250
|
* @param {C} callback - The `callback` parameter is a function that will be called for each node in
|
|
1251
1251
|
* the breadth-first search traversal. It takes a single argument, which is the current node being
|
|
1252
1252
|
* visited, and returns a value of any type.
|
|
1253
|
-
* @param {R |
|
|
1253
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
1254
1254
|
* starting point of the breadth-first search. It can be either a root node of a tree or a key, node,
|
|
1255
1255
|
* or entry object. If no value is provided, the `root` property of the class is used as the default
|
|
1256
1256
|
* starting point.
|
|
@@ -1328,7 +1328,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1328
1328
|
* @param {C} callback - The `callback` parameter is a function that will be called for each node in
|
|
1329
1329
|
* the tree. It takes a node as an argument and returns a value. The return type of the callback
|
|
1330
1330
|
* function is determined by the generic type `C` which extends `BTNCallback<NODE | null>`.
|
|
1331
|
-
* @param {R |
|
|
1331
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
1332
1332
|
* starting point for traversing the tree. It can be either a root node, a key-value pair, or a node
|
|
1333
1333
|
* entry. If no value is provided, the `root` property of the class is used as the default starting
|
|
1334
1334
|
* point.
|
|
@@ -1406,7 +1406,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1406
1406
|
* @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter in the `morris` function is used
|
|
1407
1407
|
* to specify the order in which the nodes of a binary tree are traversed. It can take one of the
|
|
1408
1408
|
* following values:
|
|
1409
|
-
* @param {R |
|
|
1409
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
1410
1410
|
* point for the traversal. It can be either a node object, a key, or an entry object. If no value is
|
|
1411
1411
|
* provided, the `root` of the tree is used as the starting point.
|
|
1412
1412
|
* @returns The function `morris` returns an array of values that are the return values of the
|
|
@@ -1592,7 +1592,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1592
1592
|
* Space Complexity: O(n)
|
|
1593
1593
|
*
|
|
1594
1594
|
* The `print` function in TypeScript prints the binary tree structure with customizable options.
|
|
1595
|
-
* @param {R |
|
|
1595
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
1596
1596
|
* point for printing the binary tree. It can be either a node of the binary tree or a key or entry
|
|
1597
1597
|
* that exists in the binary tree. If no value is provided, the root of the binary tree will be used
|
|
1598
1598
|
* as the starting point.
|
|
@@ -1675,7 +1675,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1675
1675
|
*
|
|
1676
1676
|
* The `_displayAux` function is responsible for generating the display layout of a binary tree node,
|
|
1677
1677
|
* taking into account various options such as whether to show null, undefined, or NaN nodes.
|
|
1678
|
-
* @param {NODE
|
|
1678
|
+
* @param {OptBTNOrNull<NODE>} node - The `node` parameter represents a node in a binary tree.
|
|
1679
1679
|
* It can be of type `NODE`, `null`, or `undefined`.
|
|
1680
1680
|
* @param {BinaryTreePrintOptions} options - The `options` parameter is an object that contains the
|
|
1681
1681
|
* following properties:
|
|
@@ -1747,10 +1747,10 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1747
1747
|
* Space Complexity: O(1)
|
|
1748
1748
|
*
|
|
1749
1749
|
* The function `_swapProperties` swaps the key-value properties between two nodes.
|
|
1750
|
-
* @param {R |
|
|
1750
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} srcNode - The source node that will be swapped with the
|
|
1751
1751
|
* destination node. It can be either an instance of the class `R`, or an object of type
|
|
1752
|
-
* `
|
|
1753
|
-
* @param {R |
|
|
1752
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
1753
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} destNode - The `destNode` parameter is the node where
|
|
1754
1754
|
* the properties will be swapped with the `srcNode`.
|
|
1755
1755
|
* @returns either the `destNode` object with its properties swapped with the `srcNode` object's
|
|
1756
1756
|
* properties, or `undefined` if either `srcNode` or `destNode` is falsy.
|
|
@@ -1814,7 +1814,7 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
1814
1814
|
*
|
|
1815
1815
|
* The function sets the root property of an object to the provided value, and also updates the
|
|
1816
1816
|
* parent property of the new root.
|
|
1817
|
-
* @param {NODE
|
|
1817
|
+
* @param {OptBTNOrNull<NODE>} v - The parameter `v` is of type `OptBTNOrNull<NODE>`. This
|
|
1818
1818
|
* means that it can accept a value of type `NODE`, `null`, or `undefined`.
|
|
1819
1819
|
*/
|
|
1820
1820
|
_setRoot(v) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, Comparator, CP, DFSOrderPattern, IterationType,
|
|
8
|
+
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNKeyOrNodeOrEntry, Comparator, CP, DFSOrderPattern, IterationType, OptBSTN } from '../../types';
|
|
9
9
|
import { BTNEntry } from '../../types';
|
|
10
10
|
import { BinaryTree, BinaryTreeNode } from './binary-tree';
|
|
11
11
|
import { IBinaryTree } from '../../interfaces';
|
|
@@ -17,26 +17,26 @@ export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE>
|
|
|
17
17
|
* The function returns the value of the `_left` property.
|
|
18
18
|
* @returns The `_left` property of the current object is being returned.
|
|
19
19
|
*/
|
|
20
|
-
get left(): NODE
|
|
20
|
+
get left(): OptBSTN<NODE>;
|
|
21
21
|
/**
|
|
22
22
|
* The function sets the left child of a node and updates the parent reference of the child.
|
|
23
|
-
* @param {NODE
|
|
23
|
+
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be an
|
|
24
24
|
* instance of the `NODE` class or `undefined`.
|
|
25
25
|
*/
|
|
26
|
-
set left(v: NODE
|
|
26
|
+
set left(v: OptBSTN<NODE>);
|
|
27
27
|
protected _right?: NODE;
|
|
28
28
|
/**
|
|
29
29
|
* The function returns the right node of a binary tree or undefined if there is no right node.
|
|
30
30
|
* @returns The method is returning the value of the `_right` property, which is of type `NODE` or
|
|
31
31
|
* `undefined`.
|
|
32
32
|
*/
|
|
33
|
-
get right(): NODE
|
|
33
|
+
get right(): OptBSTN<NODE>;
|
|
34
34
|
/**
|
|
35
35
|
* The function sets the right child of a node and updates the parent reference of the child.
|
|
36
|
-
* @param {NODE
|
|
36
|
+
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be a
|
|
37
37
|
* `NODE` object or `undefined`.
|
|
38
38
|
*/
|
|
39
|
-
set right(v: NODE
|
|
39
|
+
set right(v: OptBSTN<NODE>);
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* 1. Node Order: Each node's left child has a lesser value, and the right child has a greater value.
|
|
@@ -56,13 +56,13 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
56
56
|
* @param [options] - An optional object that contains additional options for the Binary Search Tree.
|
|
57
57
|
* It can include a comparator function that defines the order of the elements in the tree.
|
|
58
58
|
*/
|
|
59
|
-
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R |
|
|
59
|
+
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: BSTOptions<K, V, R>);
|
|
60
60
|
protected _root?: NODE;
|
|
61
61
|
/**
|
|
62
62
|
* The function returns the root node of a tree structure.
|
|
63
63
|
* @returns The `_root` property of the object, which is of type `NODE` or `undefined`.
|
|
64
64
|
*/
|
|
65
|
-
get root(): NODE
|
|
65
|
+
get root(): OptBSTN<NODE>;
|
|
66
66
|
/**
|
|
67
67
|
* The function creates a new BSTNode with the given key and value and returns it.
|
|
68
68
|
* @param {K} key - The key parameter is of type K, which represents the type of the key for the node
|
|
@@ -82,21 +82,21 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
82
82
|
createTree(options?: Partial<BSTOptions<K, V, R>>): TREE;
|
|
83
83
|
/**
|
|
84
84
|
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
|
|
85
|
-
* @param {R |
|
|
86
|
-
* type R or
|
|
85
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of
|
|
86
|
+
* type R or BTNKeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw
|
|
87
87
|
* element.
|
|
88
88
|
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
|
|
89
89
|
* value associated with a key in a key-value pair.
|
|
90
90
|
* @returns either a NODE object or undefined.
|
|
91
91
|
*/
|
|
92
|
-
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R |
|
|
92
|
+
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): OptBSTN<NODE>;
|
|
93
93
|
/**
|
|
94
94
|
* Time Complexity: O(log n)
|
|
95
95
|
* Space Complexity: O(log n)
|
|
96
96
|
*
|
|
97
97
|
* The function ensures the existence of a node in a data structure and returns it, or undefined if
|
|
98
98
|
* it doesn't exist.
|
|
99
|
-
* @param {R |
|
|
99
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
100
100
|
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, which represents the key, node,
|
|
101
101
|
* entry, or raw element that needs to be ensured in the tree.
|
|
102
102
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
|
|
@@ -105,27 +105,27 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
105
105
|
* @returns The method is returning either the node that was ensured or `undefined` if the node could
|
|
106
106
|
* not be ensured.
|
|
107
107
|
*/
|
|
108
|
-
ensureNode(keyOrNodeOrEntryOrRawElement: R |
|
|
108
|
+
ensureNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBSTN<NODE>;
|
|
109
109
|
/**
|
|
110
110
|
* The function checks if the input is an instance of the BSTNode class.
|
|
111
|
-
* @param {R |
|
|
112
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
111
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
112
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
113
113
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
114
114
|
* an instance of the `BSTNode` class.
|
|
115
115
|
*/
|
|
116
|
-
isNode(keyOrNodeOrEntryOrRawElement: R |
|
|
116
|
+
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
|
|
117
117
|
/**
|
|
118
118
|
* Time Complexity: O(log n)
|
|
119
119
|
* Space Complexity: O(1)
|
|
120
120
|
*
|
|
121
121
|
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value.
|
|
122
|
-
* @param {R |
|
|
123
|
-
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `
|
|
122
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
123
|
+
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
124
124
|
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the
|
|
125
125
|
* key in the binary search tree. If provided, it will be stored in the node along with the key.
|
|
126
126
|
* @returns a boolean value.
|
|
127
127
|
*/
|
|
128
|
-
add(keyOrNodeOrEntryOrRawElement: R |
|
|
128
|
+
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
|
|
129
129
|
/**
|
|
130
130
|
* Time Complexity: O(log n)
|
|
131
131
|
* Space Complexity: O(log n)
|
|
@@ -151,7 +151,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
151
151
|
* @returns The function `addMany` returns an array of booleans indicating whether each element was
|
|
152
152
|
* successfully inserted into the data structure.
|
|
153
153
|
*/
|
|
154
|
-
addMany(keysOrNodesOrEntriesOrRawElements: Iterable<R |
|
|
154
|
+
addMany(keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
|
|
155
155
|
/**
|
|
156
156
|
* Time Complexity: O(log n)
|
|
157
157
|
* Space Complexity: O(k + log n)
|
|
@@ -167,14 +167,14 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
167
167
|
* @param [onlyOne=false] - A boolean value indicating whether to return only the first matching node
|
|
168
168
|
* or all matching nodes. If set to true, only the first matching node will be returned. If set to
|
|
169
169
|
* false, all matching nodes will be returned. The default value is false.
|
|
170
|
-
* @param {R |
|
|
170
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
171
171
|
* point for the search in the binary tree. It can be either a node object, a key-value pair, or an
|
|
172
172
|
* entry object. If it is not provided, the `root` of the binary tree is used as the starting point.
|
|
173
173
|
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of
|
|
174
174
|
* iteration to be performed. It can have two possible values:
|
|
175
175
|
* @returns The method `getNodes` returns an array of `NODE` objects.
|
|
176
176
|
*/
|
|
177
|
-
getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: R |
|
|
177
|
+
getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[];
|
|
178
178
|
/**
|
|
179
179
|
* Time Complexity: O(log n)
|
|
180
180
|
* Space Complexity: O(1)
|
|
@@ -200,7 +200,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
200
200
|
* of the following values:
|
|
201
201
|
* @returns The method is returning a NODE object or undefined.
|
|
202
202
|
*/
|
|
203
|
-
getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): NODE
|
|
203
|
+
getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): OptBSTN<NODE>;
|
|
204
204
|
/**
|
|
205
205
|
* Time Complexity: O(k log n)
|
|
206
206
|
* Space Complexity: O(k + log n)
|
|
@@ -218,7 +218,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
218
218
|
* It has a default value of `'ITERATIVE'`.
|
|
219
219
|
* @returns The method is returning a NODE object or undefined.
|
|
220
220
|
*/
|
|
221
|
-
getNodeByKey(key: K, iterationType?: IterationType): NODE
|
|
221
|
+
getNodeByKey(key: K, iterationType?: IterationType): OptBSTN<NODE>;
|
|
222
222
|
/**
|
|
223
223
|
* Time Complexity: O(log n)
|
|
224
224
|
* Space Complexity: O(k + log n)
|
|
@@ -235,7 +235,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
235
235
|
* @param {DFSOrderPattern} [pattern=IN] - The "pattern" parameter in the code snippet refers to the
|
|
236
236
|
* order in which the Depth-First Search (DFS) algorithm visits the nodes in a tree or graph. It can
|
|
237
237
|
* take one of the following values:
|
|
238
|
-
* @param {R |
|
|
238
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
239
239
|
* point for the depth-first search traversal. It can be either a root node, a key-value pair, or a
|
|
240
240
|
* node entry. If not specified, the default value is the root of the tree.
|
|
241
241
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter specifies the
|
|
@@ -243,7 +243,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
243
243
|
* following values:
|
|
244
244
|
* @returns The method is returning an array of the return type of the callback function.
|
|
245
245
|
*/
|
|
246
|
-
dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R |
|
|
246
|
+
dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
|
|
247
247
|
/**
|
|
248
248
|
* Time Complexity: O(log n)
|
|
249
249
|
* Space Complexity: O(1)
|
|
@@ -257,7 +257,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
257
257
|
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
258
258
|
* visited during the breadth-first search. It should take a single argument, which is the current
|
|
259
259
|
* node being visited, and it can return a value of any type.
|
|
260
|
-
* @param {R |
|
|
260
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
261
261
|
* point for the breadth-first search. It can be either a root node, a key-value pair, or an entry
|
|
262
262
|
* object. If no value is provided, the default value is the root of the tree.
|
|
263
263
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
@@ -265,7 +265,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
265
265
|
* the following values:
|
|
266
266
|
* @returns an array of the return type of the callback function.
|
|
267
267
|
*/
|
|
268
|
-
bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R |
|
|
268
|
+
bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
|
|
269
269
|
/**
|
|
270
270
|
* Time Complexity: O(log n)
|
|
271
271
|
* Space Complexity: O(1)
|
|
@@ -279,7 +279,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
279
279
|
* @param {C} callback - The `callback` parameter is a generic type `C` that extends
|
|
280
280
|
* `BTNCallback<NODE>`. It represents a callback function that will be called for each node in the
|
|
281
281
|
* tree during the iteration process.
|
|
282
|
-
* @param {R |
|
|
282
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
283
283
|
* point for listing the levels of the binary tree. It can be either a root node of the tree, a
|
|
284
284
|
* key-value pair representing a node in the tree, or a key representing a node in the tree. If no
|
|
285
285
|
* value is provided, the root of
|
|
@@ -288,7 +288,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
288
288
|
* @returns The method is returning a two-dimensional array of the return type of the callback
|
|
289
289
|
* function.
|
|
290
290
|
*/
|
|
291
|
-
listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R |
|
|
291
|
+
listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[][];
|
|
292
292
|
/**
|
|
293
293
|
* Time complexity: O(n)
|
|
294
294
|
* Space complexity: O(n)
|
|
@@ -305,7 +305,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
305
305
|
* @param {CP} lesserOrGreater - The `lesserOrGreater` parameter is used to determine whether to
|
|
306
306
|
* traverse nodes that are lesser, greater, or both than the `targetNode`. It accepts the values -1,
|
|
307
307
|
* 0, or 1, where:
|
|
308
|
-
* @param {R |
|
|
308
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in
|
|
309
309
|
* the binary tree that you want to start traversing from. It can be specified either by providing
|
|
310
310
|
* the key of the node, the node itself, or an entry containing the key and value of the node. If no
|
|
311
311
|
* `targetNode` is provided,
|
|
@@ -314,7 +314,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
314
314
|
* @returns The function `lesserOrGreaterTraverse` returns an array of values of type
|
|
315
315
|
* `ReturnType<C>`, which is the return type of the callback function passed as an argument.
|
|
316
316
|
*/
|
|
317
|
-
lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: R |
|
|
317
|
+
lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[];
|
|
318
318
|
/**
|
|
319
319
|
* Time complexity: O(n)
|
|
320
320
|
* Space complexity: O(n)
|
|
@@ -363,7 +363,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
363
363
|
/**
|
|
364
364
|
* The function sets the root of a tree-like structure and updates the parent property of the new
|
|
365
365
|
* root.
|
|
366
|
-
* @param {NODE
|
|
366
|
+
* @param {OptBSTN<NODE>} v - v is a parameter of type NODE or undefined.
|
|
367
367
|
*/
|
|
368
|
-
protected _setRoot(v: NODE
|
|
368
|
+
protected _setRoot(v: OptBSTN<NODE>): void;
|
|
369
369
|
}
|