red-black-tree-typed
Advanced tools
Comparing version 1.51.7 to 1.51.8
@@ -8,6 +8,6 @@ /** | ||
*/ | ||
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, IterationType, KeyOrNodeOrEntry } from '../../types'; | ||
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, Comparable, IterationType, KeyOrNodeOrEntry } from '../../types'; | ||
import { IBinaryTree } from '../../interfaces'; | ||
import { AVLTree, AVLTreeNode } from './avl-tree'; | ||
export declare class AVLTreeMultiMapNode<K = any, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> { | ||
export declare class AVLTreeMultiMapNode<K extends Comparable, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> { | ||
/** | ||
@@ -40,3 +40,3 @@ * The constructor function initializes a BinaryTreeNode object with a key, value, and count. | ||
*/ | ||
export declare class AVLTreeMultiMap<K = any, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>, TREE extends AVLTreeMultiMap<K, V, NODE, TREE> = AVLTreeMultiMap<K, V, NODE, AVLTreeMultiMapNested<K, V, NODE>>> extends AVLTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
export declare class AVLTreeMultiMap<K extends Comparable, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>, TREE extends AVLTreeMultiMap<K, V, NODE, TREE> = AVLTreeMultiMap<K, V, NODE, AVLTreeMultiMapNested<K, V, NODE>>> extends AVLTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K>); | ||
@@ -73,11 +73,2 @@ protected _count: number; | ||
createNode(key: K, value?: V, count?: number): NODE; | ||
/** | ||
* The function creates a new AVLTreeMultiMap object with the specified options and returns it. | ||
* @param [options] - The `options` parameter is an optional object that contains additional | ||
* configuration options for creating the `AVLTreeMultiMap` object. It can include properties such as | ||
* `iterationType` and `variant`, which are used to specify the type of iteration and the variant of | ||
* the tree, respectively. These properties can be | ||
* @returns a new instance of the `AVLTreeMultiMap` class, with the provided options merged with the | ||
* default options. The returned value is casted as `TREE`. | ||
*/ | ||
createTree(options?: AVLTreeMultiMapOptions<K>): TREE; | ||
@@ -84,0 +75,0 @@ /** |
@@ -86,13 +86,4 @@ "use strict"; | ||
} | ||
/** | ||
* The function creates a new AVLTreeMultiMap object with the specified options and returns it. | ||
* @param [options] - The `options` parameter is an optional object that contains additional | ||
* configuration options for creating the `AVLTreeMultiMap` object. It can include properties such as | ||
* `iterationType` and `variant`, which are used to specify the type of iteration and the variant of | ||
* the tree, respectively. These properties can be | ||
* @returns a new instance of the `AVLTreeMultiMap` class, with the provided options merged with the | ||
* default options. The returned value is casted as `TREE`. | ||
*/ | ||
createTree(options) { | ||
return new AVLTreeMultiMap([], Object.assign({ iterationType: this.iterationType, variant: this.variant }, options)); | ||
return new AVLTreeMultiMap([], Object.assign({ iterationType: this.iterationType, comparator: this.comparator }, options)); | ||
} | ||
@@ -99,0 +90,0 @@ /** |
@@ -9,5 +9,5 @@ /** | ||
import { BST, BSTNode } from './bst'; | ||
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry } from '../../types'; | ||
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, Comparable, KeyOrNodeOrEntry } from '../../types'; | ||
import { IBinaryTree } from '../../interfaces'; | ||
export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> { | ||
export declare class AVLTreeNode<K extends Comparable, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> { | ||
/** | ||
@@ -44,3 +44,3 @@ * The constructor function initializes a new instance of a class with a key and an optional value, | ||
*/ | ||
export declare class AVLTree<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, NODE, TREE> = AVLTree<K, V, NODE, AVLTreeNested<K, V, NODE>>> extends BST<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
export declare class AVLTree<K extends Comparable, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, NODE, TREE> = AVLTree<K, V, NODE, AVLTreeNested<K, V, NODE>>> extends BST<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
/** | ||
@@ -47,0 +47,0 @@ * The constructor function initializes an AVLTree object with optional keysOrNodesOrEntries and options. |
@@ -86,3 +86,3 @@ "use strict"; | ||
createTree(options) { | ||
return new AVLTree([], Object.assign({ iterationType: this.iterationType, variant: this.variant }, options)); | ||
return new AVLTree([], Object.assign({ iterationType: this.iterationType, comparator: this.comparator }, options)); | ||
} | ||
@@ -161,17 +161,17 @@ /** | ||
_swapProperties(srcNode, destNode) { | ||
srcNode = this.ensureNode(srcNode); | ||
destNode = this.ensureNode(destNode); | ||
if (srcNode && destNode) { | ||
const { key, value, height } = destNode; | ||
const srcNodeEnsured = this.ensureNode(srcNode); | ||
const destNodeEnsured = this.ensureNode(destNode); | ||
if (srcNodeEnsured && destNodeEnsured) { | ||
const { key, value, height } = destNodeEnsured; | ||
const tempNode = this.createNode(key, value); | ||
if (tempNode) { | ||
tempNode.height = height; | ||
destNode.key = srcNode.key; | ||
destNode.value = srcNode.value; | ||
destNode.height = srcNode.height; | ||
srcNode.key = tempNode.key; | ||
srcNode.value = tempNode.value; | ||
srcNode.height = tempNode.height; | ||
destNodeEnsured.key = srcNodeEnsured.key; | ||
destNodeEnsured.value = srcNodeEnsured.value; | ||
destNodeEnsured.height = srcNodeEnsured.height; | ||
srcNodeEnsured.key = tempNode.key; | ||
srcNodeEnsured.value = tempNode.value; | ||
srcNodeEnsured.height = tempNode.height; | ||
} | ||
return destNode; | ||
return destNodeEnsured; | ||
} | ||
@@ -178,0 +178,0 @@ return undefined; |
@@ -8,4 +8,3 @@ /** | ||
*/ | ||
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNCallback, BTNEntry, DFSOrderPattern, EntryCallback, KeyOrNodeOrEntry, NodeDisplayLayout } from '../../types'; | ||
import { FamilyPosition, IterationType } from '../../types'; | ||
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNCallback, BTNEntry, Comparable, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, KeyOrNodeOrEntry, NodeDisplayLayout } from '../../types'; | ||
import { IBinaryTree } from '../../interfaces'; | ||
@@ -18,3 +17,3 @@ import { IterableEntryBase } from '../base'; | ||
*/ | ||
export declare class BinaryTreeNode<K = any, V = any, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>> { | ||
export declare class BinaryTreeNode<K extends Comparable, V = any, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>> { | ||
key: K; | ||
@@ -71,3 +70,3 @@ value?: V; | ||
*/ | ||
export declare class BinaryTree<K = any, V = any, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, NODE, TREE> = BinaryTree<K, V, NODE, BinaryTreeNested<K, V, NODE>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, NODE, TREE> { | ||
export declare class BinaryTree<K extends Comparable, V = any, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, NODE, TREE> = BinaryTree<K, V, NODE, BinaryTreeNested<K, V, NODE>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, NODE, TREE> { | ||
iterationType: IterationType; | ||
@@ -83,9 +82,3 @@ /** | ||
*/ | ||
constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: BinaryTreeOptions<K>); | ||
protected _extractor: (key: K) => number; | ||
/** | ||
* The function returns the value of the `_extractor` property. | ||
* @returns The `_extractor` property is being returned. | ||
*/ | ||
get extractor(): (key: K) => number; | ||
constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: BinaryTreeOptions); | ||
protected _root?: NODE | null; | ||
@@ -124,3 +117,3 @@ /** | ||
*/ | ||
createTree(options?: Partial<BinaryTreeOptions<K>>): TREE; | ||
createTree(options?: Partial<BinaryTreeOptions>): TREE; | ||
/** | ||
@@ -127,0 +120,0 @@ * The function `keyValueOrEntryToNode` converts an keyOrNodeOrEntry object into a node object. |
@@ -8,7 +8,6 @@ /** | ||
*/ | ||
import type { BSTNested, BSTNodeNested, BSTOptions, BTNCallback, KeyOrNodeOrEntry } from '../../types'; | ||
import { BSTNKeyOrNode, BSTVariant, CP, DFSOrderPattern, IterationType } from '../../types'; | ||
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, Comparable, Comparator, CP, DFSOrderPattern, IterationType, KeyOrNodeOrEntry } from '../../types'; | ||
import { BinaryTree, BinaryTreeNode } from './binary-tree'; | ||
import { IBinaryTree } from '../../interfaces'; | ||
export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V>> extends BinaryTreeNode<K, V, NODE> { | ||
export declare class BSTNode<K extends Comparable, V = any, NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V>> extends BinaryTreeNode<K, V, NODE> { | ||
parent?: NODE; | ||
@@ -51,8 +50,9 @@ constructor(key: K, value?: V); | ||
*/ | ||
export declare class BST<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>, TREE extends BST<K, V, NODE, TREE> = BST<K, V, NODE, BSTNested<K, V, NODE>>> extends BinaryTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
export declare class BST<K extends Comparable, V = any, NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>, TREE extends BST<K, V, NODE, TREE> = BST<K, V, NODE, BSTNested<K, V, NODE>>> extends BinaryTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
/** | ||
* This is the constructor function for a TypeScript class that initializes a binary search tree with | ||
* optional keys or nodes or entries and options. | ||
* @param keysOrNodesOrEntries - An iterable object that contains keys, nodes, or entries. It is used | ||
* to initialize the binary search tree with the provided keys, nodes, or entries. | ||
* This is the constructor function for a Binary Search Tree class in TypeScript, which initializes | ||
* the tree with keys, nodes, or entries and optional options. | ||
* @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can | ||
* contain keys, nodes, or entries. It is used to initialize the binary search tree with the provided | ||
* keys, nodes, or entries. | ||
* @param [options] - The `options` parameter is an optional object that can contain additional | ||
@@ -68,8 +68,8 @@ * configuration options for the binary search tree. It can have the following properties: | ||
get root(): NODE | undefined; | ||
protected _variant: BSTVariant; | ||
protected _comparator: Comparator<K>; | ||
/** | ||
* The function returns the value of the _variant property. | ||
* @returns The value of the `_variant` property. | ||
* The function returns the value of the _comparator property. | ||
* @returns The `_comparator` property is being returned. | ||
*/ | ||
get variant(): BSTVariant; | ||
get comparator(): Comparator<K>; | ||
/** | ||
@@ -133,9 +133,7 @@ * The function creates a new BSTNode with the given key and value and returns it. | ||
* | ||
* The `add` function adds a new node to a binary tree, updating the value if the key already exists | ||
* or inserting a new node if the key is unique. | ||
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values: | ||
* @param {V} [value] - The `value` parameter represents the value associated with the key that is | ||
* being added to the binary tree. | ||
* @returns The method `add` returns either the newly added node (`newNode`) or `undefined` if the | ||
* node was not added. | ||
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value, | ||
* updating the value if the key already exists. | ||
* @param keyOrNodeOrEntry - It is a parameter that can accept three types of values: | ||
* @param {V} [value] - The value to be added to the binary search tree. | ||
* @returns The method returns a boolean value. | ||
*/ | ||
@@ -151,17 +149,20 @@ add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean; | ||
* | ||
* The `addMany` function in TypeScript adds multiple keys or nodes to a binary tree, optionally | ||
* balancing the tree after each addition. | ||
* @param keysOrNodesOrEntries - An iterable containing the keys, nodes, or entries to be added to | ||
* the binary tree. | ||
* The `addMany` function in TypeScript adds multiple keys or nodes to a data structure, balancing | ||
* the structure if specified, and returns an array indicating whether each key or node was | ||
* successfully inserted. | ||
* @param keysOrNodesOrEntries - An iterable containing keys, nodes, or entries to be added to the | ||
* data structure. | ||
* @param [values] - An optional iterable of values to be associated with the keys or nodes being | ||
* added. If provided, the values will be assigned to the corresponding keys or nodes in the same | ||
* order. If not provided, undefined will be assigned as the value for each key or node. | ||
* @param [isBalanceAdd=true] - A boolean flag indicating whether the add operation should be | ||
* balanced or not. If set to true, the add operation will be balanced using a binary search tree | ||
* algorithm. If set to false, the add operation will not be balanced and the nodes will be added | ||
* in the order they appear in the input. | ||
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the | ||
* type of iteration to use when adding multiple keys or nodes. It has a default value of | ||
* `this.iterationType`, which suggests that it is a property of the current object. | ||
* @returns The function `addMany` returns an array of nodes (`NODE`) or `undefined` values. | ||
* @param [isBalanceAdd=true] - A boolean flag indicating whether the tree should be balanced after | ||
* adding the elements. If set to true, the tree will be balanced using a binary search tree | ||
* algorithm. If set to false, the elements will be added without balancing the tree. The default | ||
* value is true. | ||
* @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that | ||
* specifies the type of iteration to use when adding multiple keys or nodes to the binary tree. It | ||
* has a default value of `this.iterationType`, which means it will use the iteration type specified | ||
* in the binary tree instance. | ||
* @returns The function `addMany` returns an array of booleans indicating whether each key or node | ||
* or entry was successfully inserted into the data structure. | ||
*/ | ||
@@ -314,20 +315,2 @@ addMany(keysOrNodesOrEntries: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[]; | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
* | ||
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the | ||
* leftmost node if the comparison result is greater than. | ||
* @param {K | NODE | undefined} beginRoot - The `beginRoot` parameter is optional and can be of | ||
* type `K`, `NODE`, or `undefined`. It represents the starting point for finding the last key in | ||
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`). | ||
* @returns the key of the rightmost node in the binary tree if the comparison result is less than, | ||
* the key of the leftmost node if the comparison result is greater than, and the key of the | ||
* rightmost node otherwise. If no node is found, it returns 0. | ||
*/ | ||
lastKey(beginRoot?: KeyOrNodeOrEntry<K, V, NODE>): K | undefined; | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(log n) | ||
@@ -402,30 +385,2 @@ */ | ||
protected _setRoot(v: NODE | undefined): void; | ||
/** | ||
* The function compares two values using a comparator function and returns whether the first value | ||
* is greater than, less than, or equal to the second value. | ||
* @param {K} a - The parameter "a" is of type K. | ||
* @param {K} b - The parameter "b" in the above code represents a K. | ||
* @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater | ||
* than), 'LT' (less than), or 'EQ' (equal). | ||
*/ | ||
protected _compare(a: K, b: K): CP; | ||
/** | ||
* The function `_lt` compares two values `a` and `b` using an extractor function and returns true if | ||
* `a` is less than `b` based on the specified variant. | ||
* @param {K} a - The parameter "a" is of type "K", which means it can be any type. It represents the | ||
* first value to be compared in the function. | ||
* @param {K} b - The parameter `b` is of type `K`, which means it can be any type. It is used as one | ||
* of the arguments for the comparison in the `_lt` function. | ||
* @returns a boolean value. | ||
*/ | ||
protected _lt(a: K, b: K): boolean; | ||
/** | ||
* The function compares two values using a custom extractor function and returns true if the first | ||
* value is greater than the second value. | ||
* @param {K} a - The parameter "a" is of type K, which means it can be any type. | ||
* @param {K} b - The parameter "b" is of type K, which means it can be any type. It is used as one | ||
* of the arguments for the comparison in the function. | ||
* @returns a boolean value. | ||
*/ | ||
protected _gt(a: K, b: K): boolean; | ||
} |
@@ -63,6 +63,7 @@ "use strict"; | ||
/** | ||
* This is the constructor function for a TypeScript class that initializes a binary search tree with | ||
* optional keys or nodes or entries and options. | ||
* @param keysOrNodesOrEntries - An iterable object that contains keys, nodes, or entries. It is used | ||
* to initialize the binary search tree with the provided keys, nodes, or entries. | ||
* This is the constructor function for a Binary Search Tree class in TypeScript, which initializes | ||
* the tree with keys, nodes, or entries and optional options. | ||
* @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can | ||
* contain keys, nodes, or entries. It is used to initialize the binary search tree with the provided | ||
* keys, nodes, or entries. | ||
* @param [options] - The `options` parameter is an optional object that can contain additional | ||
@@ -73,9 +74,15 @@ * configuration options for the binary search tree. It can have the following properties: | ||
super([], options); | ||
this._variant = 'STANDARD'; | ||
this._root = undefined; | ||
this._comparator = (a, b) => { | ||
if (a > b) | ||
return 1; | ||
if (a < b) | ||
return -1; | ||
return 0; | ||
}; | ||
if (options) { | ||
const { variant } = options; | ||
if (variant) | ||
this._variant = variant; | ||
const { comparator } = options; | ||
if (comparator) | ||
this._comparator = comparator; | ||
} | ||
this._root = undefined; | ||
if (keysOrNodesOrEntries) | ||
@@ -92,7 +99,7 @@ this.addMany(keysOrNodesOrEntries); | ||
/** | ||
* The function returns the value of the _variant property. | ||
* @returns The value of the `_variant` property. | ||
* The function returns the value of the _comparator property. | ||
* @returns The `_comparator` property is being returned. | ||
*/ | ||
get variant() { | ||
return this._variant; | ||
get comparator() { | ||
return this._comparator; | ||
} | ||
@@ -119,3 +126,3 @@ /** | ||
createTree(options) { | ||
return new BST([], Object.assign({ iterationType: this.iterationType, variant: this.variant }, options)); | ||
return new BST([], Object.assign({ iterationType: this.iterationType, comparator: this.comparator }, options)); | ||
} | ||
@@ -204,9 +211,7 @@ /** | ||
* | ||
* The `add` function adds a new node to a binary tree, updating the value if the key already exists | ||
* or inserting a new node if the key is unique. | ||
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values: | ||
* @param {V} [value] - The `value` parameter represents the value associated with the key that is | ||
* being added to the binary tree. | ||
* @returns The method `add` returns either the newly added node (`newNode`) or `undefined` if the | ||
* node was not added. | ||
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value, | ||
* updating the value if the key already exists. | ||
* @param keyOrNodeOrEntry - It is a parameter that can accept three types of values: | ||
* @param {V} [value] - The value to be added to the binary search tree. | ||
* @returns The method returns a boolean value. | ||
*/ | ||
@@ -224,3 +229,3 @@ add(keyOrNodeOrEntry, value) { | ||
while (current !== undefined) { | ||
if (this._compare(current.key, newNode.key) === 'EQ') { | ||
if (this.comparator(current.key, newNode.key) === 0) { | ||
// if (current !== newNode) { | ||
@@ -236,3 +241,3 @@ // The key value is the same but the reference is different, update the value of the existing node | ||
} | ||
else if (this._compare(current.key, newNode.key) === 'GT') { | ||
else if (this.comparator(current.key, newNode.key) > 0) { | ||
if (current.left === undefined) { | ||
@@ -264,17 +269,20 @@ current.left = newNode; | ||
* | ||
* The `addMany` function in TypeScript adds multiple keys or nodes to a binary tree, optionally | ||
* balancing the tree after each addition. | ||
* @param keysOrNodesOrEntries - An iterable containing the keys, nodes, or entries to be added to | ||
* the binary tree. | ||
* The `addMany` function in TypeScript adds multiple keys or nodes to a data structure, balancing | ||
* the structure if specified, and returns an array indicating whether each key or node was | ||
* successfully inserted. | ||
* @param keysOrNodesOrEntries - An iterable containing keys, nodes, or entries to be added to the | ||
* data structure. | ||
* @param [values] - An optional iterable of values to be associated with the keys or nodes being | ||
* added. If provided, the values will be assigned to the corresponding keys or nodes in the same | ||
* order. If not provided, undefined will be assigned as the value for each key or node. | ||
* @param [isBalanceAdd=true] - A boolean flag indicating whether the add operation should be | ||
* balanced or not. If set to true, the add operation will be balanced using a binary search tree | ||
* algorithm. If set to false, the add operation will not be balanced and the nodes will be added | ||
* in the order they appear in the input. | ||
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the | ||
* type of iteration to use when adding multiple keys or nodes. It has a default value of | ||
* `this.iterationType`, which suggests that it is a property of the current object. | ||
* @returns The function `addMany` returns an array of nodes (`NODE`) or `undefined` values. | ||
* @param [isBalanceAdd=true] - A boolean flag indicating whether the tree should be balanced after | ||
* adding the elements. If set to true, the tree will be balanced using a binary search tree | ||
* algorithm. If set to false, the elements will be added without balancing the tree. The default | ||
* value is true. | ||
* @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that | ||
* specifies the type of iteration to use when adding multiple keys or nodes to the binary tree. It | ||
* has a default value of `this.iterationType`, which means it will use the iteration type specified | ||
* in the binary tree instance. | ||
* @returns The function `addMany` returns an array of booleans indicating whether each key or node | ||
* or entry was successfully inserted into the data structure. | ||
*/ | ||
@@ -306,16 +314,20 @@ addMany(keysOrNodesOrEntries, values, isBalanceAdd = true, iterationType = this.iterationType) { | ||
sorted = realBTNExemplars.sort((a, b) => { | ||
let aR, bR; | ||
if (this.isEntry(a)) | ||
aR = this.extractor(a[0]); | ||
let keyA, keyB; | ||
if (this.isEntry(a)) { | ||
keyA = a[0]; | ||
} | ||
else if (this.isRealNode(a)) | ||
aR = this.extractor(a.key); | ||
keyA = a.key; | ||
else | ||
aR = this.extractor(a); | ||
keyA = a; | ||
if (this.isEntry(b)) | ||
bR = this.extractor(b[0]); | ||
keyB = b[0]; | ||
else if (this.isRealNode(b)) | ||
bR = this.extractor(b.key); | ||
keyB = b.key; | ||
else | ||
bR = this.extractor(b); | ||
return aR - bR; | ||
keyB = b; | ||
if (keyA !== undefined && keyA !== null && keyB !== undefined && keyB !== null) { | ||
return this.comparator(keyA, keyB); | ||
} | ||
return 0; | ||
}); | ||
@@ -402,5 +414,5 @@ const _dfs = (arr) => { | ||
if (callback === this._DEFAULT_CALLBACK) { | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === 'GT') | ||
if (this.isRealNode(cur.left) && this.comparator(cur.key, identifier) > 0) | ||
dfs(cur.left); | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === 'LT') | ||
if (this.isRealNode(cur.right) && this.comparator(cur.key, identifier) < 0) | ||
dfs(cur.right); | ||
@@ -427,5 +439,5 @@ } | ||
if (callback === this._DEFAULT_CALLBACK) { | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === 'LT') | ||
if (this.isRealNode(cur.right) && this.comparator(cur.key, identifier) < 0) | ||
stack.push(cur.right); | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === 'GT') | ||
if (this.isRealNode(cur.left) && this.comparator(cur.key, identifier) > 0) | ||
stack.push(cur.left); | ||
@@ -574,37 +586,2 @@ // if (this.isRealNode(cur.right) && this._lt(cur.key, identifier as K)) stack.push(cur.right); | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
* | ||
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the | ||
* leftmost node if the comparison result is greater than. | ||
* @param {K | NODE | undefined} beginRoot - The `beginRoot` parameter is optional and can be of | ||
* type `K`, `NODE`, or `undefined`. It represents the starting point for finding the last key in | ||
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`). | ||
* @returns the key of the rightmost node in the binary tree if the comparison result is less than, | ||
* the key of the leftmost node if the comparison result is greater than, and the key of the | ||
* rightmost node otherwise. If no node is found, it returns 0. | ||
*/ | ||
lastKey(beginRoot = this.root) { | ||
let current = this.ensureNode(beginRoot); | ||
if (!current) | ||
return undefined; | ||
if (this._variant === 'STANDARD') { | ||
// For 'STANDARD', find the rightmost node | ||
while (current.right !== undefined) { | ||
current = current.right; | ||
} | ||
} | ||
else { | ||
// For BSTVariant.MAX, find the leftmost node | ||
while (current.left !== undefined) { | ||
current = current.left; | ||
} | ||
} | ||
return current.key; | ||
} | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(log n) | ||
@@ -633,14 +610,14 @@ */ | ||
*/ | ||
lesserOrGreaterTraverse(callback = this._DEFAULT_CALLBACK, lesserOrGreater = 'LT', targetNode = this.root, iterationType = this.iterationType) { | ||
targetNode = this.ensureNode(targetNode); | ||
lesserOrGreaterTraverse(callback = this._DEFAULT_CALLBACK, lesserOrGreater = -1, targetNode = this.root, iterationType = this.iterationType) { | ||
const targetNodeEnsured = this.ensureNode(targetNode); | ||
const ans = []; | ||
if (!targetNode) | ||
if (!targetNodeEnsured) | ||
return ans; | ||
if (!this.root) | ||
return ans; | ||
const targetKey = targetNode.key; | ||
const targetKey = targetNodeEnsured.key; | ||
if (iterationType === 'RECURSIVE') { | ||
const dfs = (cur) => { | ||
const compared = this._compare(cur.key, targetKey); | ||
if (compared === lesserOrGreater) | ||
const compared = this.comparator(cur.key, targetKey); | ||
if (Math.sign(compared) === lesserOrGreater) | ||
ans.push(callback(cur)); | ||
@@ -660,4 +637,4 @@ if (this.isRealNode(cur.left)) | ||
if (this.isRealNode(cur)) { | ||
const compared = this._compare(cur.key, targetKey); | ||
if (compared === lesserOrGreater) | ||
const compared = this.comparator(cur.key, targetKey); | ||
if (Math.sign(compared) === lesserOrGreater) | ||
ans.push(callback(cur)); | ||
@@ -803,48 +780,3 @@ if (this.isRealNode(cur.left)) | ||
} | ||
/** | ||
* The function compares two values using a comparator function and returns whether the first value | ||
* is greater than, less than, or equal to the second value. | ||
* @param {K} a - The parameter "a" is of type K. | ||
* @param {K} b - The parameter "b" in the above code represents a K. | ||
* @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater | ||
* than), 'LT' (less than), or 'EQ' (equal). | ||
*/ | ||
_compare(a, b) { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
const compared = this.variant === 'STANDARD' ? extractedA - extractedB : extractedB - extractedA; | ||
if (compared > 0) | ||
return 'GT'; | ||
if (compared < 0) | ||
return 'LT'; | ||
return 'EQ'; | ||
} | ||
/** | ||
* The function `_lt` compares two values `a` and `b` using an extractor function and returns true if | ||
* `a` is less than `b` based on the specified variant. | ||
* @param {K} a - The parameter "a" is of type "K", which means it can be any type. It represents the | ||
* first value to be compared in the function. | ||
* @param {K} b - The parameter `b` is of type `K`, which means it can be any type. It is used as one | ||
* of the arguments for the comparison in the `_lt` function. | ||
* @returns a boolean value. | ||
*/ | ||
_lt(a, b) { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
return this.variant === 'STANDARD' ? extractedA < extractedB : extractedA > extractedB; | ||
} | ||
/** | ||
* The function compares two values using a custom extractor function and returns true if the first | ||
* value is greater than the second value. | ||
* @param {K} a - The parameter "a" is of type K, which means it can be any type. | ||
* @param {K} b - The parameter "b" is of type K, which means it can be any type. It is used as one | ||
* of the arguments for the comparison in the function. | ||
* @returns a boolean value. | ||
*/ | ||
_gt(a, b) { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
return this.variant === 'STANDARD' ? extractedA > extractedB : extractedA < extractedB; | ||
} | ||
} | ||
exports.BST = BST; |
@@ -1,6 +0,5 @@ | ||
import type { BinaryTreeDeleteResult, BTNCallback, KeyOrNodeOrEntry, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types'; | ||
import { CP, CRUD, RBTNColor } from '../../types'; | ||
import type { BinaryTreeDeleteResult, BTNCallback, Comparable, CRUD, KeyOrNodeOrEntry, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types'; | ||
import { BST, BSTNode } from './bst'; | ||
import { IBinaryTree } from '../../interfaces'; | ||
export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> { | ||
export declare class RedBlackTreeNode<K extends Comparable, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> { | ||
/** | ||
@@ -30,3 +29,3 @@ * The constructor function initializes a Red-Black Tree Node with a key, an optional value, and a | ||
} | ||
export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, TREE extends RedBlackTree<K, V, NODE, TREE> = RedBlackTree<K, V, NODE, RedBlackTreeNested<K, V, NODE>>> extends BST<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
export declare class RedBlackTree<K extends Comparable, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, TREE extends RedBlackTree<K, V, NODE, TREE> = RedBlackTree<K, V, NODE, RedBlackTreeNested<K, V, NODE>>> extends BST<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
/** | ||
@@ -259,11 +258,2 @@ * This is the constructor function for a Red-Black Tree data structure in TypeScript. | ||
protected _rightRotate(y: NODE | undefined): void; | ||
/** | ||
* The function compares two values using a comparator function and returns whether the first value | ||
* is greater than, less than, or equal to the second value. | ||
* @param {K} a - The parameter "a" is of type K. | ||
* @param {K} b - The parameter "b" in the above code represents a K. | ||
* @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater | ||
* than), 'LT' (less than), or 'EQ' (equal). | ||
*/ | ||
protected _compare(a: K, b: K): CP; | ||
} |
@@ -317,6 +317,7 @@ "use strict"; | ||
parent = current; | ||
if (node.key < current.key) { | ||
const compared = this.comparator(node.key, current.key); | ||
if (compared < 0) { | ||
current = (_a = current.left) !== null && _a !== void 0 ? _a : this.NIL; | ||
} | ||
else if (node.key > current.key) { | ||
else if (compared > 0) { | ||
current = (_b = current.right) !== null && _b !== void 0 ? _b : this.NIL; | ||
@@ -603,21 +604,3 @@ } | ||
} | ||
/** | ||
* The function compares two values using a comparator function and returns whether the first value | ||
* is greater than, less than, or equal to the second value. | ||
* @param {K} a - The parameter "a" is of type K. | ||
* @param {K} b - The parameter "b" in the above code represents a K. | ||
* @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater | ||
* than), 'LT' (less than), or 'EQ' (equal). | ||
*/ | ||
_compare(a, b) { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
const compared = extractedA - extractedB; | ||
if (compared > 0) | ||
return 'GT'; | ||
if (compared < 0) | ||
return 'LT'; | ||
return 'EQ'; | ||
} | ||
} | ||
exports.RedBlackTree = RedBlackTree; |
@@ -8,7 +8,6 @@ /** | ||
*/ | ||
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, IterationType, KeyOrNodeOrEntry, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types'; | ||
import { RBTNColor } from '../../types'; | ||
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, Comparable, IterationType, KeyOrNodeOrEntry, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types'; | ||
import { IBinaryTree } from '../../interfaces'; | ||
import { RedBlackTree, RedBlackTreeNode } from './rb-tree'; | ||
export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> { | ||
export declare class TreeMultiMapNode<K extends Comparable, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> { | ||
/** | ||
@@ -40,3 +39,3 @@ * The constructor function initializes a Red-Black Tree node with a key, value, count, and color. | ||
} | ||
export declare class TreeMultiMap<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, TREE extends TreeMultiMap<K, V, NODE, TREE> = TreeMultiMap<K, V, NODE, TreeMultiMapNested<K, V, NODE>>> extends RedBlackTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
export declare class TreeMultiMap<K extends Comparable, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, TREE extends TreeMultiMap<K, V, NODE, TREE> = TreeMultiMap<K, V, NODE, TreeMultiMapNested<K, V, NODE>>> extends RedBlackTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> { | ||
/** | ||
@@ -43,0 +42,0 @@ * The constructor function initializes a new instance of the TreeMultiMap class with optional |
@@ -60,5 +60,3 @@ /** | ||
*/ | ||
static heapify<E>(elements: Iterable<E>, options: { | ||
comparator: Comparator<E>; | ||
}): Heap<E>; | ||
static heapify<E>(elements: Iterable<E>, options: HeapOptions<E>): Heap<E>; | ||
/** | ||
@@ -65,0 +63,0 @@ * Time Complexity: O(log n) |
import { BinaryTree, BinaryTreeNode } from '../data-structures'; | ||
import { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, KeyOrNodeOrEntry } from '../types'; | ||
export interface IBinaryTree<K = number, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTreeNested<K, V, N>> { | ||
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, Comparable, KeyOrNodeOrEntry } from '../types'; | ||
export interface IBinaryTree<K extends Comparable, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTreeNested<K, V, N>> { | ||
createNode(key: K, value?: N['value']): N; | ||
createTree(options?: Partial<BinaryTreeOptions<K>>): TREE; | ||
createTree(options?: Partial<BinaryTreeOptions>): TREE; | ||
add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V, count?: number): boolean; | ||
@@ -7,0 +7,0 @@ addMany(nodes: Iterable<KeyOrNodeOrEntry<K, V, N>>, values?: Iterable<V | undefined>): boolean[]; |
export type BSTVariant = 'STANDARD' | 'INVERSE'; | ||
export type CP = 'LT' | 'EQ' | 'GT'; | ||
export type CP = 1 | -1 | 0; | ||
/** | ||
@@ -4,0 +4,0 @@ * Enum representing different loop types. |
import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures'; | ||
import type { AVLTreeOptions } from './avl-tree'; | ||
export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type AVLTreeMultiMapNested<K, V, N extends AVLTreeMultiMapNode<K, V, N>> = AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
import { Comparable } from "../../utils"; | ||
export type AVLTreeMultiMapNodeNested<K extends Comparable, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type AVLTreeMultiMapNested<K extends Comparable, V, N extends AVLTreeMultiMapNode<K, V, N>> = AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type AVLTreeMultiMapOptions<K> = AVLTreeOptions<K> & {}; |
import { AVLTree, AVLTreeNode } from '../../../data-structures'; | ||
import { BSTOptions } from './bst'; | ||
export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type AVLTreeNested<K, V, N extends AVLTreeNode<K, V, N>> = AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
import { Comparable } from "../../utils"; | ||
export type AVLTreeNodeNested<K extends Comparable, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type AVLTreeNested<K extends Comparable, V, N extends AVLTreeNode<K, V, N>> = AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type AVLTreeOptions<K> = BSTOptions<K> & {}; |
import { BinaryTree, BinaryTreeNode } from '../../../data-structures'; | ||
import { IterationType } 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type BinaryTreeNested<K, V, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type BinaryTreeOptions<K> = { | ||
import { Comparable } from "../../utils"; | ||
export type BinaryTreeNodeNested<K extends Comparable, 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 BinaryTreeNested<K extends Comparable, V, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type BinaryTreeOptions = { | ||
iterationType?: IterationType; | ||
extractor?: (key: K) => number; | ||
}; |
import { BST, BSTNode } from '../../../data-structures'; | ||
import type { BinaryTreeOptions } from './binary-tree'; | ||
import { BSTVariant } from "../../common"; | ||
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type BSTNested<K, V, N extends BSTNode<K, V, N>> = BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type BSTOptions<K> = BinaryTreeOptions<K> & { | ||
variant?: BSTVariant; | ||
import { Comparator } from "../../common"; | ||
import { Comparable } from "../../utils"; | ||
export type BSTNodeNested<K extends Comparable, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type BSTNested<K extends Comparable, V, N extends BSTNode<K, V, N>> = BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type BSTOptions<K> = BinaryTreeOptions & { | ||
comparator?: Comparator<K>; | ||
}; |
import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures'; | ||
import type { BSTOptions } from "./bst"; | ||
import { Comparable } from "../../utils"; | ||
export type RBTNColor = 'RED' | 'BLACK'; | ||
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type RedBlackTreeNested<K, V, N extends RedBlackTreeNode<K, V, N>> = RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type RBTreeOptions<K> = Omit<BSTOptions<K>, 'variant'> & {}; | ||
export type RedBlackTreeNodeNested<K extends Comparable, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type RedBlackTreeNested<K extends Comparable, V, N extends RedBlackTreeNode<K, V, N>> = RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type RBTreeOptions<K> = BSTOptions<K> & {}; |
import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures'; | ||
import type { RBTreeOptions } from './rb-tree'; | ||
export type TreeMultiMapNodeNested<K, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type TreeMultiMapNested<K, V, N extends TreeMultiMapNode<K, V, N>> = TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
import { Comparable } from "../../utils"; | ||
export type TreeMultiMapNodeNested<K extends Comparable, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type TreeMultiMapNested<K extends Comparable, V, N extends TreeMultiMapNode<K, V, N>> = TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; | ||
export type TreeMultiMapOptions<K> = RBTreeOptions<K> & {}; |
@@ -8,2 +8,11 @@ export type ToThunkFn = () => ReturnType<TrlFn>; | ||
export type SpecifyOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
export type Any = string | number | boolean | object | null | undefined | symbol; | ||
export type Any = string | number | bigint | boolean | symbol | undefined | object; | ||
export type Comparable = number | string | bigint | boolean | ({ | ||
[key in string]: any; | ||
} & { | ||
valueOf(): Comparable; | ||
}) | ({ | ||
[key in string]: any; | ||
} & { | ||
toString(): Comparable; | ||
}) | (() => Comparable); |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import type { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types'; | ||
import type { Comparable, Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types'; | ||
export declare const uuidV4: () => string; | ||
@@ -27,1 +27,2 @@ export declare const arrayRemove: <T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean) => T[]; | ||
export declare const roundFixed: (num: number, digit?: number) => number; | ||
export declare function isComparable(key: any): key is Comparable; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.roundFixed = exports.calcMinUnitsRequired = exports.isWeakKey = exports.throwRangeError = exports.rangeCheck = exports.getMSB = exports.trampolineAsync = exports.trampoline = exports.toThunk = exports.isThunk = exports.THUNK_SYMBOL = exports.arrayRemove = exports.uuidV4 = void 0; | ||
exports.isComparable = exports.roundFixed = exports.calcMinUnitsRequired = exports.isWeakKey = exports.throwRangeError = exports.rangeCheck = exports.getMSB = exports.trampolineAsync = exports.trampoline = exports.toThunk = exports.isThunk = exports.THUNK_SYMBOL = exports.arrayRemove = exports.uuidV4 = void 0; | ||
const uuidV4 = function () { | ||
@@ -96,1 +96,29 @@ return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) { | ||
exports.roundFixed = roundFixed; | ||
function isComparable(key) { | ||
const keyType = typeof key; | ||
if (keyType === 'number') | ||
return isNaN(key); | ||
if (keyType === 'string') | ||
return true; | ||
if (keyType === 'bigint') | ||
return true; | ||
if (keyType === 'boolean') | ||
return true; | ||
if (keyType === 'symbol') | ||
return false; | ||
if (keyType === 'undefined') | ||
return false; | ||
if (keyType === 'function') | ||
return isComparable(key()); | ||
if (keyType === 'object') { | ||
if (key === null) | ||
return true; | ||
if (typeof key.valueOf === 'function') | ||
return isComparable(key.valueOf()); | ||
if (typeof key.toString === 'function') | ||
return isComparable(key.toString()); | ||
return false; | ||
} | ||
return false; | ||
} | ||
exports.isComparable = isComparable; |
{ | ||
"name": "red-black-tree-typed", | ||
"version": "1.51.7", | ||
"version": "1.51.8", | ||
"description": "RedBlackTree. Javascript & Typescript Data Structure.", | ||
@@ -145,4 +145,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"data-structure-typed": "^1.51.7" | ||
"data-structure-typed": "^1.51.8" | ||
} | ||
} |
@@ -15,2 +15,3 @@ /** | ||
BTNCallback, | ||
Comparable, | ||
IterationType, | ||
@@ -23,3 +24,3 @@ KeyOrNodeOrEntry | ||
export class AVLTreeMultiMapNode< | ||
K = any, | ||
K extends Comparable, | ||
V = any, | ||
@@ -67,3 +68,3 @@ NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V> | ||
export class AVLTreeMultiMap< | ||
K = any, | ||
K extends Comparable, | ||
V = any, | ||
@@ -124,15 +125,6 @@ NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>, | ||
/** | ||
* The function creates a new AVLTreeMultiMap object with the specified options and returns it. | ||
* @param [options] - The `options` parameter is an optional object that contains additional | ||
* configuration options for creating the `AVLTreeMultiMap` object. It can include properties such as | ||
* `iterationType` and `variant`, which are used to specify the type of iteration and the variant of | ||
* the tree, respectively. These properties can be | ||
* @returns a new instance of the `AVLTreeMultiMap` class, with the provided options merged with the | ||
* default options. The returned value is casted as `TREE`. | ||
*/ | ||
override createTree(options?: AVLTreeMultiMapOptions<K>): TREE { | ||
return new AVLTreeMultiMap<K, V, NODE, TREE>([], { | ||
iterationType: this.iterationType, | ||
variant: this.variant, | ||
comparator: this.comparator, | ||
...options | ||
@@ -139,0 +131,0 @@ }) as TREE; |
@@ -16,2 +16,3 @@ /** | ||
BTNCallback, | ||
Comparable, | ||
KeyOrNodeOrEntry | ||
@@ -22,3 +23,3 @@ } from '../../types'; | ||
export class AVLTreeNode< | ||
K = any, | ||
K extends Comparable, | ||
V = any, | ||
@@ -70,3 +71,3 @@ NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V> | ||
export class AVLTree< | ||
K = any, | ||
K extends Comparable, | ||
V = any, | ||
@@ -115,3 +116,3 @@ NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, | ||
iterationType: this.iterationType, | ||
variant: this.variant, | ||
comparator: this.comparator, | ||
...options | ||
@@ -202,7 +203,7 @@ }) as TREE; | ||
): NODE | undefined { | ||
srcNode = this.ensureNode(srcNode); | ||
destNode = this.ensureNode(destNode); | ||
const srcNodeEnsured = this.ensureNode(srcNode); | ||
const destNodeEnsured = this.ensureNode(destNode); | ||
if (srcNode && destNode) { | ||
const { key, value, height } = destNode; | ||
if (srcNodeEnsured && destNodeEnsured) { | ||
const { key, value, height } = destNodeEnsured; | ||
const tempNode = this.createNode(key, value); | ||
@@ -213,12 +214,12 @@ | ||
destNode.key = srcNode.key; | ||
destNode.value = srcNode.value; | ||
destNode.height = srcNode.height; | ||
destNodeEnsured.key = srcNodeEnsured.key; | ||
destNodeEnsured.value = srcNodeEnsured.value; | ||
destNodeEnsured.height = srcNodeEnsured.height; | ||
srcNode.key = tempNode.key; | ||
srcNode.value = tempNode.value; | ||
srcNode.height = tempNode.height; | ||
srcNodeEnsured.key = tempNode.key; | ||
srcNodeEnsured.value = tempNode.value; | ||
srcNodeEnsured.height = tempNode.height; | ||
} | ||
return destNode; | ||
return destNodeEnsured; | ||
} | ||
@@ -225,0 +226,0 @@ return undefined; |
@@ -10,2 +10,3 @@ /** | ||
BSTNested, | ||
BSTNKeyOrNode, | ||
BSTNodeNested, | ||
@@ -15,5 +16,9 @@ BSTOptions, | ||
BTNodePureExemplar, | ||
Comparable, | ||
Comparator, | ||
CP, | ||
DFSOrderPattern, | ||
IterationType, | ||
KeyOrNodeOrEntry | ||
} from '../../types'; | ||
import { BSTNKeyOrNode, BSTVariant, CP, DFSOrderPattern, IterationType } from '../../types'; | ||
import { BinaryTree, BinaryTreeNode } from './binary-tree'; | ||
@@ -23,7 +28,7 @@ import { IBinaryTree } from '../../interfaces'; | ||
export class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V>> extends BinaryTreeNode< | ||
K, | ||
V, | ||
NODE | ||
> { | ||
export class BSTNode< | ||
K extends Comparable, | ||
V = any, | ||
NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V> | ||
> extends BinaryTreeNode<K, V, NODE> { | ||
override parent?: NODE; | ||
@@ -94,3 +99,3 @@ | ||
export class BST< | ||
K = any, | ||
K extends Comparable, | ||
V = any, | ||
@@ -103,6 +108,7 @@ NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>, | ||
/** | ||
* This is the constructor function for a TypeScript class that initializes a binary search tree with | ||
* optional keys or nodes or entries and options. | ||
* @param keysOrNodesOrEntries - An iterable object that contains keys, nodes, or entries. It is used | ||
* to initialize the binary search tree with the provided keys, nodes, or entries. | ||
* This is the constructor function for a Binary Search Tree class in TypeScript, which initializes | ||
* the tree with keys, nodes, or entries and optional options. | ||
* @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can | ||
* contain keys, nodes, or entries. It is used to initialize the binary search tree with the provided | ||
* keys, nodes, or entries. | ||
* @param [options] - The `options` parameter is an optional object that can contain additional | ||
@@ -115,12 +121,10 @@ * configuration options for the binary search tree. It can have the following properties: | ||
if (options) { | ||
const { variant } = options; | ||
if (variant) this._variant = variant; | ||
const { comparator } = options; | ||
if (comparator) this._comparator = comparator; | ||
} | ||
this._root = undefined; | ||
if (keysOrNodesOrEntries) this.addMany(keysOrNodesOrEntries); | ||
} | ||
protected override _root?: NODE; | ||
protected override _root?: NODE = undefined; | ||
@@ -135,10 +139,14 @@ /** | ||
protected _variant: BSTVariant = 'STANDARD'; | ||
protected _comparator: Comparator<K> = (a: K, b: K): CP => { | ||
if (a > b) return 1; | ||
if (a < b) return -1; | ||
return 0; | ||
}; | ||
/** | ||
* The function returns the value of the _variant property. | ||
* @returns The value of the `_variant` property. | ||
* The function returns the value of the _comparator property. | ||
* @returns The `_comparator` property is being returned. | ||
*/ | ||
get variant() { | ||
return this._variant; | ||
get comparator() { | ||
return this._comparator; | ||
} | ||
@@ -169,3 +177,3 @@ | ||
iterationType: this.iterationType, | ||
variant: this.variant, | ||
comparator: this.comparator, | ||
...options | ||
@@ -259,9 +267,7 @@ }) as TREE; | ||
* | ||
* The `add` function adds a new node to a binary tree, updating the value if the key already exists | ||
* or inserting a new node if the key is unique. | ||
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values: | ||
* @param {V} [value] - The `value` parameter represents the value associated with the key that is | ||
* being added to the binary tree. | ||
* @returns The method `add` returns either the newly added node (`newNode`) or `undefined` if the | ||
* node was not added. | ||
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value, | ||
* updating the value if the key already exists. | ||
* @param keyOrNodeOrEntry - It is a parameter that can accept three types of values: | ||
* @param {V} [value] - The value to be added to the binary search tree. | ||
* @returns The method returns a boolean value. | ||
*/ | ||
@@ -280,3 +286,3 @@ override add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean { | ||
while (current !== undefined) { | ||
if (this._compare(current.key, newNode.key) === 'EQ') { | ||
if (this.comparator(current.key, newNode.key) === 0) { | ||
// if (current !== newNode) { | ||
@@ -293,3 +299,3 @@ // The key value is the same but the reference is different, update the value of the existing node | ||
// } | ||
} else if (this._compare(current.key, newNode.key) === 'GT') { | ||
} else if (this.comparator(current.key, newNode.key) > 0) { | ||
if (current.left === undefined) { | ||
@@ -323,17 +329,20 @@ current.left = newNode; | ||
* | ||
* The `addMany` function in TypeScript adds multiple keys or nodes to a binary tree, optionally | ||
* balancing the tree after each addition. | ||
* @param keysOrNodesOrEntries - An iterable containing the keys, nodes, or entries to be added to | ||
* the binary tree. | ||
* The `addMany` function in TypeScript adds multiple keys or nodes to a data structure, balancing | ||
* the structure if specified, and returns an array indicating whether each key or node was | ||
* successfully inserted. | ||
* @param keysOrNodesOrEntries - An iterable containing keys, nodes, or entries to be added to the | ||
* data structure. | ||
* @param [values] - An optional iterable of values to be associated with the keys or nodes being | ||
* added. If provided, the values will be assigned to the corresponding keys or nodes in the same | ||
* order. If not provided, undefined will be assigned as the value for each key or node. | ||
* @param [isBalanceAdd=true] - A boolean flag indicating whether the add operation should be | ||
* balanced or not. If set to true, the add operation will be balanced using a binary search tree | ||
* algorithm. If set to false, the add operation will not be balanced and the nodes will be added | ||
* in the order they appear in the input. | ||
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the | ||
* type of iteration to use when adding multiple keys or nodes. It has a default value of | ||
* `this.iterationType`, which suggests that it is a property of the current object. | ||
* @returns The function `addMany` returns an array of nodes (`NODE`) or `undefined` values. | ||
* @param [isBalanceAdd=true] - A boolean flag indicating whether the tree should be balanced after | ||
* adding the elements. If set to true, the tree will be balanced using a binary search tree | ||
* algorithm. If set to false, the elements will be added without balancing the tree. The default | ||
* value is true. | ||
* @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that | ||
* specifies the type of iteration to use when adding multiple keys or nodes to the binary tree. It | ||
* has a default value of `this.iterationType`, which means it will use the iteration type specified | ||
* in the binary tree instance. | ||
* @returns The function `addMany` returns an array of booleans indicating whether each key or node | ||
* or entry was successfully inserted into the data structure. | ||
*/ | ||
@@ -377,12 +386,16 @@ override addMany( | ||
sorted = realBTNExemplars.sort((a, b) => { | ||
let aR: number, bR: number; | ||
if (this.isEntry(a)) aR = this.extractor(a[0]); | ||
else if (this.isRealNode(a)) aR = this.extractor(a.key); | ||
else aR = this.extractor(a); | ||
let keyA: K | undefined | null, keyB: K | undefined | null; | ||
if (this.isEntry(a)) { | ||
keyA = a[0]; | ||
} else if (this.isRealNode(a)) keyA = a.key; | ||
else keyA = a; | ||
if (this.isEntry(b)) bR = this.extractor(b[0]); | ||
else if (this.isRealNode(b)) bR = this.extractor(b.key); | ||
else bR = this.extractor(b); | ||
if (this.isEntry(b)) keyB = b[0]; | ||
else if (this.isRealNode(b)) keyB = b.key; | ||
else keyB = b; | ||
return aR - bR; | ||
if (keyA !== undefined && keyA !== null && keyB !== undefined && keyB !== null) { | ||
return this.comparator(keyA, keyB); | ||
} | ||
return 0; | ||
}); | ||
@@ -478,4 +491,4 @@ | ||
if (callback === this._DEFAULT_CALLBACK) { | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, identifier as K) === 'GT') dfs(cur.left); | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, identifier as K) === 'LT') dfs(cur.right); | ||
if (this.isRealNode(cur.left) && this.comparator(cur.key, identifier as K) > 0) dfs(cur.left); | ||
if (this.isRealNode(cur.right) && this.comparator(cur.key, identifier as K) < 0) dfs(cur.right); | ||
} else { | ||
@@ -499,4 +512,4 @@ this.isRealNode(cur.left) && dfs(cur.left); | ||
if (callback === this._DEFAULT_CALLBACK) { | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, identifier as K) === 'LT') stack.push(cur.right); | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, identifier as K) === 'GT') stack.push(cur.left); | ||
if (this.isRealNode(cur.right) && this.comparator(cur.key, identifier as K) < 0) stack.push(cur.right); | ||
if (this.isRealNode(cur.left) && this.comparator(cur.key, identifier as K) > 0) stack.push(cur.left); | ||
@@ -674,38 +687,2 @@ // if (this.isRealNode(cur.right) && this._lt(cur.key, identifier as K)) stack.push(cur.right); | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
* | ||
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the | ||
* leftmost node if the comparison result is greater than. | ||
* @param {K | NODE | undefined} beginRoot - The `beginRoot` parameter is optional and can be of | ||
* type `K`, `NODE`, or `undefined`. It represents the starting point for finding the last key in | ||
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`). | ||
* @returns the key of the rightmost node in the binary tree if the comparison result is less than, | ||
* the key of the leftmost node if the comparison result is greater than, and the key of the | ||
* rightmost node otherwise. If no node is found, it returns 0. | ||
*/ | ||
lastKey(beginRoot: KeyOrNodeOrEntry<K, V, NODE> = this.root): K | undefined { | ||
let current = this.ensureNode(beginRoot); | ||
if (!current) return undefined; | ||
if (this._variant === 'STANDARD') { | ||
// For 'STANDARD', find the rightmost node | ||
while (current.right !== undefined) { | ||
current = current.right; | ||
} | ||
} else { | ||
// For BSTVariant.MAX, find the leftmost node | ||
while (current.left !== undefined) { | ||
current = current.left; | ||
} | ||
} | ||
return current.key; | ||
} | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(log n) | ||
@@ -737,17 +714,17 @@ */ | ||
callback: C = this._DEFAULT_CALLBACK as C, | ||
lesserOrGreater: CP = 'LT', | ||
lesserOrGreater: CP = -1, | ||
targetNode: KeyOrNodeOrEntry<K, V, NODE> = this.root, | ||
iterationType: IterationType = this.iterationType | ||
): ReturnType<C>[] { | ||
targetNode = this.ensureNode(targetNode); | ||
const targetNodeEnsured = this.ensureNode(targetNode); | ||
const ans: ReturnType<BTNCallback<NODE>>[] = []; | ||
if (!targetNode) return ans; | ||
if (!targetNodeEnsured) return ans; | ||
if (!this.root) return ans; | ||
const targetKey = targetNode.key; | ||
const targetKey = targetNodeEnsured.key; | ||
if (iterationType === 'RECURSIVE') { | ||
const dfs = (cur: NODE) => { | ||
const compared = this._compare(cur.key, targetKey); | ||
if (compared === lesserOrGreater) ans.push(callback(cur)); | ||
const compared = this.comparator(cur.key, targetKey); | ||
if (Math.sign(compared) === lesserOrGreater) ans.push(callback(cur)); | ||
@@ -765,4 +742,4 @@ if (this.isRealNode(cur.left)) dfs(cur.left); | ||
if (this.isRealNode(cur)) { | ||
const compared = this._compare(cur.key, targetKey); | ||
if (compared === lesserOrGreater) ans.push(callback(cur)); | ||
const compared = this.comparator(cur.key, targetKey); | ||
if (Math.sign(compared) === lesserOrGreater) ans.push(callback(cur)); | ||
@@ -909,49 +886,2 @@ if (this.isRealNode(cur.left)) queue.push(cur.left); | ||
} | ||
/** | ||
* The function compares two values using a comparator function and returns whether the first value | ||
* is greater than, less than, or equal to the second value. | ||
* @param {K} a - The parameter "a" is of type K. | ||
* @param {K} b - The parameter "b" in the above code represents a K. | ||
* @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater | ||
* than), 'LT' (less than), or 'EQ' (equal). | ||
*/ | ||
protected _compare(a: K, b: K): CP { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
const compared = this.variant === 'STANDARD' ? extractedA - extractedB : extractedB - extractedA; | ||
if (compared > 0) return 'GT'; | ||
if (compared < 0) return 'LT'; | ||
return 'EQ'; | ||
} | ||
/** | ||
* The function `_lt` compares two values `a` and `b` using an extractor function and returns true if | ||
* `a` is less than `b` based on the specified variant. | ||
* @param {K} a - The parameter "a" is of type "K", which means it can be any type. It represents the | ||
* first value to be compared in the function. | ||
* @param {K} b - The parameter `b` is of type `K`, which means it can be any type. It is used as one | ||
* of the arguments for the comparison in the `_lt` function. | ||
* @returns a boolean value. | ||
*/ | ||
protected _lt(a: K, b: K): boolean { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
return this.variant === 'STANDARD' ? extractedA < extractedB : extractedA > extractedB; | ||
} | ||
/** | ||
* The function compares two values using a custom extractor function and returns true if the first | ||
* value is greater than the second value. | ||
* @param {K} a - The parameter "a" is of type K, which means it can be any type. | ||
* @param {K} b - The parameter "b" is of type K, which means it can be any type. It is used as one | ||
* of the arguments for the comparison in the function. | ||
* @returns a boolean value. | ||
*/ | ||
protected _gt(a: K, b: K): boolean { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
return this.variant === 'STANDARD' ? extractedA > extractedB : extractedA < extractedB; | ||
} | ||
} |
import type { | ||
BinaryTreeDeleteResult, | ||
BTNCallback, | ||
Comparable, | ||
CRUD, | ||
KeyOrNodeOrEntry, | ||
RBTNColor, | ||
RBTreeOptions, | ||
@@ -9,3 +12,2 @@ RedBlackTreeNested, | ||
} from '../../types'; | ||
import { CP, CRUD, RBTNColor } from '../../types'; | ||
import { BST, BSTNode } from './bst'; | ||
@@ -15,3 +17,3 @@ import { IBinaryTree } from '../../interfaces'; | ||
export class RedBlackTreeNode< | ||
K = any, | ||
K extends Comparable, | ||
V = any, | ||
@@ -56,3 +58,3 @@ NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V> | ||
export class RedBlackTree< | ||
K = any, | ||
K extends Comparable, | ||
V = any, | ||
@@ -369,5 +371,6 @@ NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, | ||
parent = current; | ||
if (node.key < current.key) { | ||
const compared = this.comparator(node.key, current.key); | ||
if (compared < 0) { | ||
current = current.left ?? this.NIL; | ||
} else if (node.key > current.key) { | ||
} else if (compared > 0) { | ||
current = current.right ?? this.NIL; | ||
@@ -663,19 +666,2 @@ } else { | ||
} | ||
/** | ||
* The function compares two values using a comparator function and returns whether the first value | ||
* is greater than, less than, or equal to the second value. | ||
* @param {K} a - The parameter "a" is of type K. | ||
* @param {K} b - The parameter "b" in the above code represents a K. | ||
* @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater | ||
* than), 'LT' (less than), or 'EQ' (equal). | ||
*/ | ||
protected override _compare(a: K, b: K): CP { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
const compared = extractedA - extractedB; | ||
if (compared > 0) return 'GT'; | ||
if (compared < 0) return 'LT'; | ||
return 'EQ'; | ||
} | ||
} |
@@ -12,4 +12,6 @@ /** | ||
BTNCallback, | ||
Comparable, | ||
IterationType, | ||
KeyOrNodeOrEntry, | ||
RBTNColor, | ||
TreeMultiMapNested, | ||
@@ -19,3 +21,2 @@ TreeMultiMapNodeNested, | ||
} from '../../types'; | ||
import { RBTNColor } from '../../types'; | ||
import { IBinaryTree } from '../../interfaces'; | ||
@@ -25,3 +26,3 @@ import { RedBlackTree, RedBlackTreeNode } from './rb-tree'; | ||
export class TreeMultiMapNode< | ||
K = any, | ||
K extends Comparable, | ||
V = any, | ||
@@ -68,3 +69,3 @@ NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V> | ||
export class TreeMultiMap< | ||
K = any, | ||
K extends Comparable, | ||
V = any, | ||
@@ -71,0 +72,0 @@ NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, |
@@ -96,3 +96,3 @@ /** | ||
*/ | ||
static heapify<E>(elements: Iterable<E>, options: { comparator: Comparator<E> }): Heap<E> { | ||
static heapify<E>(elements: Iterable<E>, options: HeapOptions<E>): Heap<E> { | ||
return new Heap<E>(elements, options); | ||
@@ -99,0 +99,0 @@ } |
import { BinaryTree, BinaryTreeNode } from '../data-structures'; | ||
import { | ||
import type { | ||
BinaryTreeDeleteResult, | ||
@@ -8,2 +8,3 @@ BinaryTreeNested, | ||
BTNCallback, | ||
Comparable, | ||
KeyOrNodeOrEntry | ||
@@ -13,3 +14,3 @@ } from '../types'; | ||
export interface IBinaryTree< | ||
K = number, | ||
K extends Comparable, | ||
V = any, | ||
@@ -21,3 +22,3 @@ N extends BinaryTreeNode<K, V, N> = BinaryTreeNodeNested<K, V>, | ||
createTree(options?: Partial<BinaryTreeOptions<K>>): TREE; | ||
createTree(options?: Partial<BinaryTreeOptions>): TREE; | ||
@@ -24,0 +25,0 @@ add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, value?: V, count?: number): boolean; |
export type BSTVariant = 'STANDARD' | 'INVERSE'; | ||
export type CP = 'LT' | 'EQ' | 'GT'; | ||
export type CP = 1 | -1 | 0; | ||
@@ -4,0 +4,0 @@ /** |
import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures'; | ||
import type { AVLTreeOptions } from './avl-tree'; | ||
import { Comparable } from "../../utils"; | ||
export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type AVLTreeMultiMapNodeNested<K extends Comparable, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type AVLTreeMultiMapNested<K, V, N extends AVLTreeMultiMapNode<K, V, N>> = AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type AVLTreeMultiMapNested<K extends Comparable, V, N extends AVLTreeMultiMapNode<K, V, N>> = AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type AVLTreeMultiMapOptions<K> = AVLTreeOptions<K> & {} |
import { AVLTree, AVLTreeNode } from '../../../data-structures'; | ||
import { BSTOptions } from './bst'; | ||
import { Comparable } from "../../utils"; | ||
export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type AVLTreeNodeNested<K extends Comparable, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type AVLTreeNested<K, V, N extends AVLTreeNode<K, V, N>> = AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type AVLTreeNested<K extends Comparable, V, N extends AVLTreeNode<K, V, N>> = AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type AVLTreeOptions<K> = BSTOptions<K> & {}; |
import { BinaryTree, BinaryTreeNode } from '../../../data-structures'; | ||
import { IterationType } from "../../common"; | ||
import { Comparable } from "../../utils"; | ||
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 BinaryTreeNodeNested<K extends Comparable, 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 BinaryTreeNested<K, V, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type BinaryTreeNested<K extends Comparable, V, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type BinaryTreeOptions<K> = { | ||
iterationType?: IterationType, | ||
extractor?: (key: K) => number | ||
export type BinaryTreeOptions = { | ||
iterationType?: IterationType | ||
} |
import { BST, BSTNode } from '../../../data-structures'; | ||
import type { BinaryTreeOptions } from './binary-tree'; | ||
import { BSTVariant } from "../../common"; | ||
import { Comparator } from "../../common"; | ||
import { Comparable } from "../../utils"; | ||
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type BSTNodeNested<K extends Comparable, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type BSTNested<K, V, N extends BSTNode<K, V, N>> = BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type BSTNested<K extends Comparable, V, N extends BSTNode<K, V, N>> = BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type BSTOptions<K> = BinaryTreeOptions<K> & { | ||
variant?: BSTVariant | ||
export type BSTOptions<K> = BinaryTreeOptions & { | ||
comparator?: Comparator<K> | ||
} |
import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures'; | ||
import type { BSTOptions } from "./bst"; | ||
import { Comparable } from "../../utils"; | ||
export type RBTNColor = 'RED' | 'BLACK'; | ||
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type RedBlackTreeNodeNested<K extends Comparable, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type RedBlackTreeNested<K, V, N extends RedBlackTreeNode<K, V, N>> = RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type RedBlackTreeNested<K extends Comparable, V, N extends RedBlackTreeNode<K, V, N>> = RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type RBTreeOptions<K> = Omit<BSTOptions<K>, 'variant'> & {}; | ||
export type RBTreeOptions<K> = BSTOptions<K> & {}; |
import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures'; | ||
import type { RBTreeOptions } from './rb-tree'; | ||
import { Comparable } from "../../utils"; | ||
export type TreeMultiMapNodeNested<K, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type TreeMultiMapNodeNested<K extends Comparable, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type TreeMultiMapNested<K, V, N extends TreeMultiMapNode<K, V, N>> = TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type TreeMultiMapNested<K extends Comparable, V, N extends TreeMultiMapNode<K, V, N>> = TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, TreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | ||
export type TreeMultiMapOptions<K> = RBTreeOptions<K> & {} |
@@ -8,2 +8,15 @@ export type ToThunkFn = () => ReturnType<TrlFn>; | ||
export type Any = string | number | boolean | object | null | undefined | symbol; | ||
export type Any = string | number | bigint | boolean | symbol | undefined | object; | ||
export type Comparable = | ||
| number | ||
| string | ||
| bigint | ||
| boolean | ||
| ({ [key in string]: any } & { | ||
valueOf(): Comparable; | ||
}) | ||
| ({ [key in string]: any } & { | ||
toString(): Comparable; | ||
}) | ||
| (() => Comparable); |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import type { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types'; | ||
import type { Comparable, Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types'; | ||
@@ -109,1 +109,20 @@ export const uuidV4 = function () { | ||
}; | ||
export function isComparable(key: any): key is Comparable { | ||
const keyType = typeof key; | ||
if (keyType === 'number') return isNaN(key); | ||
if (keyType === 'string') return true; | ||
if (keyType === 'bigint') return true; | ||
if (keyType === 'boolean') return true; | ||
if (keyType === 'symbol') return false; | ||
if (keyType === 'undefined') return false; | ||
if (keyType === 'function') return isComparable(key()); | ||
if (keyType === 'object') { | ||
if (key === null) return true; | ||
if (typeof key.valueOf === 'function') return isComparable(key.valueOf()); | ||
if (typeof key.toString === 'function') return isComparable(key.toString()); | ||
return false; | ||
} | ||
return false; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2084025
39634
Updateddata-structure-typed@^1.51.8