undirected-graph-typed 1.52.5 → 1.52.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.
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.js +8 -0
- package/dist/data-structures/base/iterable-element-base.d.ts +8 -1
- package/dist/data-structures/base/iterable-element-base.js +10 -1
- package/dist/data-structures/base/iterable-entry-base.d.ts +8 -1
- package/dist/data-structures/base/iterable-entry-base.js +10 -10
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +31 -32
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +43 -44
- package/dist/data-structures/binary-tree/avl-tree.d.ts +23 -24
- package/dist/data-structures/binary-tree/avl-tree.js +71 -64
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +2 -2
- package/dist/data-structures/binary-tree/binary-tree.d.ts +534 -402
- package/dist/data-structures/binary-tree/binary-tree.js +669 -598
- package/dist/data-structures/binary-tree/bst.d.ts +72 -65
- package/dist/data-structures/binary-tree/bst.js +115 -113
- package/dist/data-structures/binary-tree/rb-tree.d.ts +21 -24
- package/dist/data-structures/binary-tree/rb-tree.js +40 -39
- package/dist/data-structures/binary-tree/segment-tree.d.ts +2 -2
- package/dist/data-structures/binary-tree/segment-tree.js +2 -2
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +28 -31
- package/dist/data-structures/binary-tree/tree-multi-map.js +44 -43
- package/dist/data-structures/graph/abstract-graph.d.ts +2 -2
- package/dist/data-structures/graph/abstract-graph.js +7 -4
- package/dist/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/data-structures/graph/directed-graph.js +4 -2
- package/dist/data-structures/graph/undirected-graph.d.ts +2 -2
- package/dist/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/data-structures/hash/hash-map.js +1 -1
- package/dist/data-structures/heap/heap.js +3 -3
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/data-structures/linked-list/doubly-linked-list.js +7 -7
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/data-structures/linked-list/singly-linked-list.js +6 -6
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -2
- package/dist/data-structures/matrix/matrix.d.ts +2 -2
- package/dist/data-structures/matrix/navigator.d.ts +2 -2
- package/dist/data-structures/matrix/navigator.js +4 -2
- package/dist/data-structures/queue/deque.d.ts +3 -3
- package/dist/data-structures/queue/deque.js +29 -29
- package/dist/data-structures/queue/queue.d.ts +1 -1
- package/dist/data-structures/stack/stack.d.ts +2 -2
- package/dist/data-structures/trie/trie.d.ts +2 -2
- package/dist/data-structures/trie/trie.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/binary-tree.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +2 -4
- package/dist/types/data-structures/binary-tree/binary-tree.js +0 -6
- package/package.json +2 -2
- package/src/constants/index.ts +4 -0
- package/src/data-structures/base/iterable-element-base.ts +11 -1
- package/src/data-structures/base/iterable-entry-base.ts +11 -19
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +47 -50
- package/src/data-structures/binary-tree/avl-tree.ts +69 -71
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +698 -726
- package/src/data-structures/binary-tree/bst.ts +123 -129
- package/src/data-structures/binary-tree/rb-tree.ts +44 -46
- package/src/data-structures/binary-tree/segment-tree.ts +2 -2
- package/src/data-structures/binary-tree/tree-multi-map.ts +48 -49
- package/src/data-structures/graph/abstract-graph.ts +6 -6
- package/src/data-structures/graph/directed-graph.ts +4 -4
- package/src/data-structures/graph/undirected-graph.ts +2 -2
- package/src/data-structures/hash/hash-map.ts +3 -3
- package/src/data-structures/heap/heap.ts +3 -3
- package/src/data-structures/linked-list/doubly-linked-list.ts +9 -9
- package/src/data-structures/linked-list/singly-linked-list.ts +8 -8
- package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
- package/src/data-structures/matrix/matrix.ts +2 -2
- package/src/data-structures/matrix/navigator.ts +4 -4
- package/src/data-structures/queue/deque.ts +31 -31
- package/src/data-structures/queue/queue.ts +1 -1
- package/src/data-structures/stack/stack.ts +2 -2
- package/src/data-structures/trie/trie.ts +3 -3
- package/src/index.ts +2 -1
- package/src/interfaces/binary-tree.ts +3 -3
- package/src/types/data-structures/binary-tree/binary-tree.ts +3 -5
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* data-structure-typed
|
|
3
3
|
*
|
|
4
|
-
* @author
|
|
5
|
-
* @copyright Copyright (c) 2022
|
|
4
|
+
* @author Pablo Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNKeyOrNodeOrEntry, Comparator, CP, DFSOrderPattern, IterationType, OptBSTN } from '../../types';
|
|
9
|
-
import { BTNEntry } from '../../types';
|
|
8
|
+
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNEntry, BTNKeyOrNodeOrEntry, BTNPredicate, Comparator, CP, DFSOrderPattern, IterationType, OptBSTN } from '../../types';
|
|
10
9
|
import { BinaryTree, BinaryTreeNode } from './binary-tree';
|
|
11
10
|
import { IBinaryTree } from '../../interfaces';
|
|
12
11
|
export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V>> extends BinaryTreeNode<K, V, NODE> {
|
|
@@ -50,13 +49,13 @@ export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE>
|
|
|
50
49
|
export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>, TREE extends BST<K, V, R, NODE, TREE> = BST<K, V, R, NODE, BSTNested<K, V, R, NODE>>> extends BinaryTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
|
|
51
50
|
/**
|
|
52
51
|
* This is the constructor function for a Binary Search Tree class in TypeScript.
|
|
53
|
-
* @param
|
|
52
|
+
* @param keysOrNodesOrEntriesOrRaws - The `keysOrNodesOrEntriesOrRaws` parameter is an
|
|
54
53
|
* iterable that can contain either keys, nodes, entries, or raw elements. These elements will be
|
|
55
54
|
* added to the binary search tree during the construction of the object.
|
|
56
55
|
* @param [options] - An optional object that contains additional options for the Binary Search Tree.
|
|
57
56
|
* It can include a comparator function that defines the order of the elements in the tree.
|
|
58
57
|
*/
|
|
59
|
-
constructor(
|
|
58
|
+
constructor(keysOrNodesOrEntriesOrRaws?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: BSTOptions<K, V, R>);
|
|
60
59
|
protected _root?: NODE;
|
|
61
60
|
/**
|
|
62
61
|
* The function returns the root node of a tree structure.
|
|
@@ -79,25 +78,25 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
79
78
|
* following properties:
|
|
80
79
|
* @returns a new instance of the BST class with the provided options.
|
|
81
80
|
*/
|
|
82
|
-
createTree(options?:
|
|
81
|
+
createTree(options?: BSTOptions<K, V, R>): TREE;
|
|
83
82
|
/**
|
|
84
83
|
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
|
|
85
|
-
* @param {
|
|
84
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - A variable that can be of
|
|
86
85
|
* type R or BTNKeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw
|
|
87
86
|
* element.
|
|
88
87
|
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
|
|
89
88
|
* value associated with a key in a key-value pair.
|
|
90
89
|
* @returns either a NODE object or undefined.
|
|
91
90
|
*/
|
|
92
|
-
keyValueOrEntryOrRawElementToNode(
|
|
91
|
+
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V): OptBSTN<NODE>;
|
|
93
92
|
/**
|
|
94
93
|
* Time Complexity: O(log n)
|
|
95
94
|
* Space Complexity: O(log n)
|
|
96
95
|
*
|
|
97
96
|
* The function ensures the existence of a node in a data structure and returns it, or undefined if
|
|
98
97
|
* it doesn't exist.
|
|
99
|
-
* @param {
|
|
100
|
-
* `
|
|
98
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
|
|
99
|
+
* `keyOrNodeOrEntryOrRaw` can accept a value of type `R`, which represents the key, node,
|
|
101
100
|
* entry, or raw element that needs to be ensured in the tree.
|
|
102
101
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
|
|
103
102
|
* parameter that specifies the type of iteration to be used when ensuring a node. It has a default
|
|
@@ -105,35 +104,43 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
105
104
|
* @returns The method is returning either the node that was ensured or `undefined` if the node could
|
|
106
105
|
* not be ensured.
|
|
107
106
|
*/
|
|
108
|
-
ensureNode(
|
|
107
|
+
ensureNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): OptBSTN<NODE>;
|
|
109
108
|
/**
|
|
110
109
|
* The function checks if the input is an instance of the BSTNode class.
|
|
111
|
-
* @param {
|
|
112
|
-
* `
|
|
113
|
-
* @returns a boolean value indicating whether the input parameter `
|
|
110
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
|
|
111
|
+
* `keyOrNodeOrEntryOrRaw` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
112
|
+
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRaw` is
|
|
114
113
|
* an instance of the `BSTNode` class.
|
|
115
114
|
*/
|
|
116
|
-
isNode(
|
|
115
|
+
isNode(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R): keyOrNodeOrEntryOrRaw is NODE;
|
|
116
|
+
/**
|
|
117
|
+
* The function "override isKey" checks if a key is comparable based on a given comparator.
|
|
118
|
+
* @param {any} key - The `key` parameter is a value that will be checked to determine if it is of
|
|
119
|
+
* type `K`.
|
|
120
|
+
* @returns The `override isKey(key: any): key is K` function is returning a boolean value based on
|
|
121
|
+
* the result of the `isComparable` function with the condition `this.comparator !==
|
|
122
|
+
* this._DEFAULT_COMPARATOR`.
|
|
123
|
+
*/
|
|
117
124
|
isKey(key: any): key is K;
|
|
118
125
|
/**
|
|
119
126
|
* Time Complexity: O(log n)
|
|
120
127
|
* Space Complexity: O(1)
|
|
121
128
|
*
|
|
122
129
|
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value.
|
|
123
|
-
* @param {
|
|
124
|
-
* `
|
|
130
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} keyOrNodeOrEntryOrRaw - The parameter
|
|
131
|
+
* `keyOrNodeOrEntryOrRaw` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
125
132
|
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the
|
|
126
133
|
* key in the binary search tree. If provided, it will be stored in the node along with the key.
|
|
127
134
|
* @returns a boolean value.
|
|
128
135
|
*/
|
|
129
|
-
add(
|
|
136
|
+
add(keyOrNodeOrEntryOrRaw: BTNKeyOrNodeOrEntry<K, V, NODE> | R, value?: V): boolean;
|
|
130
137
|
/**
|
|
131
138
|
* Time Complexity: O(k log n)
|
|
132
139
|
* Space Complexity: O(k + log n)
|
|
133
140
|
*
|
|
134
141
|
* The `addMany` function in TypeScript adds multiple keys or nodes to a data structure and returns
|
|
135
142
|
* an array indicating whether each key or node was successfully inserted.
|
|
136
|
-
* @param
|
|
143
|
+
* @param keysOrNodesOrEntriesOrRaws - An iterable containing keys, nodes, entries, or raw
|
|
137
144
|
* elements to be added to the data structure.
|
|
138
145
|
* @param [values] - An optional iterable of values to be associated with the keys or nodes being
|
|
139
146
|
* added. If provided, the values will be assigned to the corresponding keys or nodes in the same
|
|
@@ -148,52 +155,52 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
148
155
|
* @returns The function `addMany` returns an array of booleans indicating whether each element was
|
|
149
156
|
* successfully inserted into the data structure.
|
|
150
157
|
*/
|
|
151
|
-
addMany(
|
|
158
|
+
addMany(keysOrNodesOrEntriesOrRaws: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
|
|
152
159
|
/**
|
|
153
160
|
* Time Complexity: O(log n)
|
|
154
161
|
* Space Complexity: O(k + log n)
|
|
155
162
|
*
|
|
156
|
-
* The `getNodes`
|
|
157
|
-
*
|
|
158
|
-
* @param {
|
|
159
|
-
*
|
|
160
|
-
* function
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* @param {IterationType} iterationType - The `iterationType` parameter
|
|
171
|
-
* iteration to be performed
|
|
172
|
-
*
|
|
163
|
+
* The function `getNodes` in TypeScript overrides the base class method to retrieve nodes based on a
|
|
164
|
+
* given predicate and iteration type.
|
|
165
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>} predicate - The `predicate`
|
|
166
|
+
* parameter in the `getNodes` method is used to filter the nodes that will be returned. It can be a
|
|
167
|
+
* key, a node, an entry, or a custom predicate function that determines whether a node should be
|
|
168
|
+
* included in the result.
|
|
169
|
+
* @param [onlyOne=false] - The `onlyOne` parameter in the `getNodes` method is a boolean flag that
|
|
170
|
+
* determines whether to return only the first node that matches the predicate (`true`) or all nodes
|
|
171
|
+
* that match the predicate (`false`). If `onlyOne` is set to `true`, the method will stop iterating
|
|
172
|
+
* and
|
|
173
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} beginRoot - The `beginRoot` parameter in the
|
|
174
|
+
* `getNodes` method is used to specify the starting point for traversing the tree when searching for
|
|
175
|
+
* nodes that match a given predicate. It represents the root node of the subtree where the search
|
|
176
|
+
* should begin. If not explicitly provided, the default value for `begin
|
|
177
|
+
* @param {IterationType} iterationType - The `iterationType` parameter in the `getNodes` method
|
|
178
|
+
* specifies the type of iteration to be performed when traversing the nodes of a binary tree. It can
|
|
179
|
+
* have two possible values:
|
|
180
|
+
* @returns The `getNodes` method returns an array of nodes that satisfy the given predicate.
|
|
173
181
|
*/
|
|
174
|
-
getNodes<
|
|
182
|
+
getNodes(predicate: BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>, onlyOne?: boolean, beginRoot?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): NODE[];
|
|
175
183
|
/**
|
|
176
184
|
* Time Complexity: O(log n)
|
|
177
185
|
* Space Complexity: O(1)
|
|
178
186
|
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* node
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* @returns The method is returning a NODE object or undefined.
|
|
187
|
+
* This function retrieves a node based on a given predicate within a binary search tree structure.
|
|
188
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>} predicate - The `predicate`
|
|
189
|
+
* parameter can be of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, `R`, or `BTNPredicate<NODE>`.
|
|
190
|
+
* @param {R | BSTNKeyOrNode<K, NODE>} beginRoot - The `beginRoot` parameter in the `getNode` method
|
|
191
|
+
* is used to specify the starting point for searching nodes in the binary search tree. If no
|
|
192
|
+
* specific starting point is provided, the default value is set to `this._root`, which is the root
|
|
193
|
+
* node of the binary search tree.
|
|
194
|
+
* @param {IterationType} iterationType - The `iterationType` parameter in the `getNode` method is a
|
|
195
|
+
* parameter that specifies the type of iteration to be used. It has a default value of
|
|
196
|
+
* `this.iterationType`, which means it will use the iteration type defined in the class instance if
|
|
197
|
+
* no value is provided when calling the method.
|
|
198
|
+
* @returns The `getNode` method is returning an optional binary search tree node (`OptBSTN<NODE>`).
|
|
199
|
+
* It is using the `getNodes` method to find the node based on the provided predicate, beginning at
|
|
200
|
+
* the specified root node (`beginRoot`) and using the specified iteration type. The method then
|
|
201
|
+
* returns the first node found or `undefined` if no node is found.
|
|
195
202
|
*/
|
|
196
|
-
getNode<
|
|
203
|
+
getNode(predicate: BTNKeyOrNodeOrEntry<K, V, NODE> | R | BTNPredicate<NODE>, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): OptBSTN<NODE>;
|
|
197
204
|
/**
|
|
198
205
|
* Time Complexity: O(log n)
|
|
199
206
|
* Space Complexity: O(1)
|
|
@@ -216,11 +223,11 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
216
223
|
* the callback function.
|
|
217
224
|
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
218
225
|
* during the depth-first search traversal. It is an optional parameter and defaults to
|
|
219
|
-
* `this.
|
|
226
|
+
* `this._DEFAULT_BTN_CALLBACK`. The type `C` represents the type of the callback function.
|
|
220
227
|
* @param {DFSOrderPattern} [pattern=IN] - The "pattern" parameter in the code snippet refers to the
|
|
221
228
|
* order in which the Depth-First Search (DFS) algorithm visits the nodes in a tree or graph. It can
|
|
222
229
|
* take one of the following values:
|
|
223
|
-
* @param {
|
|
230
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} beginRoot - The `beginRoot` parameter is the starting
|
|
224
231
|
* point for the depth-first search traversal. It can be either a root node, a key-value pair, or a
|
|
225
232
|
* node entry. If not specified, the default value is the root of the tree.
|
|
226
233
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter specifies the
|
|
@@ -228,7 +235,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
228
235
|
* following values:
|
|
229
236
|
* @returns The method is returning an array of the return type of the callback function.
|
|
230
237
|
*/
|
|
231
|
-
dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?:
|
|
238
|
+
dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): ReturnType<C>[];
|
|
232
239
|
/**
|
|
233
240
|
* Time complexity: O(n)
|
|
234
241
|
* Space complexity: O(n)
|
|
@@ -238,7 +245,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
238
245
|
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
239
246
|
* visited during the breadth-first search. It should take a single argument, which is the current
|
|
240
247
|
* node being visited, and it can return a value of any type.
|
|
241
|
-
* @param {
|
|
248
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} beginRoot - The `beginRoot` parameter is the starting
|
|
242
249
|
* point for the breadth-first search. It can be either a root node, a key-value pair, or an entry
|
|
243
250
|
* object. If no value is provided, the default value is the root of the tree.
|
|
244
251
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
@@ -246,7 +253,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
246
253
|
* the following values:
|
|
247
254
|
* @returns an array of the return type of the callback function.
|
|
248
255
|
*/
|
|
249
|
-
bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?:
|
|
256
|
+
bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): ReturnType<C>[];
|
|
250
257
|
/**
|
|
251
258
|
* Time complexity: O(n)
|
|
252
259
|
* Space complexity: O(n)
|
|
@@ -256,7 +263,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
256
263
|
* @param {C} callback - The `callback` parameter is a generic type `C` that extends
|
|
257
264
|
* `BTNCallback<NODE>`. It represents a callback function that will be called for each node in the
|
|
258
265
|
* tree during the iteration process.
|
|
259
|
-
* @param {
|
|
266
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} beginRoot - The `beginRoot` parameter is the starting
|
|
260
267
|
* point for listing the levels of the binary tree. It can be either a root node of the tree, a
|
|
261
268
|
* key-value pair representing a node in the tree, or a key representing a node in the tree. If no
|
|
262
269
|
* value is provided, the root of
|
|
@@ -265,7 +272,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
265
272
|
* @returns The method is returning a two-dimensional array of the return type of the callback
|
|
266
273
|
* function.
|
|
267
274
|
*/
|
|
268
|
-
listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?:
|
|
275
|
+
listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): ReturnType<C>[][];
|
|
269
276
|
/**
|
|
270
277
|
* Time complexity: O(n)
|
|
271
278
|
* Space complexity: O(n)
|
|
@@ -278,7 +285,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
278
285
|
* @param {CP} lesserOrGreater - The `lesserOrGreater` parameter is used to determine whether to
|
|
279
286
|
* traverse nodes that are lesser, greater, or both than the `targetNode`. It accepts the values -1,
|
|
280
287
|
* 0, or 1, where:
|
|
281
|
-
* @param {
|
|
288
|
+
* @param {BTNKeyOrNodeOrEntry<K, V, NODE> | R} targetNode - The `targetNode` parameter is the node in
|
|
282
289
|
* the binary tree that you want to start traversing from. It can be specified either by providing
|
|
283
290
|
* the key of the node, the node itself, or an entry containing the key and value of the node. If no
|
|
284
291
|
* `targetNode` is provided,
|
|
@@ -287,7 +294,7 @@ export declare class BST<K = any, V = any, R = BTNEntry<K, V>, NODE extends BSTN
|
|
|
287
294
|
* @returns The function `lesserOrGreaterTraverse` returns an array of values of type
|
|
288
295
|
* `ReturnType<C>`, which is the return type of the callback function passed as an argument.
|
|
289
296
|
*/
|
|
290
|
-
lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?:
|
|
297
|
+
lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: BTNKeyOrNodeOrEntry<K, V, NODE> | R, iterationType?: IterationType): ReturnType<C>[];
|
|
291
298
|
/**
|
|
292
299
|
* Time complexity: O(n)
|
|
293
300
|
* Space complexity: O(n)
|