mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 04:44:04 +00:00
fix: The default value for the iterationType parameter in all binary tree methods is the member variable this.iterationType.
This commit is contained in:
parent
a699b097c7
commit
42235802c3
|
@ -288,7 +288,7 @@ export class BinaryTree<
|
|||
*/
|
||||
ensureNode(
|
||||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>,
|
||||
iterationType: IterationType = 'ITERATIVE'
|
||||
iterationType: IterationType = this.iterationType
|
||||
): OptBTNOrNull<NODE> {
|
||||
if (keyOrNodeOrEntryOrRawElement === null) return null;
|
||||
if (keyOrNodeOrEntryOrRawElement === undefined) return;
|
||||
|
@ -800,7 +800,7 @@ export class BinaryTree<
|
|||
* It has a default value of `'ITERATIVE'`.
|
||||
* @returns a value of type NODE, null, or undefined.
|
||||
*/
|
||||
getNodeByKey(key: K, iterationType: IterationType = 'ITERATIVE'): OptBTNOrNull<NODE> {
|
||||
getNodeByKey(key: K, iterationType: IterationType = this.iterationType): OptBTNOrNull<NODE> {
|
||||
return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType);
|
||||
}
|
||||
|
||||
|
@ -1417,7 +1417,7 @@ export class BinaryTree<
|
|||
callback: C = this._DEFAULT_CALLBACK as C,
|
||||
pattern: DFSOrderPattern = 'IN',
|
||||
beginRoot: R | BTNKeyOrNodeOrEntry<K, V, NODE> = this.root,
|
||||
iterationType: IterationType = 'ITERATIVE',
|
||||
iterationType: IterationType = this.iterationType,
|
||||
includeNull = false
|
||||
): ReturnType<C>[] {
|
||||
beginRoot = this.ensureNode(beginRoot);
|
||||
|
|
|
@ -195,7 +195,7 @@ export class BST<
|
|||
*/
|
||||
override ensureNode(
|
||||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>,
|
||||
iterationType: IterationType = 'ITERATIVE'
|
||||
iterationType: IterationType = this.iterationType
|
||||
): OptBSTN<NODE> {
|
||||
return super.ensureNode(keyOrNodeOrEntryOrRawElement, iterationType) ?? undefined;
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ export class BST<
|
|||
* It has a default value of `'ITERATIVE'`.
|
||||
* @returns The method is returning a NODE object or undefined.
|
||||
*/
|
||||
override getNodeByKey(key: K, iterationType: IterationType = 'ITERATIVE'): OptBSTN<NODE> {
|
||||
override getNodeByKey(key: K, iterationType: IterationType = this.iterationType): OptBSTN<NODE> {
|
||||
return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType);
|
||||
}
|
||||
|
||||
|
@ -555,7 +555,7 @@ export class BST<
|
|||
callback: C = this._DEFAULT_CALLBACK as C,
|
||||
pattern: DFSOrderPattern = 'IN',
|
||||
beginRoot: R | BTNKeyOrNodeOrEntry<K, V, NODE> = this.root,
|
||||
iterationType: IterationType = 'ITERATIVE'
|
||||
iterationType: IterationType = this.iterationType
|
||||
): ReturnType<C>[] {
|
||||
return super.dfs(callback, pattern, beginRoot, iterationType, false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue