graph-typed
Advanced tools
Comparing version
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, IterationType, KeyOrNodeOrEntry } from '../../types'; | ||
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNKeyOrNodeOrEntry, IterationType } from '../../types'; | ||
import { BTNEntry } from '../../types'; | ||
@@ -50,3 +50,3 @@ import { IBinaryTree } from '../../interfaces'; | ||
*/ | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>); | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>); | ||
protected _count: number; | ||
@@ -94,13 +94,13 @@ /** | ||
* The function checks if the input is an instance of AVLTreeMultiMapNode. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
* an instance of the `AVLTreeMultiMapNode` class. | ||
*/ | ||
isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
/** | ||
* The function `keyValueOrEntryOrRawElementToNode` converts a key, value, entry, or raw element into | ||
* a node object. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the | ||
@@ -113,3 +113,3 @@ * `override` function. It represents the value associated with the key in the data structure. If no | ||
*/ | ||
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined; | ||
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined; | ||
/** | ||
@@ -125,5 +125,5 @@ * Time Complexity: O(log n) | ||
* and update the count. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which can be any type. It | ||
* can also accept a value of type `KeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node, | ||
* can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node, | ||
* entry, or raw element | ||
@@ -137,3 +137,3 @@ * @param {V} [value] - The `value` parameter represents the value associated with the key in the | ||
*/ | ||
add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean; | ||
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean; | ||
/** | ||
@@ -140,0 +140,0 @@ * Time Complexity: O(log n) |
@@ -107,4 +107,4 @@ "use strict"; | ||
* The function checks if the input is an instance of AVLTreeMultiMapNode. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -119,4 +119,4 @@ * an instance of the `AVLTreeMultiMapNode` class. | ||
* a node object. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the | ||
@@ -160,5 +160,5 @@ * `override` function. It represents the value associated with the key in the data structure. If no | ||
* and update the count. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which can be any type. It | ||
* can also accept a value of type `KeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node, | ||
* can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node, | ||
* entry, or raw element | ||
@@ -165,0 +165,0 @@ * @param {V} [value] - The `value` parameter represents the value associated with the key in the |
@@ -9,3 +9,3 @@ /** | ||
import { BST, BSTNode } from './bst'; | ||
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry } from '../../types'; | ||
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNKeyOrNodeOrEntry } from '../../types'; | ||
import { BTNEntry } from '../../types'; | ||
@@ -57,3 +57,3 @@ import { IBinaryTree } from '../../interfaces'; | ||
*/ | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>); | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>); | ||
/** | ||
@@ -79,8 +79,8 @@ * The function creates a new AVL tree node with the given key and value. | ||
* The function checks if the input is an instance of AVLTreeNode. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
* an instance of the `AVLTreeNode` class. | ||
*/ | ||
isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
/** | ||
@@ -97,4 +97,4 @@ * Time Complexity: O(log n) | ||
* structure, then balances the path. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `KeyOrNodeOrEntry<K, V, NODE>`, or | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or | ||
* `RawElement`. | ||
@@ -105,3 +105,3 @@ * @param {V} [value] - The `value` parameter is an optional value that you want to associate with | ||
*/ | ||
add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean; | ||
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean; | ||
/** | ||
@@ -230,6 +230,6 @@ * Time Complexity: O(log n) | ||
* to restore balance in an AVL tree after inserting a node. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or | ||
* `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or | ||
* `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
*/ | ||
protected _balancePath(node: R | KeyOrNodeOrEntry<K, V, NODE>): void; | ||
protected _balancePath(node: R | BTNKeyOrNodeOrEntry<K, V, NODE>): void; | ||
/** | ||
@@ -236,0 +236,0 @@ * Time Complexity: O(1) |
@@ -92,4 +92,4 @@ "use strict"; | ||
* The function checks if the input is an instance of AVLTreeNode. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -112,4 +112,4 @@ * an instance of the `AVLTreeNode` class. | ||
* structure, then balances the path. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `KeyOrNodeOrEntry<K, V, NODE>`, or | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or | ||
* `RawElement`. | ||
@@ -444,4 +444,4 @@ * @param {V} [value] - The `value` parameter is an optional value that you want to associate with | ||
* to restore balance in an AVL tree after inserting a node. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or | ||
* `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or | ||
* `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
*/ | ||
@@ -448,0 +448,0 @@ _balancePath(node) { |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNCallback, BTNEntry, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, KeyOrNodeOrEntry, NodeDisplayLayout } from '../../types'; | ||
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNCallback, BTNEntry, BTNKeyOrNodeOrEntry, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeDisplayLayout, OptBTNOrNull } from '../../types'; | ||
import { IBinaryTree } from '../../interfaces'; | ||
@@ -36,9 +36,9 @@ import { IterableEntryBase } from '../base'; | ||
*/ | ||
get left(): NODE | null | undefined; | ||
get left(): OptBTNOrNull<NODE>; | ||
/** | ||
* The function sets the left child of a node and updates its parent reference. | ||
* @param {NODE | null | undefined} v - The parameter `v` can be of type `NODE`, `null`, or | ||
* @param {OptBTNOrNull<NODE>} v - The parameter `v` can be of type `NODE`, `null`, or | ||
* `undefined`. | ||
*/ | ||
set left(v: NODE | null | undefined); | ||
set left(v: OptBTNOrNull<NODE>); | ||
protected _right?: NODE | null; | ||
@@ -50,9 +50,9 @@ /** | ||
*/ | ||
get right(): NODE | null | undefined; | ||
get right(): OptBTNOrNull<NODE>; | ||
/** | ||
* The function sets the right child of a node and updates its parent. | ||
* @param {NODE | null | undefined} v - The parameter `v` can be of type `NODE`, `null`, or | ||
* @param {OptBTNOrNull<NODE>} v - The parameter `v` can be of type `NODE`, `null`, or | ||
* `undefined`. | ||
*/ | ||
set right(v: NODE | null | undefined); | ||
set right(v: OptBTNOrNull<NODE>); | ||
/** | ||
@@ -75,3 +75,3 @@ * Get the position of the node within its family. | ||
* The constructor function initializes a binary tree object with optional keysOrNodesOrEntriesOrRawElements and options. | ||
* @param [keysOrNodesOrEntriesOrRawElements] - Optional iterable of KeyOrNodeOrEntry objects. These objects represent the | ||
* @param [keysOrNodesOrEntriesOrRawElements] - Optional iterable of BTNKeyOrNodeOrEntry objects. These objects represent the | ||
* nodes to be added to the binary tree. | ||
@@ -83,4 +83,4 @@ * @param [options] - The `options` parameter is an optional object that can contain additional | ||
*/ | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: BinaryTreeOptions<K, V, R>); | ||
protected _root?: NODE | null; | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: BinaryTreeOptions<K, V, R>); | ||
protected _root?: OptBTNOrNull<NODE>; | ||
/** | ||
@@ -91,3 +91,3 @@ * The function returns the root node, which can be of type NODE, null, or undefined. | ||
*/ | ||
get root(): NODE | null | undefined; | ||
get root(): OptBTNOrNull<NODE>; | ||
protected _size: number; | ||
@@ -129,4 +129,4 @@ /** | ||
* into a node object. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the | ||
@@ -138,3 +138,3 @@ * `keyValueOrEntryOrRawElementToNode` function. It represents the value associated with a key in a | ||
*/ | ||
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | null | undefined; | ||
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): OptBTNOrNull<NODE>; | ||
/** | ||
@@ -150,4 +150,4 @@ * Time Complexity: O(n) | ||
* node if it is a key or entry. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, `KeyOrNodeOrEntry<K, V, NODE>`, or | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or | ||
* a raw element. | ||
@@ -159,40 +159,40 @@ * @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional | ||
*/ | ||
ensureNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined; | ||
ensureNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBTNOrNull<NODE>; | ||
/** | ||
* The function checks if the input is an instance of the BinaryTreeNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
* an instance of the `BinaryTreeNode` class. | ||
*/ | ||
isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
/** | ||
* The function checks if a given node is a valid node in a binary search tree. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or | ||
* `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or | ||
* `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value. | ||
*/ | ||
isRealNode(node: R | KeyOrNodeOrEntry<K, V, NODE>): node is NODE; | ||
isRealNode(node: R | BTNKeyOrNodeOrEntry<K, V, NODE>): node is NODE; | ||
/** | ||
* The function checks if a given node is a real node or null. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or | ||
* `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or | ||
* `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value. | ||
*/ | ||
isNodeOrNull(node: R | KeyOrNodeOrEntry<K, V, NODE>): node is NODE | null; | ||
isNodeOrNull(node: R | BTNKeyOrNodeOrEntry<K, V, NODE>): node is NODE | null; | ||
/** | ||
* The function checks if a given node is equal to the NIL value. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or | ||
* `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or | ||
* `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value. | ||
*/ | ||
isNIL(node: R | KeyOrNodeOrEntry<K, V, NODE>): boolean; | ||
isNIL(node: R | BTNKeyOrNodeOrEntry<K, V, NODE>): boolean; | ||
/** | ||
* The function checks if the input is an array with two elements, indicating it is a binary tree | ||
* node entry. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value. | ||
*/ | ||
isEntry(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is BTNEntry<K, V>; | ||
isEntry(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is BTNEntry<K, V>; | ||
/** | ||
@@ -219,6 +219,6 @@ * The function checks if a given value is a valid key by evaluating its type and value. | ||
* and finding the appropriate insertion position. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which represents the key, | ||
* node, entry, or raw element to be added to the tree. It can also accept a value of type | ||
* `KeyOrNodeOrEntry<K, V, NODE> | ||
* `BTNKeyOrNodeOrEntry<K, V, NODE> | ||
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the | ||
@@ -230,3 +230,3 @@ * key being added to the tree. It represents the value that will be stored in the tree for the given | ||
*/ | ||
add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean; | ||
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean; | ||
/** | ||
@@ -251,3 +251,3 @@ * Time Complexity: O(k * n) | ||
*/ | ||
addMany(keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[]; | ||
addMany(keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[]; | ||
/** | ||
@@ -264,3 +264,3 @@ * Time Complexity: O(k * n) | ||
* @param keysOrNodesOrEntriesOrRawElements - An iterable collection of keys, nodes, entries, or raw | ||
* elements. These can be of any type (R) or a specific type (KeyOrNodeOrEntry<K, V, NODE>). | ||
* elements. These can be of any type (R) or a specific type (BTNKeyOrNodeOrEntry<K, V, NODE>). | ||
* @param [values] - The `values` parameter is an optional iterable of values that will be associated | ||
@@ -270,12 +270,12 @@ * with the keys or nodes being added. If provided, the values will be assigned to the corresponding | ||
*/ | ||
refill(keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): void; | ||
refill(keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): void; | ||
delete<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C): BinaryTreeDeleteResult<NODE>[]; | ||
delete<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C): BinaryTreeDeleteResult<NODE>[]; | ||
delete<C extends BTNCallback<NODE, NODE>>(identifier: OptBTNOrNull<NODE>, callback?: C): BinaryTreeDeleteResult<NODE>[]; | ||
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C): BinaryTreeDeleteResult<NODE>[]; | ||
getNodes<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, onlyOne?: boolean, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[]; | ||
getNodes<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C, onlyOne?: boolean, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[]; | ||
getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C, onlyOne?: boolean, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[]; | ||
getNode<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined; | ||
getNode<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined; | ||
getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined; | ||
getNodes<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, onlyOne?: boolean, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[]; | ||
getNodes<C extends BTNCallback<NODE, NODE>>(identifier: OptBTNOrNull<NODE>, callback?: C, onlyOne?: boolean, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[]; | ||
getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C, onlyOne?: boolean, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[]; | ||
getNode<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBTNOrNull<NODE>; | ||
getNode<C extends BTNCallback<NODE, NODE>>(identifier: OptBTNOrNull<NODE>, callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBTNOrNull<NODE>; | ||
getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBTNOrNull<NODE>; | ||
/** | ||
@@ -297,9 +297,9 @@ * Time Complexity: O(n) | ||
*/ | ||
getNodeByKey(key: K, iterationType?: IterationType): NODE | null | undefined; | ||
get<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined; | ||
get<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined; | ||
get<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined; | ||
has<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean; | ||
has<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean; | ||
has<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean; | ||
getNodeByKey(key: K, iterationType?: IterationType): OptBTNOrNull<NODE>; | ||
get<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined; | ||
get<C extends BTNCallback<NODE, NODE>>(identifier: OptBTNOrNull<NODE>, callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined; | ||
get<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined; | ||
has<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean; | ||
has<C extends BTNCallback<NODE, NODE>>(identifier: OptBTNOrNull<NODE>, callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean; | ||
has<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean; | ||
/** | ||
@@ -338,9 +338,9 @@ * Time Complexity: O(1) | ||
* height of the tree. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The parameter `beginRoot` is optional and | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The parameter `beginRoot` is optional and | ||
* has a default value of `this.root`. It represents the starting point for checking if the tree is | ||
* perfectly balanced. It can be either a root node (`R`), a key or node or entry | ||
* (`KeyOrNodeOrEntry<K, V, NODE | ||
* (`BTNKeyOrNodeOrEntry<K, V, NODE | ||
* @returns a boolean value. | ||
*/ | ||
isPerfectlyBalanced(beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>): boolean; | ||
isPerfectlyBalanced(beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>): boolean; | ||
/** | ||
@@ -355,3 +355,3 @@ * Time Complexity: O(n) | ||
* The function `isBST` checks if a binary search tree is valid, either recursively or iteratively. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* starting point for checking if a binary search tree (BST) is valid. It can be either a root node | ||
@@ -365,3 +365,3 @@ * of the BST, a key value of a node in the BST, or an entry object containing both the key and value | ||
*/ | ||
isBST(beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean; | ||
isBST(beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): boolean; | ||
/** | ||
@@ -376,6 +376,6 @@ * Time Complexity: O(n) | ||
* The function calculates the depth of a given node or key in a tree-like data structure. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} dist - The `dist` parameter can be either a `R` | ||
* (representing a root node), or a `KeyOrNodeOrEntry<K, V, NODE>` (representing a key, node, or | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} dist - The `dist` parameter can be either a `R` | ||
* (representing a root node), or a `BTNKeyOrNodeOrEntry<K, V, NODE>` (representing a key, node, or | ||
* entry). | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is optional and | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is optional and | ||
* represents the starting point from which to calculate the depth. It can be either a reference to a | ||
@@ -386,3 +386,3 @@ * node in the tree or a key-value pair or an entry object. If not provided, the default value is | ||
*/ | ||
getDepth(dist: R | KeyOrNodeOrEntry<K, V, NODE>, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>): number; | ||
getDepth(dist: R | BTNKeyOrNodeOrEntry<K, V, NODE>, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>): number; | ||
/** | ||
@@ -398,5 +398,5 @@ * Time Complexity: O(n) | ||
* or iterative approach. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* starting point for calculating the height of a tree. It can be either a root node (`R`), a key or | ||
* node or entry (`KeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current tree. | ||
* node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current tree. | ||
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of | ||
@@ -406,3 +406,3 @@ * iteration used to calculate the height of the tree. It can have two possible values: | ||
*/ | ||
getHeight(beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): number; | ||
getHeight(beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): number; | ||
/** | ||
@@ -418,5 +418,5 @@ * Time Complexity: O(n) | ||
* recursive or iterative approach. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* starting point for calculating the minimum height of a tree. It can be either a root node (`R`), a | ||
* key or node or entry (`KeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current | ||
* key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current | ||
* tree. | ||
@@ -429,3 +429,3 @@ * @param {IterationType} iterationType - The `iterationType` parameter determines the type of | ||
*/ | ||
getMinHeight(beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): number; | ||
getMinHeight(beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): number; | ||
/** | ||
@@ -441,4 +441,4 @@ * Time Complexity: O(log n) | ||
* up to the root node, with an option to reverse the order of the nodes. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginNode - The `beginNode` parameter can be either of | ||
* type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginNode - The `beginNode` parameter can be either of | ||
* type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the | ||
@@ -449,3 +449,3 @@ * resulting path should be reversed or not. If `isReverse` is set to `true`, the path will be | ||
*/ | ||
getPathToRoot(beginNode: R | KeyOrNodeOrEntry<K, V, NODE>, isReverse?: boolean): NODE[]; | ||
getPathToRoot(beginNode: R | BTNKeyOrNodeOrEntry<K, V, NODE>, isReverse?: boolean): NODE[]; | ||
/** | ||
@@ -461,5 +461,5 @@ * Time Complexity: O(log n) | ||
* iterative traversal. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* starting point for finding the leftmost node in a binary tree. It can be either a root node (`R`), | ||
* a key or node or entry (`KeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`. | ||
* a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`. | ||
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type | ||
@@ -469,3 +469,3 @@ * of iteration to be performed. It can have two possible values: | ||
*/ | ||
getLeftMost(beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined; | ||
getLeftMost(beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBTNOrNull<NODE>; | ||
/** | ||
@@ -481,5 +481,5 @@ * Time Complexity: O(log n) | ||
* iteratively. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the | ||
* starting point for finding the rightmost node in a binary tree. It can be either a root node | ||
* (`R`), a key or node or entry (`KeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`. | ||
* (`R`), a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`. | ||
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type | ||
@@ -490,3 +490,3 @@ * of iteration to be performed when finding the rightmost node in a binary tree. It can have two | ||
*/ | ||
getRightMost(beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | null | undefined; | ||
getRightMost(beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBTNOrNull<NODE>; | ||
/** | ||
@@ -519,9 +519,9 @@ * Time Complexity: O(log n) | ||
*/ | ||
getSuccessor(x?: K | NODE | null): NODE | null | undefined; | ||
dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[]; | ||
dfs<C extends BTNCallback<NODE | null>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[]; | ||
bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[]; | ||
bfs<C extends BTNCallback<NODE | null>>(callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[]; | ||
listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][]; | ||
listLevels<C extends BTNCallback<NODE | null>>(callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][]; | ||
getSuccessor(x?: K | NODE | null): OptBTNOrNull<NODE>; | ||
dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[]; | ||
dfs<C extends BTNCallback<NODE | null>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[]; | ||
bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[]; | ||
bfs<C extends BTNCallback<NODE | null>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[]; | ||
listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][]; | ||
listLevels<C extends BTNCallback<NODE | null>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][]; | ||
/** | ||
@@ -544,3 +544,3 @@ * Time complexity: O(n) | ||
* following values: | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the traversal. It can be either a node object, a key, or an entry object. If no value is | ||
@@ -551,3 +551,3 @@ * provided, the `root` of the tree is used as the starting point. | ||
*/ | ||
morris<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>): ReturnType<C>[]; | ||
morris<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>): ReturnType<C>[]; | ||
/** | ||
@@ -614,3 +614,3 @@ * Time complexity: O(n) | ||
* The `print` function in TypeScript prints the binary tree structure with customizable options. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for printing the binary tree. It can be either a node of the binary tree or a key or entry | ||
@@ -624,3 +624,3 @@ * that exists in the binary tree. If no value is provided, the root of the binary tree will be used | ||
*/ | ||
print(beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, options?: BinaryTreePrintOptions): void; | ||
print(beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, options?: BinaryTreePrintOptions): void; | ||
/** | ||
@@ -640,3 +640,3 @@ * Time Complexity: O(1) | ||
*/ | ||
protected _getIterator(node?: NODE | null | undefined): IterableIterator<[K, V | undefined]>; | ||
protected _getIterator(node?: OptBTNOrNull<NODE>): IterableIterator<[K, V | undefined]>; | ||
/** | ||
@@ -652,3 +652,3 @@ * Time Complexity: O(n) | ||
* taking into account various options such as whether to show null, undefined, or NaN nodes. | ||
* @param {NODE | null | undefined} node - The `node` parameter represents a node in a binary tree. | ||
* @param {OptBTNOrNull<NODE>} node - The `node` parameter represents a node in a binary tree. | ||
* It can be of type `NODE`, `null`, or `undefined`. | ||
@@ -664,4 +664,4 @@ * @param {BinaryTreePrintOptions} options - The `options` parameter is an object that contains the | ||
*/ | ||
protected _displayAux(node: NODE | null | undefined, options: BinaryTreePrintOptions): NodeDisplayLayout; | ||
protected _DEFAULT_CALLBACK: (node: NODE | null | undefined) => K | undefined; | ||
protected _displayAux(node: OptBTNOrNull<NODE>, options: BinaryTreePrintOptions): NodeDisplayLayout; | ||
protected _DEFAULT_CALLBACK: (node: OptBTNOrNull<NODE>) => K | undefined; | ||
/** | ||
@@ -676,6 +676,6 @@ * Time Complexity: O(1) | ||
* The function `_swapProperties` swaps the key-value properties between two nodes. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} srcNode - The source node that will be swapped with the | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} srcNode - The source node that will be swapped with the | ||
* destination node. It can be either an instance of the class `R`, or an object of type | ||
* `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} destNode - The `destNode` parameter is the node where | ||
* `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} destNode - The `destNode` parameter is the node where | ||
* the properties will be swapped with the `srcNode`. | ||
@@ -685,3 +685,3 @@ * @returns either the `destNode` object with its properties swapped with the `srcNode` object's | ||
*/ | ||
protected _swapProperties(srcNode: R | KeyOrNodeOrEntry<K, V, NODE>, destNode: R | KeyOrNodeOrEntry<K, V, NODE>): NODE | undefined; | ||
protected _swapProperties(srcNode: R | BTNKeyOrNodeOrEntry<K, V, NODE>, destNode: R | BTNKeyOrNodeOrEntry<K, V, NODE>): NODE | undefined; | ||
/** | ||
@@ -714,6 +714,6 @@ * Time Complexity: O(1) | ||
* parent property of the new root. | ||
* @param {NODE | null | undefined} v - The parameter `v` is of type `NODE | null | undefined`. This | ||
* @param {OptBTNOrNull<NODE>} v - The parameter `v` is of type `OptBTNOrNull<NODE>`. This | ||
* means that it can accept a value of type `NODE`, `null`, or `undefined`. | ||
*/ | ||
protected _setRoot(v: NODE | null | undefined): void; | ||
protected _setRoot(v: OptBTNOrNull<NODE>): void; | ||
/** | ||
@@ -720,0 +720,0 @@ * Time Complexity: O(1) |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, Comparator, CP, DFSOrderPattern, IterationType, KeyOrNodeOrEntry } from '../../types'; | ||
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNKeyOrNodeOrEntry, Comparator, CP, DFSOrderPattern, IterationType, OptBSTN } from '../../types'; | ||
import { BTNEntry } from '../../types'; | ||
@@ -21,9 +21,9 @@ import { BinaryTree, BinaryTreeNode } from './binary-tree'; | ||
*/ | ||
get left(): NODE | undefined; | ||
get left(): OptBSTN<NODE>; | ||
/** | ||
* The function sets the left child of a node and updates the parent reference of the child. | ||
* @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be an | ||
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be an | ||
* instance of the `NODE` class or `undefined`. | ||
*/ | ||
set left(v: NODE | undefined); | ||
set left(v: OptBSTN<NODE>); | ||
protected _right?: NODE; | ||
@@ -35,9 +35,9 @@ /** | ||
*/ | ||
get right(): NODE | undefined; | ||
get right(): OptBSTN<NODE>; | ||
/** | ||
* The function sets the right child of a node and updates the parent reference of the child. | ||
* @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be a | ||
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be a | ||
* `NODE` object or `undefined`. | ||
*/ | ||
set right(v: NODE | undefined); | ||
set right(v: OptBSTN<NODE>); | ||
} | ||
@@ -62,3 +62,3 @@ /** | ||
*/ | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: BSTOptions<K, V, R>); | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: BSTOptions<K, V, R>); | ||
protected _root?: NODE; | ||
@@ -69,3 +69,3 @@ /** | ||
*/ | ||
get root(): NODE | undefined; | ||
get root(): OptBSTN<NODE>; | ||
/** | ||
@@ -90,4 +90,4 @@ * The function creates a new BSTNode with the given key and value and returns it. | ||
* The function overrides a method and converts a key, value pair or entry or raw element to a node. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of | ||
* type R or KeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of | ||
* type R or BTNKeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw | ||
* element. | ||
@@ -98,3 +98,3 @@ * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the | ||
*/ | ||
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined; | ||
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): OptBSTN<NODE>; | ||
/** | ||
@@ -106,3 +106,3 @@ * Time Complexity: O(log n) | ||
* it doesn't exist. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, which represents the key, node, | ||
@@ -116,11 +116,11 @@ * entry, or raw element that needs to be ensured in the tree. | ||
*/ | ||
ensureNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE | undefined; | ||
ensureNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): OptBSTN<NODE>; | ||
/** | ||
* The function checks if the input is an instance of the BSTNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
* an instance of the `BSTNode` class. | ||
*/ | ||
isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
/** | ||
@@ -131,4 +131,4 @@ * Time Complexity: O(log n) | ||
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the | ||
@@ -138,3 +138,3 @@ * key in the binary search tree. If provided, it will be stored in the node along with the key. | ||
*/ | ||
add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean; | ||
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean; | ||
/** | ||
@@ -165,3 +165,3 @@ * Time Complexity: O(log n) | ||
*/ | ||
addMany(keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[]; | ||
addMany(keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[]; | ||
/** | ||
@@ -182,3 +182,3 @@ * Time Complexity: O(log n) | ||
* false, all matching nodes will be returned. The default value is false. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the search in the binary tree. It can be either a node object, a key-value pair, or an | ||
@@ -190,3 +190,3 @@ * entry object. If it is not provided, the `root` of the binary tree is used as the starting point. | ||
*/ | ||
getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[]; | ||
getNodes<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): NODE[]; | ||
/** | ||
@@ -217,3 +217,3 @@ * Time Complexity: O(log n) | ||
*/ | ||
getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): NODE | undefined; | ||
getNode<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | undefined, callback?: C, beginRoot?: R | BSTNKeyOrNode<K, NODE>, iterationType?: IterationType): OptBSTN<NODE>; | ||
/** | ||
@@ -236,3 +236,3 @@ * Time Complexity: O(k log n) | ||
*/ | ||
getNodeByKey(key: K, iterationType?: IterationType): NODE | undefined; | ||
getNodeByKey(key: K, iterationType?: IterationType): OptBSTN<NODE>; | ||
/** | ||
@@ -254,3 +254,3 @@ * Time Complexity: O(log n) | ||
* take one of the following values: | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the depth-first search traversal. It can be either a root node, a key-value pair, or a | ||
@@ -263,3 +263,3 @@ * node entry. If not specified, the default value is the root of the tree. | ||
*/ | ||
dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[]; | ||
dfs<C extends BTNCallback<NODE>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[]; | ||
/** | ||
@@ -278,3 +278,3 @@ * Time Complexity: O(log n) | ||
* node being visited, and it can return a value of any type. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the breadth-first search. It can be either a root node, a key-value pair, or an entry | ||
@@ -287,3 +287,3 @@ * object. If no value is provided, the default value is the root of the tree. | ||
*/ | ||
bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[]; | ||
bfs<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[]; | ||
/** | ||
@@ -302,3 +302,3 @@ * Time Complexity: O(log n) | ||
* tree during the iteration process. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for listing the levels of the binary tree. It can be either a root node of the tree, a | ||
@@ -312,3 +312,3 @@ * key-value pair representing a node in the tree, or a key representing a node in the tree. If no | ||
*/ | ||
listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[][]; | ||
listLevels<C extends BTNCallback<NODE>>(callback?: C, beginRoot?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[][]; | ||
/** | ||
@@ -330,3 +330,3 @@ * Time complexity: O(n) | ||
* 0, or 1, where: | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in | ||
* the binary tree that you want to start traversing from. It can be specified either by providing | ||
@@ -340,3 +340,3 @@ * the key of the node, the node itself, or an entry containing the key and value of the node. If no | ||
*/ | ||
lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: R | KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[]; | ||
lesserOrGreaterTraverse<C extends BTNCallback<NODE>>(callback?: C, lesserOrGreater?: CP, targetNode?: R | BTNKeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): ReturnType<C>[]; | ||
/** | ||
@@ -390,5 +390,5 @@ * Time complexity: O(n) | ||
* root. | ||
* @param {NODE | undefined} v - v is a parameter of type NODE or undefined. | ||
* @param {OptBSTN<NODE>} v - v is a parameter of type NODE or undefined. | ||
*/ | ||
protected _setRoot(v: NODE | undefined): void; | ||
protected _setRoot(v: OptBSTN<NODE>): void; | ||
} |
@@ -22,3 +22,3 @@ "use strict"; | ||
* The function sets the left child of a node and updates the parent reference of the child. | ||
* @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be an | ||
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be an | ||
* instance of the `NODE` class or `undefined`. | ||
@@ -42,3 +42,3 @@ */ | ||
* The function sets the right child of a node and updates the parent reference of the child. | ||
* @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be a | ||
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be a | ||
* `NODE` object or `undefined`. | ||
@@ -124,4 +124,4 @@ */ | ||
* The function overrides a method and converts a key, value pair or entry or raw element to a node. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of | ||
* type R or KeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of | ||
* type R or BTNKeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw | ||
* element. | ||
@@ -142,3 +142,3 @@ * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the | ||
* it doesn't exist. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, which represents the key, node, | ||
@@ -158,4 +158,4 @@ * entry, or raw element that needs to be ensured in the tree. | ||
* The function checks if the input is an instance of the BSTNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -172,4 +172,4 @@ * an instance of the `BSTNode` class. | ||
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the | ||
@@ -338,3 +338,3 @@ * key in the binary search tree. If provided, it will be stored in the node along with the key. | ||
* false, all matching nodes will be returned. The default value is false. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the search in the binary tree. It can be either a node object, a key-value pair, or an | ||
@@ -472,3 +472,3 @@ * entry object. If it is not provided, the `root` of the binary tree is used as the starting point. | ||
* take one of the following values: | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the depth-first search traversal. It can be either a root node, a key-value pair, or a | ||
@@ -497,3 +497,3 @@ * node entry. If not specified, the default value is the root of the tree. | ||
* node being visited, and it can return a value of any type. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the breadth-first search. It can be either a root node, a key-value pair, or an entry | ||
@@ -522,3 +522,3 @@ * object. If no value is provided, the default value is the root of the tree. | ||
* tree during the iteration process. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for listing the levels of the binary tree. It can be either a root node of the tree, a | ||
@@ -551,3 +551,3 @@ * key-value pair representing a node in the tree, or a key representing a node in the tree. If no | ||
* 0, or 1, where: | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in | ||
* the binary tree that you want to start traversing from. It can be specified either by providing | ||
@@ -727,3 +727,3 @@ * the key of the node, the node itself, or an entry containing the key and value of the node. If no | ||
* root. | ||
* @param {NODE | undefined} v - v is a parameter of type NODE or undefined. | ||
* @param {OptBSTN<NODE>} v - v is a parameter of type NODE or undefined. | ||
*/ | ||
@@ -730,0 +730,0 @@ _setRoot(v) { |
@@ -1,2 +0,2 @@ | ||
import type { BinaryTreeDeleteResult, BTNCallback, CRUD, KeyOrNodeOrEntry, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types'; | ||
import type { BinaryTreeDeleteResult, BTNCallback, BTNKeyOrNodeOrEntry, CRUD, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types'; | ||
import { BTNEntry } from '../../types'; | ||
@@ -41,3 +41,3 @@ import { BST, BSTNode } from './bst'; | ||
*/ | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: RBTreeOptions<K, V, R>); | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: RBTreeOptions<K, V, R>); | ||
protected _root: NODE | undefined; | ||
@@ -80,8 +80,8 @@ /** | ||
* The function checks if the input is an instance of the RedBlackTreeNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
* an instance of the `RedBlackTreeNode` class. | ||
*/ | ||
isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
/** | ||
@@ -109,4 +109,4 @@ * Time Complexity: O(1) | ||
* added. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with | ||
@@ -119,3 +119,3 @@ * the key in the data structure. It represents the value that you want to add or update in the data | ||
*/ | ||
add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean; | ||
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean; | ||
/** | ||
@@ -122,0 +122,0 @@ * Time Complexity: O(log n) |
@@ -97,4 +97,4 @@ "use strict"; | ||
* The function checks if the input is an instance of the RedBlackTreeNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -117,7 +117,7 @@ * an instance of the `RedBlackTreeNode` class. | ||
// * valid, otherwise it returns undefined. | ||
// * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The key, value, or entry to convert. | ||
// * @param {BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The key, value, or entry to convert. | ||
// * @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntryOrRawElement` is a key). | ||
// * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails. | ||
// */ | ||
// override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined { | ||
// override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined { | ||
// | ||
@@ -167,4 +167,4 @@ // if (keyOrNodeOrEntryOrRawElement === null || keyOrNodeOrEntryOrRawElement === undefined) return; | ||
* added. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with | ||
@@ -171,0 +171,0 @@ * the key in the data structure. It represents the value that you want to add or update in the data |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, IterationType, KeyOrNodeOrEntry, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types'; | ||
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNKeyOrNodeOrEntry, IterationType, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types'; | ||
import { BTNEntry } from '../../types'; | ||
@@ -50,3 +50,3 @@ import { IBinaryTree } from '../../interfaces'; | ||
*/ | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: TreeMultiMapOptions<K, V, R>); | ||
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: TreeMultiMapOptions<K, V, R>); | ||
protected _count: number; | ||
@@ -97,4 +97,4 @@ /** | ||
* node based on the input. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that represents the value | ||
@@ -107,11 +107,11 @@ * associated with the key in the node. It is used when creating a new node or updating the value of | ||
*/ | ||
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined; | ||
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined; | ||
/** | ||
* The function checks if the input is an instance of the TreeMultiMapNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
* an instance of the `TreeMultiMapNode` class. | ||
*/ | ||
isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE; | ||
/** | ||
@@ -127,3 +127,3 @@ * Time Complexity: O(log n) | ||
* the count and returning a boolean indicating success. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can accept one of the following types: | ||
@@ -138,3 +138,3 @@ * @param {V} [value] - The `value` parameter represents the value associated with the key in the | ||
*/ | ||
add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean; | ||
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean; | ||
/** | ||
@@ -141,0 +141,0 @@ * Time Complexity: O(log n) |
@@ -111,4 +111,4 @@ "use strict"; | ||
* node based on the input. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that represents the value | ||
@@ -144,4 +144,4 @@ * associated with the key in the node. It is used when creating a new node or updating the value of | ||
* The function checks if the input is an instance of the TreeMultiMapNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -163,3 +163,3 @@ * an instance of the `TreeMultiMapNode` class. | ||
* the count and returning a boolean indicating success. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can accept one of the following types: | ||
@@ -166,0 +166,0 @@ * @param {V} [value] - The `value` parameter represents the value associated with the key in the |
@@ -223,3 +223,4 @@ "use strict"; | ||
for (const neighbor of neighbors) { | ||
this._inEdgeMap.delete(neighbor); | ||
// this._inEdgeMap.delete(neighbor); | ||
this.deleteEdgeSrcToDest(vertex, neighbor); | ||
} | ||
@@ -226,0 +227,0 @@ this._outEdgeMap.delete(vertex); |
@@ -37,2 +37,9 @@ /** | ||
get bucketSize(): number; | ||
protected _maxLen: number; | ||
/** | ||
* The maxLen function returns the max length of the deque. | ||
* | ||
* @return The max length of the deque | ||
*/ | ||
get maxLen(): number; | ||
protected _bucketFirst: number; | ||
@@ -39,0 +46,0 @@ /** |
@@ -28,2 +28,3 @@ "use strict"; | ||
this._bucketSize = 1 << 12; | ||
this._maxLen = -1; | ||
this._bucketFirst = 0; | ||
@@ -37,5 +38,7 @@ this._firstInBucket = 0; | ||
if (options) { | ||
const { bucketSize } = options; | ||
const { bucketSize, maxLen } = options; | ||
if (typeof bucketSize === 'number') | ||
this._bucketSize = bucketSize; | ||
if (typeof maxLen === 'number' && maxLen > 0 && maxLen % 1 === 0) | ||
this._maxLen = maxLen; | ||
} | ||
@@ -80,2 +83,10 @@ let _size; | ||
/** | ||
* The maxLen function returns the max length of the deque. | ||
* | ||
* @return The max length of the deque | ||
*/ | ||
get maxLen() { | ||
return this._maxLen; | ||
} | ||
/** | ||
* The function returns the value of the protected variable `_bucketFirst`. | ||
@@ -181,2 +192,4 @@ * @returns The value of the `_bucketFirst` property. | ||
this._buckets[this._bucketLast][this._lastInBucket] = element; | ||
if (this._maxLen > 0 && this._size > this._maxLen) | ||
this.shift(); | ||
return true; | ||
@@ -248,2 +261,4 @@ } | ||
this._buckets[this._bucketFirst][this._firstInBucket] = element; | ||
if (this._maxLen > 0 && this._size > this._maxLen) | ||
this.pop(); | ||
return true; | ||
@@ -250,0 +265,0 @@ } |
@@ -73,3 +73,2 @@ /** | ||
* @public | ||
* @static | ||
* @param {E[]} elements - The "elements" parameter is an array of elements of type E. | ||
@@ -76,0 +75,0 @@ * @returns The method is returning a new instance of the Queue class, initialized with the elements from the input |
@@ -90,3 +90,2 @@ "use strict"; | ||
* @public | ||
* @static | ||
* @param {E[]} elements - The "elements" parameter is an array of elements of type E. | ||
@@ -93,0 +92,0 @@ * @returns The method is returning a new instance of the Queue class, initialized with the elements from the input |
import { BinaryTree, BinaryTreeNode } from '../data-structures'; | ||
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, KeyOrNodeOrEntry } from '../types'; | ||
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, BTNKeyOrNodeOrEntry } from '../types'; | ||
export interface IBinaryTree<K = any, V = any, R = [K, V], NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>> { | ||
createNode(key: K, value?: NODE['value']): NODE; | ||
createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE; | ||
add(keyOrNodeOrEntryOrRawElement: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean; | ||
addMany(nodes: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[]; | ||
add(keyOrNodeOrEntryOrRawElement: BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean; | ||
addMany(nodes: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[]; | ||
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<NODE>[]; | ||
} |
export type CP = 1 | -1 | 0; | ||
/** | ||
* Enum representing different loop types. | ||
* | ||
* - `iterative`: Indicates the iterative loop type (with loops that use iterations). | ||
* - `recursive`: Indicates the recursive loop type (with loops that call themselves). | ||
*/ | ||
export type IterationType = 'ITERATIVE' | 'RECURSIVE'; | ||
@@ -13,3 +7,2 @@ export type FamilyPosition = 'ROOT' | 'LEFT' | 'RIGHT' | 'ROOT_LEFT' | 'ROOT_RIGHT' | 'ISOLATED' | 'MAL_NODE'; | ||
export type NodeDisplayLayout = [string[], number, number, number]; | ||
export type BTNCallback<N, D = any> = (node: N) => D; | ||
export interface IterableWithSize<T> extends Iterable<T> { | ||
@@ -21,18 +14,4 @@ size: number | ((...args: any[]) => number); | ||
} | ||
export type OptValue<V> = V | undefined; | ||
export type IterableWithSizeOrLength<T> = IterableWithSize<T> | IterableWithLength<T>; | ||
export type BinaryTreePrintOptions = { | ||
isShowUndefined?: boolean; | ||
isShowNull?: boolean; | ||
isShowRedBlackNIL?: boolean; | ||
}; | ||
export type BTNEntry<K, V> = [K | null | undefined, V | undefined]; | ||
export type BTNKeyOrNode<K, N> = K | null | undefined | N; | ||
export type KeyOrNodeOrEntry<K, V, N> = BTNEntry<K, V> | BTNKeyOrNode<K, N>; | ||
export type BTNodePureKeyOrNode<K, N> = K | N; | ||
export type BTNPureKeyOrNodeOrEntry<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>; | ||
export type BSTNKeyOrNode<K, N> = K | undefined | N; | ||
export type BinaryTreeDeleteResult<N> = { | ||
deleted: N | null | undefined; | ||
needBalanced: N | null | undefined; | ||
}; | ||
export type CRUD = 'CREATED' | 'READ' | 'UPDATED' | 'DELETED'; |
import { BinaryTree, BinaryTreeNode } from '../../../data-structures'; | ||
import { BTNEntry, IterationType } from '../../common'; | ||
import { IterationType, OptValue } from '../../common'; | ||
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
@@ -9,1 +9,18 @@ export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
}; | ||
export type BinaryTreePrintOptions = { | ||
isShowUndefined?: boolean; | ||
isShowNull?: boolean; | ||
isShowRedBlackNIL?: boolean; | ||
}; | ||
export type OptBTNOrNull<NODE> = NODE | null | undefined; | ||
export type OptBTNKeyOrNull<K> = K | null | undefined; | ||
export type BTNEntry<K, V> = [OptBTNKeyOrNull<K>, OptValue<V>]; | ||
export type BTNKeyOrNode<K, NODE> = OptBTNKeyOrNull<K> | NODE; | ||
export type BTNKeyOrNodeOrEntry<K, V, NODE> = BTNEntry<K, V> | BTNKeyOrNode<K, NODE>; | ||
export type BTNPureKeyOrNode<K, NODE> = K | NODE; | ||
export type BTNPureKeyOrNodeOrEntry<K, V, NODE> = [K, OptValue<V>] | BTNPureKeyOrNode<K, NODE>; | ||
export type BinaryTreeDeleteResult<NODE> = { | ||
deleted: OptBTNOrNull<NODE>; | ||
needBalanced: OptBTNOrNull<NODE>; | ||
}; | ||
export type BTNCallback<NODE, D = any> = (node: NODE) => D; |
@@ -9,1 +9,4 @@ import { BST, BSTNode } from '../../../data-structures'; | ||
}; | ||
export type OptBSTNKey<K> = K | undefined; | ||
export type OptBSTN<NODE> = NODE | undefined; | ||
export type BSTNKeyOrNode<K, NODE> = OptBSTNKey<K> | NODE; |
import { IterableElementBaseOptions } from '../base'; | ||
export type DequeOptions<E, R> = { | ||
bucketSize?: number; | ||
maxLen?: number; | ||
} & IterableElementBaseOptions<E, R>; |
{ | ||
"name": "graph-typed", | ||
"version": "1.52.0", | ||
"version": "1.52.1", | ||
"description": "Graph. Javascript & Typescript Data Structure.", | ||
@@ -139,4 +139,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"data-structure-typed": "^1.52.0" | ||
"data-structure-typed": "^1.52.1" | ||
} | ||
} |
@@ -15,4 +15,4 @@ /** | ||
BTNCallback, | ||
IterationType, | ||
KeyOrNodeOrEntry | ||
BTNKeyOrNodeOrEntry, | ||
IterationType | ||
} from '../../types'; | ||
@@ -90,3 +90,3 @@ import { BTNEntry } from '../../types'; | ||
constructor( | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>> = [], | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>> = [], | ||
options?: AVLTreeMultiMapOptions<K, V, R> | ||
@@ -160,4 +160,4 @@ ) { | ||
* The function checks if the input is an instance of AVLTreeMultiMapNode. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -167,3 +167,3 @@ * an instance of the `AVLTreeMultiMapNode` class. | ||
override isNode( | ||
keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE> | ||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE> | ||
): keyOrNodeOrEntryOrRawElement is NODE { | ||
@@ -176,4 +176,4 @@ return keyOrNodeOrEntryOrRawElement instanceof AVLTreeMultiMapNode; | ||
* a node object. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the | ||
@@ -187,3 +187,3 @@ * `override` function. It represents the value associated with the key in the data structure. If no | ||
override keyValueOrEntryOrRawElementToNode( | ||
keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, | ||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, | ||
value?: V, | ||
@@ -222,5 +222,5 @@ count = 1 | ||
* and update the count. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which can be any type. It | ||
* can also accept a value of type `KeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node, | ||
* can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node, | ||
* entry, or raw element | ||
@@ -234,3 +234,3 @@ * @param {V} [value] - The `value` parameter represents the value associated with the key in the | ||
*/ | ||
override add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count = 1): boolean { | ||
override add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count = 1): boolean { | ||
const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value, count); | ||
@@ -237,0 +237,0 @@ if (newNode === undefined) return false; |
@@ -16,3 +16,3 @@ /** | ||
BTNCallback, | ||
KeyOrNodeOrEntry | ||
BTNKeyOrNodeOrEntry | ||
} from '../../types'; | ||
@@ -90,3 +90,3 @@ import { BTNEntry } from '../../types'; | ||
constructor( | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>> = [], | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>> = [], | ||
options?: AVLTreeOptions<K, V, R> | ||
@@ -128,4 +128,4 @@ ) { | ||
* The function checks if the input is an instance of AVLTreeNode. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -135,3 +135,3 @@ * an instance of the `AVLTreeNode` class. | ||
override isNode( | ||
keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE> | ||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE> | ||
): keyOrNodeOrEntryOrRawElement is NODE { | ||
@@ -153,4 +153,4 @@ return keyOrNodeOrEntryOrRawElement instanceof AVLTreeNode; | ||
* structure, then balances the path. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `KeyOrNodeOrEntry<K, V, NODE>`, or | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or | ||
* `RawElement`. | ||
@@ -161,3 +161,3 @@ * @param {V} [value] - The `value` parameter is an optional value that you want to associate with | ||
*/ | ||
override add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean { | ||
override add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean { | ||
if (keyOrNodeOrEntryOrRawElement === null) return false; | ||
@@ -497,6 +497,6 @@ const inserted = super.add(keyOrNodeOrEntryOrRawElement, value); | ||
* to restore balance in an AVL tree after inserting a node. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or | ||
* `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or | ||
* `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
*/ | ||
protected _balancePath(node: R | KeyOrNodeOrEntry<K, V, NODE>): void { | ||
protected _balancePath(node: R | BTNKeyOrNodeOrEntry<K, V, NODE>): void { | ||
node = this.ensureNode(node); | ||
@@ -503,0 +503,0 @@ const path = this.getPathToRoot(node, false); // first O(log n) + O(log n) |
@@ -14,2 +14,3 @@ /** | ||
BTNCallback, | ||
BTNKeyOrNodeOrEntry, | ||
BTNPureKeyOrNodeOrEntry, | ||
@@ -20,3 +21,3 @@ Comparator, | ||
IterationType, | ||
KeyOrNodeOrEntry | ||
OptBSTN | ||
} from '../../types'; | ||
@@ -48,3 +49,3 @@ import { BTNEntry } from '../../types'; | ||
*/ | ||
override get left(): NODE | undefined { | ||
override get left(): OptBSTN<NODE> { | ||
return this._left; | ||
@@ -55,6 +56,6 @@ } | ||
* The function sets the left child of a node and updates the parent reference of the child. | ||
* @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be an | ||
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be an | ||
* instance of the `NODE` class or `undefined`. | ||
*/ | ||
override set left(v: NODE | undefined) { | ||
override set left(v: OptBSTN<NODE>) { | ||
if (v) { | ||
@@ -73,3 +74,3 @@ v.parent = this as unknown as NODE; | ||
*/ | ||
override get right(): NODE | undefined { | ||
override get right(): OptBSTN<NODE> { | ||
return this._right; | ||
@@ -80,6 +81,6 @@ } | ||
* The function sets the right child of a node and updates the parent reference of the child. | ||
* @param {NODE | undefined} v - The parameter `v` is of type `NODE | undefined`. It can either be a | ||
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be a | ||
* `NODE` object or `undefined`. | ||
*/ | ||
override set right(v: NODE | undefined) { | ||
override set right(v: OptBSTN<NODE>) { | ||
if (v) { | ||
@@ -119,3 +120,3 @@ v.parent = this as unknown as NODE; | ||
constructor( | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>> = [], | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>> = [], | ||
options?: BSTOptions<K, V, R> | ||
@@ -139,3 +140,3 @@ ) { | ||
*/ | ||
override get root(): NODE | undefined { | ||
override get root(): OptBSTN<NODE> { | ||
return this._root; | ||
@@ -173,4 +174,4 @@ } | ||
* The function overrides a method and converts a key, value pair or entry or raw element to a node. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of | ||
* type R or KeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of | ||
* type R or BTNKeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw | ||
* element. | ||
@@ -182,5 +183,5 @@ * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the | ||
override keyValueOrEntryOrRawElementToNode( | ||
keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, | ||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, | ||
value?: V | ||
): NODE | undefined { | ||
): OptBSTN<NODE> { | ||
return super.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value) ?? undefined; | ||
@@ -195,3 +196,3 @@ } | ||
* it doesn't exist. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, which represents the key, node, | ||
@@ -206,5 +207,5 @@ * entry, or raw element that needs to be ensured in the tree. | ||
override ensureNode( | ||
keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, | ||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, | ||
iterationType: IterationType = 'ITERATIVE' | ||
): NODE | undefined { | ||
): OptBSTN<NODE> { | ||
return super.ensureNode(keyOrNodeOrEntryOrRawElement, iterationType) ?? undefined; | ||
@@ -215,4 +216,4 @@ } | ||
* The function checks if the input is an instance of the BSTNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -222,3 +223,3 @@ * an instance of the `BSTNode` class. | ||
override isNode( | ||
keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE> | ||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE> | ||
): keyOrNodeOrEntryOrRawElement is NODE { | ||
@@ -233,4 +234,4 @@ return keyOrNodeOrEntryOrRawElement instanceof BSTNode; | ||
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the | ||
@@ -240,3 +241,3 @@ * key in the binary search tree. If provided, it will be stored in the node along with the key. | ||
*/ | ||
override add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean { | ||
override add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean { | ||
const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value); | ||
@@ -303,3 +304,3 @@ if (newNode === undefined) return false; | ||
override addMany( | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, | ||
values?: Iterable<V | undefined>, | ||
@@ -328,3 +329,5 @@ isBalanceAdd = true, | ||
const isRealBTNExemplar = (kve: R | KeyOrNodeOrEntry<K, V, NODE>): kve is BTNPureKeyOrNodeOrEntry<K, V, NODE> => { | ||
const isRealBTNExemplar = ( | ||
kve: R | BTNKeyOrNodeOrEntry<K, V, NODE> | ||
): kve is BTNPureKeyOrNodeOrEntry<K, V, NODE> => { | ||
if (kve === undefined || kve === null) return false; | ||
@@ -416,3 +419,3 @@ return !(this.isEntry(kve) && (kve[0] === undefined || kve[0] === null)); | ||
* false, all matching nodes will be returned. The default value is false. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the search in the binary tree. It can be either a node object, a key-value pair, or an | ||
@@ -428,3 +431,3 @@ * entry object. If it is not provided, the `root` of the binary tree is used as the starting point. | ||
onlyOne = false, | ||
beginRoot: R | KeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
beginRoot: R | BTNKeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
iterationType: IterationType = this.iterationType | ||
@@ -519,3 +522,3 @@ ): NODE[] { | ||
iterationType: IterationType = this.iterationType | ||
): NODE | undefined { | ||
): OptBSTN<NODE> { | ||
return this.getNodes(identifier, callback, true, beginRoot, iterationType)[0] ?? undefined; | ||
@@ -542,3 +545,3 @@ } | ||
*/ | ||
override getNodeByKey(key: K, iterationType: IterationType = 'ITERATIVE'): NODE | undefined { | ||
override getNodeByKey(key: K, iterationType: IterationType = 'ITERATIVE'): OptBSTN<NODE> { | ||
return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType); | ||
@@ -564,3 +567,3 @@ } | ||
* take one of the following values: | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the depth-first search traversal. It can be either a root node, a key-value pair, or a | ||
@@ -576,3 +579,3 @@ * node entry. If not specified, the default value is the root of the tree. | ||
pattern: DFSOrderPattern = 'IN', | ||
beginRoot: R | KeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
beginRoot: R | BTNKeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
iterationType: IterationType = 'ITERATIVE' | ||
@@ -597,3 +600,3 @@ ): ReturnType<C>[] { | ||
* node being visited, and it can return a value of any type. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for the breadth-first search. It can be either a root node, a key-value pair, or an entry | ||
@@ -608,3 +611,3 @@ * object. If no value is provided, the default value is the root of the tree. | ||
callback: C = this._DEFAULT_CALLBACK as C, | ||
beginRoot: R | KeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
beginRoot: R | BTNKeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
iterationType: IterationType = this.iterationType | ||
@@ -629,3 +632,3 @@ ): ReturnType<C>[] { | ||
* tree during the iteration process. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting | ||
* point for listing the levels of the binary tree. It can be either a root node of the tree, a | ||
@@ -641,3 +644,3 @@ * key-value pair representing a node in the tree, or a key representing a node in the tree. If no | ||
callback: C = this._DEFAULT_CALLBACK as C, | ||
beginRoot: R | KeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
beginRoot: R | BTNKeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
iterationType: IterationType = this.iterationType | ||
@@ -665,3 +668,3 @@ ): ReturnType<C>[][] { | ||
* 0, or 1, where: | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in | ||
* the binary tree that you want to start traversing from. It can be specified either by providing | ||
@@ -678,3 +681,3 @@ * the key of the node, the node itself, or an entry containing the key and value of the node. If no | ||
lesserOrGreater: CP = -1, | ||
targetNode: R | KeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
targetNode: R | BTNKeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
iterationType: IterationType = this.iterationType | ||
@@ -793,3 +796,3 @@ ): ReturnType<C>[] { | ||
if (iterationType === 'RECURSIVE') { | ||
const _height = (cur: NODE | undefined): number => { | ||
const _height = (cur: OptBSTN<NODE>): number => { | ||
if (!cur) return 0; | ||
@@ -804,4 +807,4 @@ const leftHeight = _height(cur.left), | ||
const stack: NODE[] = []; | ||
let node: NODE | undefined = this.root, | ||
last: NODE | undefined = undefined; | ||
let node: OptBSTN<NODE> = this.root, | ||
last: OptBSTN<NODE> = undefined; | ||
const depths: Map<NODE, number> = new Map(); | ||
@@ -862,5 +865,5 @@ | ||
* root. | ||
* @param {NODE | undefined} v - v is a parameter of type NODE or undefined. | ||
* @param {OptBSTN<NODE>} v - v is a parameter of type NODE or undefined. | ||
*/ | ||
protected override _setRoot(v: NODE | undefined) { | ||
protected override _setRoot(v: OptBSTN<NODE>) { | ||
if (v) { | ||
@@ -867,0 +870,0 @@ v.parent = undefined; |
import type { | ||
BinaryTreeDeleteResult, | ||
BTNCallback, | ||
BTNKeyOrNodeOrEntry, | ||
CRUD, | ||
KeyOrNodeOrEntry, | ||
RBTNColor, | ||
@@ -75,3 +75,3 @@ RBTreeOptions, | ||
constructor( | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>> = [], | ||
keysOrNodesOrEntriesOrRawElements: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>> = [], | ||
options?: RBTreeOptions<K, V, R> | ||
@@ -139,4 +139,4 @@ ) { | ||
* The function checks if the input is an instance of the RedBlackTreeNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -146,3 +146,3 @@ * an instance of the `RedBlackTreeNode` class. | ||
override isNode( | ||
keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE> | ||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE> | ||
): keyOrNodeOrEntryOrRawElement is NODE { | ||
@@ -163,7 +163,7 @@ return keyOrNodeOrEntryOrRawElement instanceof RedBlackTreeNode; | ||
// * valid, otherwise it returns undefined. | ||
// * @param {KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The key, value, or entry to convert. | ||
// * @param {BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The key, value, or entry to convert. | ||
// * @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntryOrRawElement` is a key). | ||
// * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails. | ||
// */ | ||
// override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined { | ||
// override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined { | ||
// | ||
@@ -217,4 +217,4 @@ // if (keyOrNodeOrEntryOrRawElement === null || keyOrNodeOrEntryOrRawElement === undefined) return; | ||
* added. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with | ||
@@ -227,3 +227,3 @@ * the key in the data structure. It represents the value that you want to add or update in the data | ||
*/ | ||
override add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean { | ||
override add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean { | ||
const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value); | ||
@@ -230,0 +230,0 @@ if (!this.isRealNode(newNode)) return false; |
@@ -12,4 +12,4 @@ /** | ||
BTNCallback, | ||
BTNKeyOrNodeOrEntry, | ||
IterationType, | ||
KeyOrNodeOrEntry, | ||
RBTNColor, | ||
@@ -85,3 +85,3 @@ TreeMultiMapNested, | ||
constructor( | ||
keysOrNodesOrEntriesOrRawElements: Iterable<KeyOrNodeOrEntry<K, V, NODE>> = [], | ||
keysOrNodesOrEntriesOrRawElements: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>> = [], | ||
options?: TreeMultiMapOptions<K, V, R> | ||
@@ -158,4 +158,4 @@ ) { | ||
* node based on the input. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {V} [value] - The `value` parameter is an optional value that represents the value | ||
@@ -169,3 +169,3 @@ * associated with the key in the node. It is used when creating a new node or updating the value of | ||
override keyValueOrEntryOrRawElementToNode( | ||
keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, | ||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, | ||
value?: V, | ||
@@ -197,4 +197,4 @@ count = 1 | ||
* The function checks if the input is an instance of the TreeMultiMapNode class. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`. | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter | ||
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`. | ||
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is | ||
@@ -204,3 +204,3 @@ * an instance of the `TreeMultiMapNode` class. | ||
override isNode( | ||
keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE> | ||
keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE> | ||
): keyOrNodeOrEntryOrRawElement is NODE { | ||
@@ -221,3 +221,3 @@ return keyOrNodeOrEntryOrRawElement instanceof TreeMultiMapNode; | ||
* the count and returning a boolean indicating success. | ||
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The | ||
* `keyOrNodeOrEntryOrRawElement` parameter can accept one of the following types: | ||
@@ -232,3 +232,3 @@ * @param {V} [value] - The `value` parameter represents the value associated with the key in the | ||
*/ | ||
override add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count = 1): boolean { | ||
override add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count = 1): boolean { | ||
const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value, count); | ||
@@ -235,0 +235,0 @@ const orgCount = newNode?.count || 0; |
@@ -264,3 +264,4 @@ /** | ||
for (const neighbor of neighbors) { | ||
this._inEdgeMap.delete(neighbor); | ||
// this._inEdgeMap.delete(neighbor); | ||
this.deleteEdgeSrcToDest(vertex, neighbor); | ||
} | ||
@@ -267,0 +268,0 @@ this._outEdgeMap.delete(vertex); |
@@ -35,4 +35,5 @@ /** | ||
if (options) { | ||
const { bucketSize } = options; | ||
const { bucketSize, maxLen } = options; | ||
if (typeof bucketSize === 'number') this._bucketSize = bucketSize; | ||
if (typeof maxLen === 'number' && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen; | ||
} | ||
@@ -77,2 +78,13 @@ | ||
protected _maxLen: number = -1; | ||
/** | ||
* The maxLen function returns the max length of the deque. | ||
* | ||
* @return The max length of the deque | ||
*/ | ||
get maxLen() { | ||
return this._maxLen; | ||
} | ||
protected _bucketFirst = 0; | ||
@@ -198,2 +210,3 @@ | ||
this._buckets[this._bucketLast][this._lastInBucket] = element; | ||
if (this._maxLen > 0 && this._size > this._maxLen) this.shift(); | ||
return true; | ||
@@ -263,2 +276,3 @@ } | ||
this._buckets[this._bucketFirst][this._firstInBucket] = element; | ||
if (this._maxLen > 0 && this._size > this._maxLen) this.pop(); | ||
return true; | ||
@@ -265,0 +279,0 @@ } |
@@ -103,3 +103,2 @@ /** | ||
* @public | ||
* @static | ||
* @param {E[]} elements - The "elements" parameter is an array of elements of type E. | ||
@@ -106,0 +105,0 @@ * @returns The method is returning a new instance of the Queue class, initialized with the elements from the input |
@@ -8,3 +8,3 @@ import { BinaryTree, BinaryTreeNode } from '../data-structures'; | ||
BTNCallback, | ||
KeyOrNodeOrEntry | ||
BTNKeyOrNodeOrEntry | ||
} from '../types'; | ||
@@ -23,7 +23,7 @@ | ||
add(keyOrNodeOrEntryOrRawElement: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean; | ||
add(keyOrNodeOrEntryOrRawElement: BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean; | ||
addMany(nodes: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[]; | ||
addMany(nodes: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[]; | ||
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<NODE>[]; | ||
} |
export type CP = 1 | -1 | 0; | ||
/** | ||
* Enum representing different loop types. | ||
* | ||
* - `iterative`: Indicates the iterative loop type (with loops that use iterations). | ||
* - `recursive`: Indicates the recursive loop type (with loops that call themselves). | ||
*/ | ||
export type IterationType = 'ITERATIVE' | 'RECURSIVE'; | ||
@@ -19,4 +13,2 @@ | ||
export type BTNCallback<N, D = any> = (node: N) => D; | ||
export interface IterableWithSize<T> extends Iterable<T> { | ||
@@ -30,20 +22,6 @@ size: number | ((...args: any[]) => number); | ||
export type OptValue<V> = V | undefined; | ||
export type IterableWithSizeOrLength<T> = IterableWithSize<T> | IterableWithLength<T>; | ||
export type BinaryTreePrintOptions = { isShowUndefined?: boolean; isShowNull?: boolean; isShowRedBlackNIL?: boolean }; | ||
export type BTNEntry<K, V> = [K | null | undefined, V | undefined]; | ||
export type BTNKeyOrNode<K, N> = K | null | undefined | N; | ||
export type KeyOrNodeOrEntry<K, V, N> = BTNEntry<K, V> | BTNKeyOrNode<K, N>; | ||
export type BTNodePureKeyOrNode<K, N> = K | N; | ||
export type BTNPureKeyOrNodeOrEntry<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>; | ||
export type BSTNKeyOrNode<K, N> = K | undefined | N; | ||
export type BinaryTreeDeleteResult<N> = { deleted: N | null | undefined; needBalanced: N | null | undefined }; | ||
export type CRUD = 'CREATED' | 'READ' | 'UPDATED' | 'DELETED'; |
import { BinaryTree, BinaryTreeNode } from '../../../data-structures'; | ||
import { BTNEntry, IterationType } from '../../common'; | ||
import { IterationType, OptValue } from '../../common'; | ||
@@ -12,1 +12,21 @@ export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
} | ||
export type BinaryTreePrintOptions = { isShowUndefined?: boolean; isShowNull?: boolean; isShowRedBlackNIL?: boolean }; | ||
export type OptBTNOrNull<NODE> = NODE | null | undefined; | ||
export type OptBTNKeyOrNull<K> = K | null | undefined; | ||
export type BTNEntry<K, V> = [OptBTNKeyOrNull<K>, OptValue<V>]; | ||
export type BTNKeyOrNode<K, NODE> = OptBTNKeyOrNull<K> | NODE; | ||
export type BTNKeyOrNodeOrEntry<K, V, NODE> = BTNEntry<K, V> | BTNKeyOrNode<K, NODE>; | ||
export type BTNPureKeyOrNode<K, NODE> = K | NODE; | ||
export type BTNPureKeyOrNodeOrEntry<K, V, NODE> = [K, OptValue<V>] | BTNPureKeyOrNode<K, NODE>; | ||
export type BinaryTreeDeleteResult<NODE> = { deleted: OptBTNOrNull<NODE>; needBalanced: OptBTNOrNull<NODE> }; | ||
export type BTNCallback<NODE, D = any> = (node: NODE) => D; |
@@ -12,1 +12,8 @@ import { BST, BSTNode } from '../../../data-structures'; | ||
} | ||
export type OptBSTNKey<K> = K | undefined; | ||
export type OptBSTN<NODE> = NODE | undefined; | ||
export type BSTNKeyOrNode<K, NODE> = OptBSTNKey<K> | NODE; | ||
import { IterableElementBaseOptions } from '../base'; | ||
export type DequeOptions<E, R> = { bucketSize?: number } & IterableElementBaseOptions<E, R>; | ||
export type DequeOptions<E, R> = { | ||
bucketSize?: number, | ||
maxLen?: number | ||
} & IterableElementBaseOptions<E, R>; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2928022
0.07%42159
0.1%Updated