🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

graph-typed

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graph-typed - npm Package Compare versions

Comparing version

to
1.54.0

@@ -8,3 +8,3 @@ /**

*/
import type { AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, IterationType } from '../../types';
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, IterationType } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -24,14 +24,2 @@ import { AVLTree, AVLTreeNode } from './avl-tree';

constructor(key: K, value?: V, count?: number);
protected _count: number;
/**
* The function returns the value of the protected variable _count.
* @returns The count property of the object, which is of type number.
*/
get count(): number;
/**
* The above function sets the value of the count property.
* @param {number} value - The value parameter is of type number, which means it can accept any
* numeric value.
*/
set count(value: number);
}

@@ -41,3 +29,3 @@ /**

*/
export declare class AVLTreeMultiMap<K = any, V = any, R = object, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>> extends AVLTree<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
export declare class AVLTreeMultiMap<K = any, V = any, R = object, MK = any, MV = any, MR = object, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>, TREE extends AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, TREE> = AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, AVLTreeMultiMapNested<K, V, R, MK, MV, MR, NODE>>> extends AVLTree<K, V, R, MK, MV, MR, NODE, TREE> implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE> {
/**

@@ -87,3 +75,3 @@ * The constructor initializes a new AVLTreeMultiMap object with optional initial elements.

*/
createTree(options?: AVLTreeMultiMapOptions<K, V, R>): AVLTreeMultiMap<K, V, R, NODE>;
createTree(options?: AVLTreeMultiMapOptions<K, V, R>): TREE;
/**

@@ -163,3 +151,3 @@ * The function checks if the input is an instance of AVLTreeMultiMapNode.

*/
clone(): AVLTreeMultiMap<K, V, R, NODE>;
clone(): TREE;
/**

@@ -183,3 +171,3 @@ * The `map` function in TypeScript overrides the default behavior to create a new AVLTreeMultiMap

*/
map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeMultiMapOptions<MK, MV, MR>, thisArg?: any): AVLTreeMultiMap<MK, MV, MR, AVLTreeMultiMapNode<MK, MV, AVLTreeMultiMapNodeNested<MK, MV>>>;
map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeMultiMapOptions<MK, MV, MR>, thisArg?: any): AVLTreeMultiMap<MK, MV, MR>;
/**

@@ -186,0 +174,0 @@ * The function `keyValueNodeEntryRawToNodeAndValue` converts a key, value, entry, or raw element into

@@ -18,20 +18,4 @@ "use strict";

super(key, value);
this._count = 1;
this.count = count;
}
/**
* The function returns the value of the protected variable _count.
* @returns The count property of the object, which is of type number.
*/
get count() {
return this._count;
}
/**
* The above function sets the value of the count property.
* @param {number} value - The value parameter is of type number, which means it can accept any
* numeric value.
*/
set count(value) {
this._count = value;
}
}

@@ -99,3 +83,2 @@ exports.AVLTreeMultiMapNode = AVLTreeMultiMapNode;

*/
// @ts-ignore
createTree(options) {

@@ -178,3 +161,3 @@ return new AVLTreeMultiMap([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn, isReverse: this._isReverse }, options));

if (!parent) {
if (curr.right !== undefined)
if (curr.right !== undefined && curr.right !== null)
this._setRoot(curr.right);

@@ -292,3 +275,2 @@ }

*/
// @ts-ignore
clone() {

@@ -322,3 +304,2 @@ const cloned = this.createTree();

*/
// @ts-ignore
map(callback, options, thisArg) {

@@ -325,0 +306,0 @@ const newTree = new AVLTreeMultiMap([], options);

@@ -9,3 +9,3 @@ /**

import { BST, BSTNode } from './bst';
import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback } from '../../types';
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -22,14 +22,2 @@ export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {

constructor(key: K, value?: V);
protected _height: number;
/**
* The function returns the value of the height property.
* @returns The height of the object.
*/
get height(): number;
/**
* The above function sets the value of the height property.
* @param {number} value - The value parameter is a number that represents the new height value to be
* set.
*/
set height(value: number);
}

@@ -45,3 +33,3 @@ /**

*/
export declare class AVLTree<K = any, V = any, R = object, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>> extends BST<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
export declare class AVLTree<K = any, V = any, R = object, MK = any, MV = any, MR = object, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, R, MK, MV, MR, NODE, TREE> = AVLTree<K, V, R, MK, MV, MR, NODE, AVLTreeNested<K, V, R, MK, MV, MR, NODE>>> extends BST<K, V, R, MK, MV, MR, NODE, TREE> implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE> {
/**

@@ -70,12 +58,9 @@ * This is a constructor function for an AVLTree class that initializes the tree with keys, nodes,

/**
* The function `createTree` in TypeScript overrides the default AVLTree creation with the provided
* options.
* @param [options] - The `options` parameter in the `createTree` function is an object that contains
* configuration options for creating an AVL tree. These options can include properties such as
* `iterationType`, `isMapMode`, `specifyComparable`, `toEntryFn`, and `isReverse`. The function
* creates a
* @returns An AVLTree object is being returned with the specified options and properties inherited
* from the current object.
* The function creates a new AVL tree with the specified options and returns it.
* @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
* passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
* being created.
* @returns a new AVLTree object.
*/
createTree(options?: AVLTreeOptions<K, V, R>): AVLTree<K, V, R, NODE>;
createTree(options?: AVLTreeOptions<K, V, R>): TREE;
/**

@@ -117,3 +102,3 @@ * The function checks if the input is an instance of AVLTreeNode.

delete(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): BinaryTreeDeleteResult<NODE>[];
map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeOptions<MK, MV, MR>, thisArg?: any): AVLTree<MK, MV, MR, AVLTreeNode<MK, MV, AVLTreeNodeNested<MK, MV>>>;
map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: AVLTreeOptions<MK, MV, MR>, thisArg?: any): AVLTree<MK, MV, MR>;
/**

@@ -120,0 +105,0 @@ * Time Complexity: O(1)

@@ -23,19 +23,3 @@ "use strict";

super(key, value);
this._height = 0;
}
/**
* The function returns the value of the height property.
* @returns The height of the object.
*/
get height() {
return this._height;
}
/**
* The above function sets the value of the height property.
* @param {number} value - The value parameter is a number that represents the new height value to be
* set.
*/
set height(value) {
this._height = value;
}
}

@@ -82,12 +66,8 @@ exports.AVLTreeNode = AVLTreeNode;

/**
* The function `createTree` in TypeScript overrides the default AVLTree creation with the provided
* options.
* @param [options] - The `options` parameter in the `createTree` function is an object that contains
* configuration options for creating an AVL tree. These options can include properties such as
* `iterationType`, `isMapMode`, `specifyComparable`, `toEntryFn`, and `isReverse`. The function
* creates a
* @returns An AVLTree object is being returned with the specified options and properties inherited
* from the current object.
* The function creates a new AVL tree with the specified options and returns it.
* @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
* passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
* being created.
* @returns a new AVLTree object.
*/
// @ts-ignore
createTree(options) {

@@ -149,3 +129,2 @@ return new AVLTree([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn, isReverse: this._isReverse }, options));

}
// @ts-ignore
map(callback, options, thisArg) {

@@ -243,3 +222,4 @@ const newTree = new AVLTree([], options);

const B = A.left;
A.parent = B;
if (B !== null)
A.parent = B;
if (B && B.right) {

@@ -285,9 +265,10 @@ B.right.parent = A;

}
if (A)
if (A && C !== null)
A.parent = C;
if (B)
if (B && C !== null)
B.parent = C;
if (C) {
if (C.left) {
C.left.parent = B;
if (B !== null)
C.left.parent = B;
}

@@ -336,3 +317,4 @@ if (C.right) {

const B = A.right;
A.parent = B;
if (B !== null)
A.parent = B;
if (B) {

@@ -380,4 +362,5 @@ if (B.left) {

}
A.parent = C;
if (B)
if (C !== null)
A.parent = C;
if (B && C !== null)
B.parent = C;

@@ -389,3 +372,4 @@ if (C) {

if (C.right) {
C.right.parent = B;
if (B !== null)
C.right.parent = B;
}

@@ -392,0 +376,0 @@ C.parent = parentOfA;

@@ -8,3 +8,3 @@ /**

*/
import { BinaryTreeDeleteResult, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNEntry, BTNRep, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodeDisplayLayout, NodePredicate, OptNodeOrNull, ToEntryFn } from '../../types';
import { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNEntry, BTNRep, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodeDisplayLayout, NodePredicate, OptNodeOrNull, type RBTNColor, ToEntryFn } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -23,8 +23,17 @@ import { IterableEntryBase } from '../base';

constructor(key: K, value?: V);
protected _left?: OptNodeOrNull<NODE>;
_left?: OptNodeOrNull<NODE>;
get left(): OptNodeOrNull<NODE>;
set left(v: OptNodeOrNull<NODE>);
protected _right?: OptNodeOrNull<NODE>;
_right?: OptNodeOrNull<NODE>;
get right(): OptNodeOrNull<NODE>;
set right(v: OptNodeOrNull<NODE>);
_height: number;
get height(): number;
set height(value: number);
_color: RBTNColor;
get color(): RBTNColor;
set color(value: RBTNColor);
_count: number;
get count(): number;
set count(value: number);
get familyPosition(): FamilyPosition;

@@ -39,3 +48,3 @@ }

*/
export declare class BinaryTree<K = any, V = any, R = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, R, NODE> {
export declare class BinaryTree<K = any, V = any, R = object, MK = any, MV = any, MR = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, R, MK, MV, MR, NODE, TREE> = BinaryTree<K, V, R, MK, MV, MR, NODE, BinaryTreeNested<K, V, R, MK, MV, MR, NODE>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE> {
iterationType: IterationType;

@@ -78,17 +87,27 @@ /**

/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*
* The `createTree` function creates a new binary tree based on the provided options.
* @param [options] - The `options` parameter in the `createTree` method is of type
* `BinaryTreeOptions<K, V, R>`. This type likely contains configuration options for creating a
* binary tree, such as the iteration type, whether the tree is in map mode, and functions for
* converting entries.
* @returns The `createTree` method is returning an instance of the `BinaryTree` class with the
* provided options. The method is creating a new `BinaryTree` object with an empty array as the
* initial data, and then setting various options such as `iterationType`, `isMapMode`, and
* `toEntryFn` based on the current object's properties and the provided `options`. Finally, it
* The function creates a binary tree with the specified options.
* @param [options] - The `options` parameter in the `createTree` function is an optional parameter
* that allows you to provide partial configuration options for creating a binary tree. It is of type
* `Partial<BinaryTreeOptions<K, V, R>>`, which means you can pass in an object containing a subset
* of properties
* @returns A new instance of a binary tree with the specified options is being returned.
*/
createTree(options?: BinaryTreeOptions<K, V, R>): typeof this;
createTree(options?: BinaryTreeOptions<K, V, R>): TREE;
/**
* The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
* or returns null.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
* `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeEntryOrRaw`, which
* can be of type `BTNRep<K, V, NODE>` or `R`. This parameter represents either a key, a
* node, an entry
* @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
* an optional parameter of type `V`. It represents the value associated with the key in the node
* being created. If a `value` is provided, it will be used when creating the node. If
* @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
* (`OptNodeOrNull<NODE>`) based on the input parameters provided. The function checks the type of the
* input parameter (`keyNodeEntryOrRaw`) and processes it accordingly to return a node or null
* value.
*/
protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): [OptNodeOrNull<NODE>, V | undefined];
/**
* Time Complexity: O(n)

@@ -238,3 +257,3 @@ * Space Complexity: O(log n)

*/
merge(anotherTree: this): void;
merge(anotherTree: BinaryTree<K, V, R, NODE, TREE>): void;
/**

@@ -639,3 +658,3 @@ * Time Complexity: O(k * n)

*/
clone(): this;
clone(): TREE;
/**

@@ -657,3 +676,3 @@ * Time Complexity: O(n)

*/
filter(predicate: EntryCallback<K, V | undefined, boolean>, thisArg?: any): this;
filter(predicate: EntryCallback<K, V | undefined, boolean>, thisArg?: any): TREE;
/**

@@ -678,3 +697,3 @@ * Time Complexity: O(n)

*/
map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: BinaryTreeOptions<MK, MV, MR>, thisArg?: any): BinaryTree<MK, MV, MR, BinaryTreeNode<MK, MV, BinaryTreeNodeNested<MK, MV>>>;
map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: BinaryTreeOptions<MK, MV, MR>, thisArg?: any): BinaryTree<MK, MV, MR>;
/**

@@ -716,18 +735,2 @@ * Time Complexity: O(n)

/**
* The function `keyValueNodeEntryRawToNodeAndValue` converts various input types into a node object
* or returns null.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
* `keyValueNodeEntryRawToNodeAndValue` function takes in a parameter `keyNodeEntryOrRaw`, which
* can be of type `BTNRep<K, V, NODE>` or `R`. This parameter represents either a key, a
* node, an entry
* @param {V} [value] - The `value` parameter in the `keyValueNodeEntryRawToNodeAndValue` function is
* an optional parameter of type `V`. It represents the value associated with the key in the node
* being created. If a `value` is provided, it will be used when creating the node. If
* @returns The `keyValueNodeEntryRawToNodeAndValue` function returns an optional node
* (`OptNodeOrNull<NODE>`) based on the input parameters provided. The function checks the type of the
* input parameter (`keyNodeEntryOrRaw`) and processes it accordingly to return a node or null
* value.
*/
protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): [OptNodeOrNull<NODE>, V | undefined];
/**
* Time complexity: O(n)

@@ -734,0 +737,0 @@ * Space complexity: O(n)

@@ -8,3 +8,3 @@ /**

*/
import { BSTNodeNested, BSTNOptKeyOrNode, BSTOptions, BTNRep, Comparable, Comparator, CP, DFSOrderPattern, EntryCallback, IterationType, NodeCallback, NodePredicate, OptNode } from '../../types';
import { BSTNested, BSTNodeNested, BSTNOptKeyOrNode, BSTOptions, BTNRep, Comparable, Comparator, CP, DFSOrderPattern, EntryCallback, IterationType, NodeCallback, NodePredicate, OptNode, OptNodeOrNull } from '../../types';
import { BinaryTree, BinaryTreeNode } from './binary-tree';

@@ -16,3 +16,3 @@ import { IBinaryTree } from '../../interfaces';

constructor(key: K, value?: V);
protected _left?: NODE;
_left?: OptNodeOrNull<NODE>;
/**

@@ -22,3 +22,3 @@ * The function returns the value of the `_left` property.

*/
get left(): OptNode<NODE>;
get left(): OptNodeOrNull<NODE>;
/**

@@ -29,4 +29,4 @@ * The function sets the left child of a node and updates the parent reference of the child.

*/
set left(v: OptNode<NODE>);
protected _right?: NODE;
set left(v: OptNodeOrNull<NODE>);
_right?: OptNodeOrNull<NODE>;
/**

@@ -37,3 +37,3 @@ * The function returns the right node of a binary tree or undefined if there is no right node.

*/
get right(): OptNode<NODE>;
get right(): OptNodeOrNull<NODE>;
/**

@@ -44,3 +44,3 @@ * The function sets the right child of a node and updates the parent reference of the child.

*/
set right(v: OptNode<NODE>);
set right(v: OptNodeOrNull<NODE>);
}

@@ -112,3 +112,3 @@ /**

*/
export declare class BST<K = any, V = any, R = object, NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>> extends BinaryTree<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
export declare class BST<K = any, V = any, R = object, MK = any, MV = any, MR = object, NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>, TREE extends BST<K, V, R, MK, MV, MR, NODE, TREE> = BST<K, V, R, MK, MV, MR, NODE, BSTNested<K, V, R, MK, MV, MR, NODE>>> extends BinaryTree<K, V, R, MK, MV, MR, NODE, TREE> implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE> {
/**

@@ -136,16 +136,3 @@ * This is the constructor function for a Binary Search Tree class in TypeScript.

get isReverse(): boolean;
protected _comparator: Comparator<K>;
/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator(): Comparator<K>;
protected _specifyComparable?: (key: K) => Comparable;
/**
* This function returns the value of the `_specifyComparable` property.
* @returns The method `specifyComparable()` is being returned, which is a getter method for the
* `_specifyComparable` property.
*/
get specifyComparable(): ((key: K) => Comparable) | undefined;
/**
* The function creates a new BSTNode with the given key and value and returns it.

@@ -160,14 +147,20 @@ * @param {K} key - The key parameter is of type K, which represents the type of the key for the node

/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*
* The `createTree` function in TypeScript overrides the default options with the provided options to
* create a new Binary Search Tree.
* @param [options] - The `options` parameter in the `createTree` method is an optional object that
* can contain the following properties:
* @returns A new instance of a Binary Search Tree (BST) is being returned with the specified options
* and properties inherited from the current instance.
* The function creates a new binary search tree with the specified options.
* @param [options] - The `options` parameter is an optional object that allows you to customize the
* behavior of the `createTree` method. It accepts a partial `BSTOptions` object, which has the
* following properties:
* @returns a new instance of the BST class with the provided options.
*/
createTree(options?: BSTOptions<K, V, R>): BST<K, V, R, BSTNode<K, V, BSTNodeNested<K, V>>>;
createTree(options?: BSTOptions<K, V, R>): TREE;
/**
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
* type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
* element.
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
* value associated with a key in a key-value pair.
* @returns either a NODE object or undefined.
*/
protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): [OptNode<NODE>, V | undefined];
/**
* Time Complexity: O(log n)

@@ -240,12 +233,2 @@ * Space Complexity: O(log n)

/**
* Time Complexity: O(n)
* Space Complexity: O(1)
*
* The `merge` function overrides the base class method by adding elements from another
* binary search tree.
* @param anotherTree - `anotherTree` is an instance of a Binary Search Tree (BST) with key type `K`,
* value type `V`, return type `R`, node type `NODE`, and tree type `TREE`.
*/
merge(anotherTree: this): void;
/**
* Time Complexity: O(log n)

@@ -428,14 +411,16 @@ * Space Complexity: O(k + log n)

isAVLBalanced(iterationType?: IterationType): boolean;
map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: BSTOptions<MK, MV, MR>, thisArg?: any): BST<MK, MV, MR, BSTNode<MK, MV, BSTNodeNested<MK, MV>>>;
protected _comparator: Comparator<K>;
/**
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
* type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
* element.
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
* value associated with a key in a key-value pair.
* @returns either a NODE object or undefined.
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): [OptNode<NODE>, V | undefined];
get comparator(): Comparator<K>;
protected _specifyComparable?: (key: K) => Comparable;
/**
* This function returns the value of the `_specifyComparable` property.
* @returns The method `specifyComparable()` is being returned, which is a getter method for the
* `_specifyComparable` property.
*/
get specifyComparable(): ((key: K) => Comparable) | undefined;
/**
* The function sets the root of a tree-like structure and updates the parent property of the new

@@ -447,2 +432,3 @@ * root.

protected _compare(a: K, b: K): number;
map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: BSTOptions<MK, MV, MR>, thisArg?: any): BST<MK, MV, MR>;
}

@@ -178,17 +178,2 @@ "use strict";

/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator() {
return this._comparator;
}
/**
* This function returns the value of the `_specifyComparable` property.
* @returns The method `specifyComparable()` is being returned, which is a getter method for the
* `_specifyComparable` property.
*/
get specifyComparable() {
return this._specifyComparable;
}
/**
* The function creates a new BSTNode with the given key and value and returns it.

@@ -205,13 +190,8 @@ * @param {K} key - The key parameter is of type K, which represents the type of the key for the node

/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*
* The `createTree` function in TypeScript overrides the default options with the provided options to
* create a new Binary Search Tree.
* @param [options] - The `options` parameter in the `createTree` method is an optional object that
* can contain the following properties:
* @returns A new instance of a Binary Search Tree (BST) is being returned with the specified options
* and properties inherited from the current instance.
* The function creates a new binary search tree with the specified options.
* @param [options] - The `options` parameter is an optional object that allows you to customize the
* behavior of the `createTree` method. It accepts a partial `BSTOptions` object, which has the
* following properties:
* @returns a new instance of the BST class with the provided options.
*/
// @ts-ignore
createTree(options) {

@@ -221,2 +201,17 @@ return new BST([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn, isReverse: this._isReverse }, options));

/**
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
* type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
* element.
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
* value associated with a key in a key-value pair.
* @returns either a NODE object or undefined.
*/
_keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
const [node, entryValue] = super._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
if (node === null)
return [undefined, undefined];
return [node, value !== null && value !== void 0 ? value : entryValue];
}
/**
* Time Complexity: O(log n)

@@ -299,3 +294,4 @@ * Space Complexity: O(log n)

}
current = current.left;
if (current.left !== null)
current = current.left;
}

@@ -310,3 +306,4 @@ else {

}
current = current.right;
if (current.right !== null)
current = current.right;
}

@@ -419,14 +416,2 @@ }

/**
* Time Complexity: O(n)
* Space Complexity: O(1)
*
* The `merge` function overrides the base class method by adding elements from another
* binary search tree.
* @param anotherTree - `anotherTree` is an instance of a Binary Search Tree (BST) with key type `K`,
* value type `V`, return type `R`, node type `NODE`, and tree type `TREE`.
*/
merge(anotherTree) {
this.addMany(anotherTree, [], false);
}
/**
* Time Complexity: O(log n)

@@ -831,3 +816,4 @@ * Space Complexity: O(k + log n)

stack.push(node);
node = node.left;
if (node.left !== null)
node = node.left;
}

@@ -855,25 +841,16 @@ else {

}
// @ts-ignore
map(callback, options, thisArg) {
const newTree = new BST([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator() {
return this._comparator;
}
/**
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
* type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
* element.
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
* value associated with a key in a key-value pair.
* @returns either a NODE object or undefined.
* This function returns the value of the `_specifyComparable` property.
* @returns The method `specifyComparable()` is being returned, which is a getter method for the
* `_specifyComparable` property.
*/
_keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value) {
const [node, entryValue] = super._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
if (node === null)
return [undefined, undefined];
return [node, value !== null && value !== void 0 ? value : entryValue];
get specifyComparable() {
return this._specifyComparable;
}

@@ -894,3 +871,11 @@ /**

}
map(callback, options, thisArg) {
const newTree = new BST([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
}
exports.BST = BST;

@@ -1,2 +0,2 @@

import type { BinaryTreeDeleteResult, BTNRep, CRUD, EntryCallback, RBTNColor, RedBlackTreeOptions, RedBlackTreeNodeNested } from '../../types';
import type { BinaryTreeDeleteResult, BTNRep, CRUD, EntryCallback, RBTNColor, RedBlackTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
import { BST, BSTNode } from './bst';

@@ -17,13 +17,2 @@ import { IBinaryTree } from '../../interfaces';

constructor(key: K, value?: V, color?: RBTNColor);
protected _color: RBTNColor;
/**
* The function returns the color value of a variable.
* @returns The color value stored in the private variable `_color`.
*/
get color(): RBTNColor;
/**
* The function sets the color property to the specified value.
* @param {RBTNColor} value - The value parameter is of type RBTNColor.
*/
set color(value: RBTNColor);
}

@@ -83,3 +72,3 @@ /**

*/
export declare class RedBlackTree<K = any, V = any, R = object, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>> extends BST<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
export declare class RedBlackTree<K = any, V = any, R = object, MK = any, MV = any, MR = object, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, TREE extends RedBlackTree<K, V, R, MK, MV, MR, NODE, TREE> = RedBlackTree<K, V, R, MK, MV, MR, NODE, RedBlackTreeNested<K, V, R, MK, MV, MR, NODE>>> extends BST<K, V, R, MK, MV, MR, NODE, TREE> implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE> {
/**

@@ -89,3 +78,3 @@ * This is the constructor function for a Red-Black Tree data structure in TypeScript.

* iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
* initialize the RedBlackTree with the provided elements.
* initialize the RBTree with the provided elements.
* @param [options] - The `options` parameter is an optional object that can be passed to the

@@ -119,11 +108,8 @@ * constructor. It is of type `RedBlackTreeOptions<K, V, R>`. This object can contain various options for

/**
* The function `createTree` overrides the default implementation to create a Red-Black Tree with
* specified options in TypeScript.
* @param [options] - The `options` parameter in the `createTree` method is of type `RedBlackTreeOptions<K,
* V, R>`, which is a generic type with three type parameters `K`, `V`, and `R`. This parameter
* allows you to pass additional configuration options when creating a new Red-
* @returns A new instance of a RedBlackTree with the specified options and properties from the
* current object is being returned.
* The function creates a new Red-Black Tree with the specified options.
* @param [options] - The `options` parameter is an optional object that contains additional
* configuration options for creating the Red-Black Tree. It has the following properties:
* @returns a new instance of a RedBlackTree object.
*/
createTree(options?: RedBlackTreeOptions<K, V, R>): RedBlackTree<K, V, R, RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>>;
createTree(options?: RedBlackTreeOptions<K, V, R>): TREE;
/**

@@ -180,23 +166,2 @@ * Time Complexity: O(1)

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
* applying a callback to each entry in the original tree.
* @param callback - A function that will be called for each entry in the tree, with parameters
* representing the key, value, index, and the tree itself. It should return an entry for the new
* tree.
* @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
* MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
* Tree that will be created during the mapping process. These options could include things like
* custom comparators
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function. This can be useful when you want to access properties
* or
* @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
* provided callback function.
*/
map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: RedBlackTreeOptions<MK, MV, MR>, thisArg?: any): RedBlackTree<MK, MV, MR, RedBlackTreeNode<MK, MV, RedBlackTreeNodeNested<MK, MV>>>;
/**
* Time Complexity: O(1)

@@ -287,2 +252,23 @@ * Space Complexity: O(1)

protected _rightRotate(y: NODE | undefined): void;
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
* applying a callback to each entry in the original tree.
* @param callback - A function that will be called for each entry in the tree, with parameters
* representing the key, value, index, and the tree itself. It should return an entry for the new
* tree.
* @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
* MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
* Tree that will be created during the mapping process. These options could include things like
* custom comparators
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function. This can be useful when you want to access properties
* or
* @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
* provided callback function.
*/
map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: RedBlackTreeOptions<MK, MV, MR>, thisArg?: any): RedBlackTree<MK, MV, MR>;
}

@@ -21,16 +21,2 @@ "use strict";

}
/**
* The function returns the color value of a variable.
* @returns The color value stored in the private variable `_color`.
*/
get color() {
return this._color;
}
/**
* The function sets the color property to the specified value.
* @param {RBTNColor} value - The value parameter is of type RBTNColor.
*/
set color(value) {
this._color = value;
}
}

@@ -96,3 +82,3 @@ exports.RedBlackTreeNode = RedBlackTreeNode;

* iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
* initialize the RedBlackTree with the provided elements.
* initialize the RBTree with the provided elements.
* @param [options] - The `options` parameter is an optional object that can be passed to the

@@ -135,11 +121,7 @@ * constructor. It is of type `RedBlackTreeOptions<K, V, R>`. This object can contain various options for

/**
* The function `createTree` overrides the default implementation to create a Red-Black Tree with
* specified options in TypeScript.
* @param [options] - The `options` parameter in the `createTree` method is of type `RedBlackTreeOptions<K,
* V, R>`, which is a generic type with three type parameters `K`, `V`, and `R`. This parameter
* allows you to pass additional configuration options when creating a new Red-
* @returns A new instance of a RedBlackTree with the specified options and properties from the
* current object is being returned.
* The function creates a new Red-Black Tree with the specified options.
* @param [options] - The `options` parameter is an optional object that contains additional
* configuration options for creating the Red-Black Tree. It has the following properties:
* @returns a new instance of a RedBlackTree object.
*/
// @ts-ignore
createTree(options) {

@@ -241,4 +223,6 @@ return new RedBlackTree([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn }, options));

if (!this.isRealNode(nodeToDelete.left)) {
replacementNode = nodeToDelete.right;
this._transplant(nodeToDelete, nodeToDelete.right);
if (nodeToDelete.right !== null) {
replacementNode = nodeToDelete.right;
this._transplant(nodeToDelete, nodeToDelete.right);
}
}

@@ -253,3 +237,4 @@ else if (!this.isRealNode(nodeToDelete.right)) {

originalColor = successor.color;
replacementNode = successor.right;
if (successor.right !== null)
replacementNode = successor.right;
if (successor.parent === nodeToDelete) {

@@ -261,4 +246,6 @@ if (this.isRealNode(replacementNode)) {

else {
this._transplant(successor, successor.right);
successor.right = nodeToDelete.right;
if (successor.right !== null) {
this._transplant(successor, successor.right);
successor.right = nodeToDelete.right;
}
if (this.isRealNode(successor.right)) {

@@ -287,31 +274,2 @@ successor.right.parent = successor;

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
* applying a callback to each entry in the original tree.
* @param callback - A function that will be called for each entry in the tree, with parameters
* representing the key, value, index, and the tree itself. It should return an entry for the new
* tree.
* @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
* MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
* Tree that will be created during the mapping process. These options could include things like
* custom comparators
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function. This can be useful when you want to access properties
* or
* @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
* provided callback function.
*/
// @ts-ignore
map(callback, options, thisArg) {
const newTree = new RedBlackTree([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
/**
* Time Complexity: O(1)

@@ -424,3 +382,3 @@ * Space Complexity: O(1)

_insertFixup(z) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e;
// Continue fixing the tree as long as the parent of z is red

@@ -459,3 +417,3 @@ while (((_a = z === null || z === void 0 ? void 0 : z.parent) === null || _a === void 0 ? void 0 : _a.color) === 'RED') {

// Follow the same logic as above with left and right exchanged
const y = (_d = (_c = z === null || z === void 0 ? void 0 : z.parent) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.left;
const y = (_e = (_d = (_c = z === null || z === void 0 ? void 0 : z.parent) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.left) !== null && _e !== void 0 ? _e : undefined;
if ((y === null || y === void 0 ? void 0 : y.color) === 'RED') {

@@ -633,3 +591,31 @@ z.parent.color = 'BLACK';

}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
* applying a callback to each entry in the original tree.
* @param callback - A function that will be called for each entry in the tree, with parameters
* representing the key, value, index, and the tree itself. It should return an entry for the new
* tree.
* @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
* MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
* Tree that will be created during the mapping process. These options could include things like
* custom comparators
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function. This can be useful when you want to access properties
* or
* @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
* provided callback function.
*/
map(callback, options, thisArg) {
const newTree = new RedBlackTree([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
}
exports.RedBlackTree = RedBlackTree;

@@ -8,3 +8,3 @@ /**

*/
import type { BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, IterationType, RBTNColor, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
import type { BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, IterationType, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -26,16 +26,4 @@ import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';

constructor(key: K, value?: V, count?: number, color?: RBTNColor);
protected _count: number;
/**
* The function returns the value of the private variable _count.
* @returns The count property of the object, which is of type number.
*/
get count(): number;
/**
* The above function sets the value of the count property.
* @param {number} value - The value parameter is of type number, which means it can accept any
* numeric value.
*/
set count(value: number);
}
export declare class TreeMultiMap<K = any, V = any, R = object, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>> extends RedBlackTree<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
export declare class TreeMultiMap<K = any, V = any, R = object, MK = any, MV = any, MR = object, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, TREE extends TreeMultiMap<K, V, R, MK, MV, MR, NODE, TREE> = TreeMultiMap<K, V, R, MK, MV, MR, NODE, TreeMultiMapNested<K, V, R, MK, MV, MR, NODE>>> extends RedBlackTree<K, V, R, MK, MV, MR, NODE, TREE> implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE> {
/**

@@ -88,4 +76,17 @@ * The constructor function initializes a TreeMultiMap object with optional initial data.

*/
createTree(options?: TreeMultiMapOptions<K, V, R>): TreeMultiMap<K, V, R, NODE>;
createTree(options?: TreeMultiMapOptions<K, V, R>): TREE;
/**
* The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
* node based on the input.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
* `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
* @param {V} [value] - The `value` parameter is an optional value that represents the value
* associated with the key in the node. It is used when creating a new node or updating the value of
* an existing node.
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
* @returns either a NODE object or undefined.
*/
protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): [NODE | undefined, V | undefined];
/**
* The function checks if the input is an instance of the TreeMultiMapNode class.

@@ -160,33 +161,4 @@ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter

*/
clone(): TreeMultiMap<K, V, R, NODE>;
clone(): TREE;
/**
* The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
* modified entries based on a provided callback.
* @param callback - The `callback` parameter is a function that will be called for each entry in the
* map. It takes four arguments:
* @param [options] - The `options` parameter in the `override map` function is of type
* `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
* options when creating a new `TreeMultiMap` instance within the `map` function. These options could
* include things like
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function when it is called within the `map` function. This
* @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
* by the provided callback function.
*/
map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: TreeMultiMapOptions<MK, MV, MR>, thisArg?: any): TreeMultiMap<MK, MV, MR, TreeMultiMapNode<MK, MV, TreeMultiMapNodeNested<MK, MV>>>;
/**
* The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
* node based on the input.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
* `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
* @param {V} [value] - The `value` parameter is an optional value that represents the value
* associated with the key in the node. It is used when creating a new node or updating the value of
* an existing node.
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
* @returns either a NODE object or undefined.
*/
protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): [NODE | undefined, V | undefined];
/**
* Time Complexity: O(1)

@@ -218,2 +190,18 @@ * Space Complexity: O(1)

protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
/**
* The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
* modified entries based on a provided callback.
* @param callback - The `callback` parameter is a function that will be called for each entry in the
* map. It takes four arguments:
* @param [options] - The `options` parameter in the `override map` function is of type
* `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
* options when creating a new `TreeMultiMap` instance within the `map` function. These options could
* include things like
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function when it is called within the `map` function. This
* @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
* by the provided callback function.
*/
map(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: TreeMultiMapOptions<MK, MV, MR>, thisArg?: any): TreeMultiMap<MK, MV, MR>;
}

@@ -20,20 +20,4 @@ "use strict";

super(key, value, color);
this._count = 1;
this.count = count;
}
/**
* The function returns the value of the private variable _count.
* @returns The count property of the object, which is of type number.
*/
get count() {
return this._count;
}
/**
* The above function sets the value of the count property.
* @param {number} value - The value parameter is of type number, which means it can accept any
* numeric value.
*/
set count(value) {
this._count = value;
}
}

@@ -102,3 +86,2 @@ exports.TreeMultiMapNode = TreeMultiMapNode;

*/
// @ts-ignore
createTree(options) {

@@ -108,2 +91,37 @@ return new TreeMultiMap([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn }, options));

/**
* The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
* node based on the input.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
* `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
* @param {V} [value] - The `value` parameter is an optional value that represents the value
* associated with the key in the node. It is used when creating a new node or updating the value of
* an existing node.
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
* @returns either a NODE object or undefined.
*/
_keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null)
return [undefined, undefined];
if (this.isNode(keyNodeEntryOrRaw))
return [keyNodeEntryOrRaw, value];
if (this.isEntry(keyNodeEntryOrRaw)) {
const [key, entryValue] = keyNodeEntryOrRaw;
if (key === undefined || key === null)
return [undefined, undefined];
const finalValue = value !== null && value !== void 0 ? value : entryValue;
if (this.isKey(key))
return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
}
if (this.isRaw(keyNodeEntryOrRaw)) {
const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
const finalValue = value !== null && value !== void 0 ? value : entryValue;
if (this.isKey(key))
return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
}
if (this.isKey(keyNodeEntryOrRaw))
return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
return [undefined, undefined];
}
/**
* The function checks if the input is an instance of the TreeMultiMapNode class.

@@ -176,6 +194,9 @@ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter

if (!this.isRealNode(nodeToDelete.left)) {
replacementNode = nodeToDelete.right;
if (nodeToDelete.right !== null)
replacementNode = nodeToDelete.right;
if (ignoreCount || nodeToDelete.count <= 1) {
this._transplant(nodeToDelete, nodeToDelete.right);
this._count -= nodeToDelete.count;
if (nodeToDelete.right !== null) {
this._transplant(nodeToDelete, nodeToDelete.right);
this._count -= nodeToDelete.count;
}
}

@@ -206,3 +227,4 @@ else {

originalColor = successor.color;
replacementNode = successor.right;
if (successor.right !== null)
replacementNode = successor.right;
if (successor.parent === nodeToDelete) {

@@ -215,4 +237,6 @@ if (this.isRealNode(replacementNode)) {

if (ignoreCount || nodeToDelete.count <= 1) {
this._transplant(successor, successor.right);
this._count -= nodeToDelete.count;
if (successor.right !== null) {
this._transplant(successor, successor.right);
this._count -= nodeToDelete.count;
}
}

@@ -328,3 +352,2 @@ else {

*/
// @ts-ignore
clone() {

@@ -338,61 +361,2 @@ const cloned = this.createTree();

/**
* The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
* modified entries based on a provided callback.
* @param callback - The `callback` parameter is a function that will be called for each entry in the
* map. It takes four arguments:
* @param [options] - The `options` parameter in the `override map` function is of type
* `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
* options when creating a new `TreeMultiMap` instance within the `map` function. These options could
* include things like
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function when it is called within the `map` function. This
* @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
* by the provided callback function.
*/
// @ts-ignore
map(callback, options, thisArg) {
const newTree = new TreeMultiMap([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
/**
* The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
* node based on the input.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
* `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
* @param {V} [value] - The `value` parameter is an optional value that represents the value
* associated with the key in the node. It is used when creating a new node or updating the value of
* an existing node.
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
* @returns either a NODE object or undefined.
*/
_keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null)
return [undefined, undefined];
if (this.isNode(keyNodeEntryOrRaw))
return [keyNodeEntryOrRaw, value];
if (this.isEntry(keyNodeEntryOrRaw)) {
const [key, entryValue] = keyNodeEntryOrRaw;
if (key === undefined || key === null)
return [undefined, undefined];
const finalValue = value !== null && value !== void 0 ? value : entryValue;
if (this.isKey(key))
return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
}
if (this.isRaw(keyNodeEntryOrRaw)) {
const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
const finalValue = value !== null && value !== void 0 ? value : entryValue;
if (this.isKey(key))
return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
}
if (this.isKey(keyNodeEntryOrRaw))
return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
return [undefined, undefined];
}
/**
* Time Complexity: O(1)

@@ -449,3 +413,26 @@ * Space Complexity: O(1)

}
/**
* The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
* modified entries based on a provided callback.
* @param callback - The `callback` parameter is a function that will be called for each entry in the
* map. It takes four arguments:
* @param [options] - The `options` parameter in the `override map` function is of type
* `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
* options when creating a new `TreeMultiMap` instance within the `map` function. These options could
* include things like
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function when it is called within the `map` function. This
* @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
* by the provided callback function.
*/
map(callback, options, thisArg) {
const newTree = new TreeMultiMap([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
}
exports.TreeMultiMap = TreeMultiMap;

@@ -1,5 +0,6 @@

import { BinaryTreeNode } from '../data-structures';
import type { BinaryTreeDeleteResult, BinaryTreeNodeNested, BTNRep, NodePredicate } from '../types';
export interface IBinaryTree<K = any, V = any, R = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>> {
import { BinaryTree, BinaryTreeNode } from '../data-structures';
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNRep, NodePredicate } from '../types';
export interface IBinaryTree<K = any, V = any, R = object, MK = any, MV = any, MR = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, MK, MV, MR, NODE, TREE> = BinaryTreeNested<K, V, R, MK, MV, MR, NODE>> {
createNode(key: K, value?: NODE['value']): NODE;
createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, NODE>, value?: V, count?: number): boolean;

@@ -6,0 +7,0 @@ addMany(nodes: Iterable<BTNRep<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];

@@ -1,4 +0,5 @@

import { AVLTreeMultiMapNode } from '../../../data-structures';
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, any>>>>>>>>>>;
export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>;
export type AVLTreeMultiMapNested<K, V, R, MK, MV, MR, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, any>>>;
export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};

@@ -1,4 +0,5 @@

import { AVLTreeNode } from '../../../data-structures';
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, any>>>>>>>>>>;
export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>;
export type AVLTreeNested<K, V, R, MK, MV, MR, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R, MK, MV, MR, NODE, AVLTree<K, V, R, MK, MV, MR, NODE, AVLTree<K, V, R, MK, MV, MR, NODE, any>>>;
export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};

@@ -1,5 +0,6 @@

import { BinaryTreeNode } from '../../../data-structures';
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
import { IterationType, OptValue } from '../../common';
import { DFSOperation } 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, any>>>>>>>>>>;
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>;
export type BinaryTreeNested<K, V, R, MK, MV, MR, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, MK, MV, MR, NODE, BinaryTree<K, V, R, MK, MV, MR, NODE, BinaryTree<K, V, R, MK, MV, MR, NODE, any>>>;
export type ToEntryFn<K, V, R> = (rawElement: R) => BTNEntry<K, V>;

@@ -6,0 +7,0 @@ export type BinaryTreeOptions<K, V, R> = {

@@ -1,5 +0,6 @@

import { BSTNode } from '../../../data-structures';
import { BST, BSTNode } from '../../../data-structures';
import type { BinaryTreeOptions } from './binary-tree';
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, any>>>>>>>>>>;
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>;
export type BSTNested<K, V, R, MK, MV, MR, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, MK, MV, MR, NODE, BST<K, V, R, MK, MV, MR, NODE, BST<K, V, R, MK, MV, MR, NODE, any>>>;
export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {

@@ -6,0 +7,0 @@ specifyComparable?: (key: K) => Comparable;

@@ -1,5 +0,6 @@

import { RedBlackTreeNode } from '../../../data-structures';
import type { BSTOptions } from './bst';
import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
import type { BSTOptions } from "./bst";
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, any>>>>>>>>>>;
export type RedBlackTreeOptions<K, V, R> = Omit<BSTOptions<K, V, R>, 'isReverse'> & {};
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>;
export type RedBlackTreeNested<K, V, R, MK, MV, MR, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, MK, MV, MR, NODE, RedBlackTree<K, V, R, MK, MV, MR, NODE, RedBlackTree<K, V, R, MK, MV, MR, NODE, any>>>;
export type RedBlackTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};

@@ -1,4 +0,5 @@

import { TreeMultiMapNode } from '../../../data-structures';
import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures';
import type { RedBlackTreeOptions } 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, any>>>>>>>>>>;
export type TreeMultiMapNodeNested<K, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>;
export type TreeMultiMapNested<K, V, R, MK, MV, MR, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, MK, MV, MR, NODE, TreeMultiMap<K, V, R, MK, MV, MR, NODE, TreeMultiMap<K, V, R, MK, MV, MR, NODE, any>>>;
export type TreeMultiMapOptions<K, V, R> = RedBlackTreeOptions<K, V, R> & {};
{
"name": "graph-typed",
"version": "1.53.9",
"version": "1.54.0",
"description": "Graph. Javascript & Typescript Data Structure.",

@@ -139,4 +139,4 @@ "main": "dist/index.js",

"dependencies": {
"data-structure-typed": "^1.53.9"
"data-structure-typed": "^1.54.0"
}
}

@@ -9,2 +9,3 @@ /**

import type {
AVLTreeMultiMapNested,
AVLTreeMultiMapNodeNested,

@@ -40,21 +41,2 @@ AVLTreeMultiMapOptions,

}
protected _count: number = 1;
/**
* The function returns the value of the protected variable _count.
* @returns The count property of the object, which is of type number.
*/
get count(): number {
return this._count;
}
/**
* The above function sets the value of the count property.
* @param {number} value - The value parameter is of type number, which means it can accept any
* numeric value.
*/
set count(value: number) {
this._count = value;
}
}

@@ -69,6 +51,19 @@

R = object,
NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>
MK = any,
MV = any,
MR = object,
NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>,
TREE extends AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, TREE> = AVLTreeMultiMap<
K,
V,
R,
MK,
MV,
MR,
NODE,
AVLTreeMultiMapNested<K, V, R, MK, MV, MR, NODE>
>
>
extends AVLTree<K, V, R, NODE>
implements IBinaryTree<K, V, R, NODE>
extends AVLTree<K, V, R, MK, MV, MR, NODE, TREE>
implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE>
{

@@ -138,5 +133,4 @@ /**

*/
// @ts-ignore
override createTree(options?: AVLTreeMultiMapOptions<K, V, R>) {
return new AVLTreeMultiMap<K, V, R, NODE>([], {
override createTree(options?: AVLTreeMultiMapOptions<K, V, R>): TREE {
return new AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, TREE>([], {
iterationType: this.iterationType,

@@ -148,3 +142,3 @@ isMapMode: this._isMapMode,

...options
});
}) as TREE;
}

@@ -228,3 +222,3 @@

if (!parent) {
if (curr.right !== undefined) this._setRoot(curr.right);
if (curr.right !== undefined && curr.right !== null) this._setRoot(curr.right);
} else {

@@ -339,4 +333,3 @@ const { familyPosition: fp } = curr;

*/
// @ts-ignore
override clone() {
override clone(): TREE {
const cloned = this.createTree();

@@ -367,3 +360,2 @@ if (this._isMapMode) this.bfs(node => cloned.add(node.key, undefined, node.count));

*/
// @ts-ignore
override map<MK, MV, MR>(

@@ -373,3 +365,3 @@ callback: EntryCallback<K, V | undefined, [MK, MV]>,

thisArg?: any
) {
): AVLTreeMultiMap<MK, MV, MR> {
const newTree = new AVLTreeMultiMap<MK, MV, MR>([], options);

@@ -376,0 +368,0 @@ let index = 0;

@@ -10,2 +10,3 @@ /**

import type {
AVLTreeNested,
AVLTreeNodeNested,

@@ -35,23 +36,3 @@ AVLTreeOptions,

super(key, value);
this._height = 0;
}
protected _height: number;
/**
* The function returns the value of the height property.
* @returns The height of the object.
*/
get height(): number {
return this._height;
}
/**
* The above function sets the value of the height property.
* @param {number} value - The value parameter is a number that represents the new height value to be
* set.
*/
set height(value: number) {
this._height = value;
}
}

@@ -72,6 +53,19 @@

R = object,
NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>
MK = any,
MV = any,
MR = object,
NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>,
TREE extends AVLTree<K, V, R, MK, MV, MR, NODE, TREE> = AVLTree<
K,
V,
R,
MK,
MV,
MR,
NODE,
AVLTreeNested<K, V, R, MK, MV, MR, NODE>
>
>
extends BST<K, V, R, NODE>
implements IBinaryTree<K, V, R, NODE>
extends BST<K, V, R, MK, MV, MR, NODE, TREE>
implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE>
{

@@ -108,14 +102,10 @@ /**

/**
* The function `createTree` in TypeScript overrides the default AVLTree creation with the provided
* options.
* @param [options] - The `options` parameter in the `createTree` function is an object that contains
* configuration options for creating an AVL tree. These options can include properties such as
* `iterationType`, `isMapMode`, `specifyComparable`, `toEntryFn`, and `isReverse`. The function
* creates a
* @returns An AVLTree object is being returned with the specified options and properties inherited
* from the current object.
* The function creates a new AVL tree with the specified options and returns it.
* @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be
* passed to the `createTree` function. It is used to customize the behavior of the AVL tree that is
* being created.
* @returns a new AVLTree object.
*/
// @ts-ignore
override createTree(options?: AVLTreeOptions<K, V, R>) {
return new AVLTree<K, V, R, NODE>([], {
override createTree(options?: AVLTreeOptions<K, V, R>): TREE {
return new AVLTree<K, V, R, MK, MV, MR, NODE, TREE>([], {
iterationType: this.iterationType,

@@ -127,3 +117,3 @@ isMapMode: this._isMapMode,

...options
});
}) as TREE;
}

@@ -185,8 +175,7 @@

// @ts-ignore
override map<MK, MV, MR>(
override map(
callback: EntryCallback<K, V | undefined, [MK, MV]>,
options?: AVLTreeOptions<MK, MV, MR>,
thisArg?: any
) {
): AVLTree<MK, MV, MR> {
const newTree = new AVLTree<MK, MV, MR>([], options);

@@ -288,3 +277,3 @@ let index = 0;

const B = A.left;
A.parent = B;
if (B !== null) A.parent = B;
if (B && B.right) {

@@ -326,8 +315,8 @@ B.right.parent = A;

}
if (A) A.parent = C;
if (B) B.parent = C;
if (A && C !== null) A.parent = C;
if (B && C !== null) B.parent = C;
if (C) {
if (C.left) {
C.left.parent = B;
if (B !== null) C.left.parent = B;
}

@@ -374,3 +363,3 @@ if (C.right) {

const B = A.right;
A.parent = B;
if (B !== null) A.parent = B;
if (B) {

@@ -418,4 +407,4 @@ if (B.left) {

A.parent = C;
if (B) B.parent = C;
if (C !== null) A.parent = C;
if (B && C !== null) B.parent = C;

@@ -427,3 +416,3 @@ if (C) {

if (C.right) {
C.right.parent = B;
if (B !== null) C.right.parent = B;
}

@@ -430,0 +419,0 @@ C.parent = parentOfA;

@@ -9,2 +9,3 @@ /**

import {
BSTNested,
BSTNodeNested,

@@ -22,3 +23,4 @@ BSTNOptKeyOrNode,

NodePredicate,
OptNode
OptNode,
OptNodeOrNull
} from '../../types';

@@ -45,3 +47,3 @@ import { BinaryTree, BinaryTreeNode } from './binary-tree';

protected override _left?: NODE;
override _left?: OptNodeOrNull<NODE>;

@@ -52,3 +54,3 @@ /**

*/
override get left(): OptNode<NODE> {
override get left(): OptNodeOrNull<NODE> {
return this._left;

@@ -62,3 +64,3 @@ }

*/
override set left(v: OptNode<NODE>) {
override set left(v: OptNodeOrNull<NODE>) {
if (v) {

@@ -70,3 +72,3 @@ v.parent = this as unknown as NODE;

protected override _right?: NODE;
override _right?: OptNodeOrNull<NODE>;

@@ -78,3 +80,3 @@ /**

*/
override get right(): OptNode<NODE> {
override get right(): OptNodeOrNull<NODE> {
return this._right;

@@ -88,3 +90,3 @@ }

*/
override set right(v: OptNode<NODE>) {
override set right(v: OptNodeOrNull<NODE>) {
if (v) {

@@ -162,5 +164,23 @@ v.parent = this as unknown as NODE;

*/
export class BST<K = any, V = any, R = object, NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>>
extends BinaryTree<K, V, R, NODE>
implements IBinaryTree<K, V, R, NODE>
export class BST<
K = any,
V = any,
R = object,
MK = any,
MV = any,
MR = object,
NODE extends BSTNode<K, V, NODE> = BSTNode<K, V, BSTNodeNested<K, V>>,
TREE extends BST<K, V, R, MK, MV, MR, NODE, TREE> = BST<
K,
V,
R,
MK,
MV,
MR,
NODE,
BSTNested<K, V, R, MK, MV, MR, NODE>
>
>
extends BinaryTree<K, V, R, MK, MV, MR, NODE, TREE>
implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE>
{

@@ -208,42 +228,3 @@ /**

protected _comparator: Comparator<K> = (a: K, b: K): number => {
if (isComparable(a) && isComparable(b)) {
if (a > b) return 1;
if (a < b) return -1;
return 0;
}
if (this._specifyComparable) {
if (this._specifyComparable(a) > this._specifyComparable(b)) return 1;
if (this._specifyComparable(a) < this._specifyComparable(b)) return -1;
return 0;
}
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(
`When comparing object types, a custom specifyComparable must be defined in the constructor's options parameter.`
);
}
return 0;
};
/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator() {
return this._comparator;
}
protected _specifyComparable?: (key: K) => Comparable;
/**
* This function returns the value of the `_specifyComparable` property.
* @returns The method `specifyComparable()` is being returned, which is a getter method for the
* `_specifyComparable` property.
*/
get specifyComparable() {
return this._specifyComparable;
}
/**
* The function creates a new BSTNode with the given key and value and returns it.

@@ -261,15 +242,10 @@ * @param {K} key - The key parameter is of type K, which represents the type of the key for the node

/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*
* The `createTree` function in TypeScript overrides the default options with the provided options to
* create a new Binary Search Tree.
* @param [options] - The `options` parameter in the `createTree` method is an optional object that
* can contain the following properties:
* @returns A new instance of a Binary Search Tree (BST) is being returned with the specified options
* and properties inherited from the current instance.
* The function creates a new binary search tree with the specified options.
* @param [options] - The `options` parameter is an optional object that allows you to customize the
* behavior of the `createTree` method. It accepts a partial `BSTOptions` object, which has the
* following properties:
* @returns a new instance of the BST class with the provided options.
*/
// @ts-ignore
override createTree(options?: BSTOptions<K, V, R>) {
return new BST<K, V, R>([], {
override createTree(options?: BSTOptions<K, V, R>): TREE {
return new BST<K, V, R, MK, MV, MR, NODE, TREE>([], {
iterationType: this.iterationType,

@@ -281,6 +257,24 @@ isMapMode: this._isMapMode,

...options
});
}) as TREE;
}
/**
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
* type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
* element.
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
* value associated with a key in a key-value pair.
* @returns either a NODE object or undefined.
*/
protected override _keyValueNodeEntryRawToNodeAndValue(
keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R,
value?: V
): [OptNode<NODE>, V | undefined] {
const [node, entryValue] = super._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
if (node === null) return [undefined, undefined];
return [node, value ?? entryValue];
}
/**
* Time Complexity: O(log n)

@@ -365,3 +359,3 @@ * Space Complexity: O(log n)

}
current = current.left;
if (current.left !== null) current = current.left;
} else {

@@ -374,3 +368,3 @@ if (current.right === undefined) {

}
current = current.right;
if (current.right !== null) current = current.right;
}

@@ -501,15 +495,2 @@ }

/**
* Time Complexity: O(n)
* Space Complexity: O(1)
*
* The `merge` function overrides the base class method by adding elements from another
* binary search tree.
* @param anotherTree - `anotherTree` is an instance of a Binary Search Tree (BST) with key type `K`,
* value type `V`, return type `R`, node type `NODE`, and tree type `TREE`.
*/
override merge(anotherTree: this) {
this.addMany(anotherTree, [], false);
}
/**
* Time Complexity: O(log n)

@@ -924,3 +905,3 @@ * Space Complexity: O(k + log n)

if (iterationType === 'RECURSIVE') {
const _height = (cur: OptNode<NODE>): number => {
const _height = (cur: OptNodeOrNull<NODE>): number => {
if (!cur) return 0;

@@ -942,3 +923,3 @@ const leftHeight = _height(cur.left),

stack.push(node);
node = node.left;
if (node.left !== null) node = node.left;
} else {

@@ -964,32 +945,39 @@ node = stack[stack.length - 1];

// @ts-ignore
override map<MK, MV, MR>(
callback: EntryCallback<K, V | undefined, [MK, MV]>,
options?: BSTOptions<MK, MV, MR>,
thisArg?: any
) {
const newTree = new BST<MK, MV, MR>([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
protected _comparator: Comparator<K> = (a: K, b: K): number => {
if (isComparable(a) && isComparable(b)) {
if (a > b) return 1;
if (a < b) return -1;
return 0;
}
return newTree;
if (this._specifyComparable) {
if (this._specifyComparable(a) > this._specifyComparable(b)) return 1;
if (this._specifyComparable(a) < this._specifyComparable(b)) return -1;
return 0;
}
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(
`When comparing object types, a custom specifyComparable must be defined in the constructor's options parameter.`
);
}
return 0;
};
/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator() {
return this._comparator;
}
protected _specifyComparable?: (key: K) => Comparable;
/**
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - A variable that can be of
* type R or BTNRep<K, V, NODE>. It represents either a key, a node, an entry, or a raw
* element.
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
* value associated with a key in a key-value pair.
* @returns either a NODE object or undefined.
* This function returns the value of the `_specifyComparable` property.
* @returns The method `specifyComparable()` is being returned, which is a getter method for the
* `_specifyComparable` property.
*/
protected override _keyValueNodeEntryRawToNodeAndValue(
keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R,
value?: V
): [OptNode<NODE>, V | undefined] {
const [node, entryValue] = super._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
if (node === null) return [undefined, undefined];
return [node, value ?? entryValue];
get specifyComparable() {
return this._specifyComparable;
}

@@ -1012,2 +1000,15 @@

}
override map(
callback: EntryCallback<K, V | undefined, [MK, MV]>,
options?: BSTOptions<MK, MV, MR>,
thisArg?: any
): BST<MK, MV, MR> {
const newTree = new BST<MK, MV, MR>([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
}

@@ -9,2 +9,3 @@ import type {

RedBlackTreeOptions,
RedBlackTreeNested,
RedBlackTreeNodeNested

@@ -35,20 +36,2 @@ } from '../../types';

}
protected _color: RBTNColor;
/**
* The function returns the color value of a variable.
* @returns The color value stored in the private variable `_color`.
*/
get color(): RBTNColor {
return this._color;
}
/**
* The function sets the color property to the specified value.
* @param {RBTNColor} value - The value parameter is of type RBTNColor.
*/
set color(value: RBTNColor) {
this._color = value;
}
}

@@ -113,6 +96,19 @@

R = object,
NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>
MK = any,
MV = any,
MR = object,
NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>,
TREE extends RedBlackTree<K, V, R, MK, MV, MR, NODE, TREE> = RedBlackTree<
K,
V,
R,
MK,
MV,
MR,
NODE,
RedBlackTreeNested<K, V, R, MK, MV, MR, NODE>
>
>
extends BST<K, V, R, NODE>
implements IBinaryTree<K, V, R, NODE>
extends BST<K, V, R, MK, MV, MR, NODE, TREE>
implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE>
{

@@ -123,3 +119,3 @@ /**

* iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
* initialize the RedBlackTree with the provided elements.
* initialize the RBTree with the provided elements.
* @param [options] - The `options` parameter is an optional object that can be passed to the

@@ -169,13 +165,9 @@ * constructor. It is of type `RedBlackTreeOptions<K, V, R>`. This object can contain various options for

/**
* The function `createTree` overrides the default implementation to create a Red-Black Tree with
* specified options in TypeScript.
* @param [options] - The `options` parameter in the `createTree` method is of type `RedBlackTreeOptions<K,
* V, R>`, which is a generic type with three type parameters `K`, `V`, and `R`. This parameter
* allows you to pass additional configuration options when creating a new Red-
* @returns A new instance of a RedBlackTree with the specified options and properties from the
* current object is being returned.
* The function creates a new Red-Black Tree with the specified options.
* @param [options] - The `options` parameter is an optional object that contains additional
* configuration options for creating the Red-Black Tree. It has the following properties:
* @returns a new instance of a RedBlackTree object.
*/
// @ts-ignore
override createTree(options?: RedBlackTreeOptions<K, V, R>) {
return new RedBlackTree<K, V, R>([], {
override createTree(options?: RedBlackTreeOptions<K, V, R>): TREE {
return new RedBlackTree<K, V, R, MK, MV, MR, NODE, TREE>([], {
iterationType: this.iterationType,

@@ -186,3 +178,3 @@ isMapMode: this._isMapMode,

...options
});
}) as TREE;
}

@@ -285,4 +277,6 @@

if (!this.isRealNode(nodeToDelete.left)) {
replacementNode = nodeToDelete.right;
this._transplant(nodeToDelete, nodeToDelete.right);
if (nodeToDelete.right !== null) {
replacementNode = nodeToDelete.right;
this._transplant(nodeToDelete, nodeToDelete.right);
}
} else if (!this.isRealNode(nodeToDelete.right)) {

@@ -295,3 +289,3 @@ replacementNode = nodeToDelete.left;

originalColor = successor.color;
replacementNode = successor.right;
if (successor.right !== null) replacementNode = successor.right;

@@ -303,4 +297,6 @@ if (successor.parent === nodeToDelete) {

} else {
this._transplant(successor, successor.right);
successor.right = nodeToDelete.right;
if (successor.right !== null) {
this._transplant(successor, successor.right);
successor.right = nodeToDelete.right;
}
if (this.isRealNode(successor.right)) {

@@ -333,36 +329,2 @@ successor.right.parent = successor;

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
* applying a callback to each entry in the original tree.
* @param callback - A function that will be called for each entry in the tree, with parameters
* representing the key, value, index, and the tree itself. It should return an entry for the new
* tree.
* @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
* MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
* Tree that will be created during the mapping process. These options could include things like
* custom comparators
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function. This can be useful when you want to access properties
* or
* @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
* provided callback function.
*/
// @ts-ignore
override map<MK, MV, MR>(
callback: EntryCallback<K, V | undefined, [MK, MV]>,
options?: RedBlackTreeOptions<MK, MV, MR>,
thisArg?: any
) {
const newTree = new RedBlackTree<MK, MV, MR>([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
/**
* Time Complexity: O(1)

@@ -511,3 +473,3 @@ * Space Complexity: O(1)

// Follow the same logic as above with left and right exchanged
const y: NODE | undefined = z?.parent?.parent?.left;
const y: NODE | undefined = z?.parent?.parent?.left ?? undefined;
if (y?.color === 'RED') {

@@ -689,2 +651,35 @@ z.parent.color = 'BLACK';

}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
* applying a callback to each entry in the original tree.
* @param callback - A function that will be called for each entry in the tree, with parameters
* representing the key, value, index, and the tree itself. It should return an entry for the new
* tree.
* @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
* MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
* Tree that will be created during the mapping process. These options could include things like
* custom comparators
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function. This can be useful when you want to access properties
* or
* @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
* provided callback function.
*/
override map(
callback: EntryCallback<K, V | undefined, [MK, MV]>,
options?: RedBlackTreeOptions<MK, MV, MR>,
thisArg?: any
): RedBlackTree<MK, MV, MR> {
const newTree = new RedBlackTree<MK, MV, MR>([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
}

@@ -16,2 +16,3 @@ /**

RBTNColor,
TreeMultiMapNested,
TreeMultiMapNodeNested,

@@ -44,21 +45,2 @@ TreeMultiMapOptions

}
protected _count: number = 1;
/**
* The function returns the value of the private variable _count.
* @returns The count property of the object, which is of type number.
*/
get count(): number {
return this._count;
}
/**
* The above function sets the value of the count property.
* @param {number} value - The value parameter is of type number, which means it can accept any
* numeric value.
*/
set count(value: number) {
this._count = value;
}
}

@@ -70,6 +52,19 @@

R = object,
NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>
MK = any,
MV = any,
MR = object,
NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>,
TREE extends TreeMultiMap<K, V, R, MK, MV, MR, NODE, TREE> = TreeMultiMap<
K,
V,
R,
MK,
MV,
MR,
NODE,
TreeMultiMapNested<K, V, R, MK, MV, MR, NODE>
>
>
extends RedBlackTree<K, V, R, NODE>
implements IBinaryTree<K, V, R, NODE>
extends RedBlackTree<K, V, R, MK, MV, MR, NODE, TREE>
implements IBinaryTree<K, V, R, MK, MV, MR, NODE, TREE>
{

@@ -140,5 +135,4 @@ /**

*/
// @ts-ignore
override createTree(options?: TreeMultiMapOptions<K, V, R>) {
return new TreeMultiMap<K, V, R, NODE>([], {
override createTree(options?: TreeMultiMapOptions<K, V, R>): TREE {
return new TreeMultiMap<K, V, R, MK, MV, MR, NODE, TREE>([], {
iterationType: this.iterationType,

@@ -149,6 +143,45 @@ isMapMode: this._isMapMode,

...options
});
}) as TREE;
}
/**
* The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
* node based on the input.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
* `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
* @param {V} [value] - The `value` parameter is an optional value that represents the value
* associated with the key in the node. It is used when creating a new node or updating the value of
* an existing node.
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
* @returns either a NODE object or undefined.
*/
protected override _keyValueNodeEntryRawToNodeAndValue(
keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R,
value?: V,
count = 1
): [NODE | undefined, V | undefined] {
if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null) return [undefined, undefined];
if (this.isNode(keyNodeEntryOrRaw)) return [keyNodeEntryOrRaw, value];
if (this.isEntry(keyNodeEntryOrRaw)) {
const [key, entryValue] = keyNodeEntryOrRaw;
if (key === undefined || key === null) return [undefined, undefined];
const finalValue = value ?? entryValue;
if (this.isKey(key)) return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
}
if (this.isRaw(keyNodeEntryOrRaw)) {
const [key, entryValue] = this._toEntryFn!(keyNodeEntryOrRaw);
const finalValue = value ?? entryValue;
if (this.isKey(key)) return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
}
if (this.isKey(keyNodeEntryOrRaw)) return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
return [undefined, undefined];
}
/**
* The function checks if the input is an instance of the TreeMultiMapNode class.

@@ -225,6 +258,8 @@ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter

if (!this.isRealNode(nodeToDelete.left)) {
replacementNode = nodeToDelete.right;
if (nodeToDelete.right !== null) replacementNode = nodeToDelete.right;
if (ignoreCount || nodeToDelete.count <= 1) {
this._transplant(nodeToDelete, nodeToDelete.right);
this._count -= nodeToDelete.count;
if (nodeToDelete.right !== null) {
this._transplant(nodeToDelete, nodeToDelete.right);
this._count -= nodeToDelete.count;
}
} else {

@@ -251,3 +286,3 @@ nodeToDelete.count--;

originalColor = successor.color;
replacementNode = successor.right;
if (successor.right !== null) replacementNode = successor.right;

@@ -260,4 +295,6 @@ if (successor.parent === nodeToDelete) {

if (ignoreCount || nodeToDelete.count <= 1) {
this._transplant(successor, successor.right);
this._count -= nodeToDelete.count;
if (successor.right !== null) {
this._transplant(successor, successor.right);
this._count -= nodeToDelete.count;
}
} else {

@@ -374,4 +411,3 @@ nodeToDelete.count--;

*/
// @ts-ignore
override clone() {
override clone(): TREE {
const cloned = this.createTree();

@@ -384,70 +420,2 @@ this.bfs(node => cloned.add(node.key, undefined, node.count));

/**
* The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
* modified entries based on a provided callback.
* @param callback - The `callback` parameter is a function that will be called for each entry in the
* map. It takes four arguments:
* @param [options] - The `options` parameter in the `override map` function is of type
* `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
* options when creating a new `TreeMultiMap` instance within the `map` function. These options could
* include things like
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function when it is called within the `map` function. This
* @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
* by the provided callback function.
*/
// @ts-ignore
override map<MK, MV, MR>(
callback: EntryCallback<K, V | undefined, [MK, MV]>,
options?: TreeMultiMapOptions<MK, MV, MR>,
thisArg?: any
) {
const newTree = new TreeMultiMap<MK, MV, MR>([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
/**
* The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
* node based on the input.
* @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
* `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
* @param {V} [value] - The `value` parameter is an optional value that represents the value
* associated with the key in the node. It is used when creating a new node or updating the value of
* an existing node.
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
* @returns either a NODE object or undefined.
*/
protected override _keyValueNodeEntryRawToNodeAndValue(
keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R,
value?: V,
count = 1
): [NODE | undefined, V | undefined] {
if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null) return [undefined, undefined];
if (this.isNode(keyNodeEntryOrRaw)) return [keyNodeEntryOrRaw, value];
if (this.isEntry(keyNodeEntryOrRaw)) {
const [key, entryValue] = keyNodeEntryOrRaw;
if (key === undefined || key === null) return [undefined, undefined];
const finalValue = value ?? entryValue;
if (this.isKey(key)) return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
}
if (this.isRaw(keyNodeEntryOrRaw)) {
const [key, entryValue] = this._toEntryFn!(keyNodeEntryOrRaw);
const finalValue = value ?? entryValue;
if (this.isKey(key)) return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
}
if (this.isKey(keyNodeEntryOrRaw)) return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
return [undefined, undefined];
}
/**
* Time Complexity: O(1)

@@ -509,2 +477,30 @@ * Space Complexity: O(1)

}
/**
* The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
* modified entries based on a provided callback.
* @param callback - The `callback` parameter is a function that will be called for each entry in the
* map. It takes four arguments:
* @param [options] - The `options` parameter in the `override map` function is of type
* `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
* options when creating a new `TreeMultiMap` instance within the `map` function. These options could
* include things like
* @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
* the value of `this` when executing the `callback` function. It allows you to set the context
* (value of `this`) for the callback function when it is called within the `map` function. This
* @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
* by the provided callback function.
*/
override map(
callback: EntryCallback<K, V | undefined, [MK, MV]>,
options?: TreeMultiMapOptions<MK, MV, MR>,
thisArg?: any
): TreeMultiMap<MK, MV, MR> {
const newTree = new TreeMultiMap<MK, MV, MR>([], options);
let index = 0;
for (const [key, value] of this) {
newTree.add(callback.call(thisArg, key, value, index++, this));
}
return newTree;
}
}

@@ -1,3 +0,10 @@

import { BinaryTreeNode } from '../data-structures';
import type { BinaryTreeDeleteResult, BinaryTreeNodeNested, BTNRep, NodePredicate } from '../types';
import { BinaryTree, BinaryTreeNode } from '../data-structures';
import type {
BinaryTreeDeleteResult,
BinaryTreeNested,
BinaryTreeNodeNested,
BinaryTreeOptions,
BTNRep,
NodePredicate
} from '../types';

@@ -8,6 +15,12 @@ export interface IBinaryTree<

R = object,
NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>
MK = any,
MV = any,
MR = object,
NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>,
TREE extends BinaryTree<K, V, R, MK, MV, MR, NODE, TREE> = BinaryTreeNested<K, V, R, MK, MV, MR, NODE>
> {
createNode(key: K, value?: NODE['value']): NODE;
createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, NODE>, value?: V, count?: number): boolean;

@@ -14,0 +27,0 @@

@@ -1,6 +0,8 @@

import { AVLTreeMultiMapNode } from '../../../data-structures';
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, any>>>>>>>>>>
export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>
export type AVLTreeMultiMapNested<K, V, R, MK, MV, MR, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, any>>>
export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {}

@@ -1,6 +0,8 @@

import { AVLTreeNode } from '../../../data-structures';
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, any>>>>>>>>>>
export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>
export type AVLTreeNested<K, V, R,MK, MV, MR, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R,MK, MV, MR, NODE, AVLTree<K, V, R,MK, MV, MR, NODE, AVLTree<K, V, R,MK, MV, MR, NODE, any>>>
export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};

@@ -1,8 +0,8 @@

import { BinaryTreeNode } from '../../../data-structures';
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
import { IterationType, OptValue } from '../../common';
import { DFSOperation } 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, any>>>>>>>>>>
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>
// export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type BinaryTreeNested<K, V, R, MK, MV, MR, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, MK, MV, MR, NODE,BinaryTree<K, V, R, MK, MV, MR, NODE,BinaryTree<K, V, R, MK, MV, MR, NODE,any>>>

@@ -9,0 +9,0 @@ export type ToEntryFn<K, V, R> = (rawElement: R) => BTNEntry<K, V>;

@@ -1,7 +0,9 @@

import { BSTNode } from '../../../data-structures';
import { BST, BSTNode } from '../../../data-structures';
import type { BinaryTreeOptions } from './binary-tree';
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, any>>>>>>>>>>
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>
export type BSTNested<K, V, R,MK, MV, MR, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R,MK, MV, MR, NODE,BST<K, V, R,MK, MV, MR, NODE,BST<K, V, R,MK, MV, MR, NODE, any>>>
export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {

@@ -8,0 +10,0 @@ specifyComparable?: (key: K) => Comparable

@@ -1,8 +0,10 @@

import { RedBlackTreeNode } from '../../../data-structures';
import type { BSTOptions } from './bst';
import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
import type { BSTOptions } from "./bst";
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, any>>>>>>>>>>
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>
export type RedBlackTreeOptions<K, V, R> = Omit<BSTOptions<K, V, R>, 'isReverse'> & {};
export type RedBlackTreeNested<K, V, R, MK, MV, MR, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, MK, MV, MR, NODE, RedBlackTree<K, V, R, MK, MV, MR, NODE, RedBlackTree<K, V, R, MK, MV, MR, NODE, any>>>
export type RedBlackTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};

@@ -1,6 +0,8 @@

import { TreeMultiMapNode } from '../../../data-structures';
import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures';
import type { RedBlackTreeOptions } 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, any>>>>>>>>>>
export type TreeMultiMapNodeNested<K, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>
export type TreeMultiMapNested<K, V, R, MK, MV, MR, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, MK, MV, MR, NODE, TreeMultiMap<K, V, R, MK, MV, MR, NODE,TreeMultiMap<K, V, R, MK, MV, MR, NODE, any>>>
export type TreeMultiMapOptions<K, V, R> = RedBlackTreeOptions<K, V, R> & {}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display