New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

red-black-tree-typed

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

red-black-tree-typed - npm Package Compare versions

Comparing version 1.49.0 to 1.49.1

22

dist/data-structures/binary-tree/avl-tree.d.ts

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

import { BST, BSTNode } from './bst';
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BiTreeDeleteResult, BSTNodeKeyOrNode, BTNodeExemplar } from '../../types';
import { BTNCallback, BTNodeKeyOrNode } from '../../types';
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNExemplar, BTNKeyOrNode } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -25,3 +24,2 @@ export declare class AVLTreeNode<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, N> {

* 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
* 8. Memory Overhead: Stores balance factors (or heights) at each node, leading to slightly higher memory usage compared to a regular BST.
*/

@@ -31,3 +29,3 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, N, TREE> = AVLTree<K, V, N, AVLTreeNested<K, V, N>>> extends BST<K, V, N, TREE> implements IBinaryTree<K, V, N, TREE> {

* The constructor function initializes an AVLTree object with optional elements and options.
* @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
* @param [elements] - The `elements` parameter is an optional iterable of `BTNExemplar<K, V, N>`
* objects. It represents a collection of elements that will be added to the AVL tree during

@@ -39,3 +37,3 @@ * initialization.

*/
constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<AVLTreeOptions<K>>);
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<AVLTreeOptions<K>>);
/**

@@ -61,6 +59,6 @@ * The function creates a new AVL tree node with the specified key and value.

* The function checks if an exemplar is an instance of AVLTreeNode.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the AVLTreeNode class.
*/
isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N;
isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N;
/**

@@ -72,3 +70,3 @@ * The function "isNotNodeInstance" checks if a potential key is a K.

*/
isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K;
isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K;
/**

@@ -90,3 +88,3 @@ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.

*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -109,5 +107,5 @@ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.

* parameter of type `N
* @returns The method is returning an array of `BiTreeDeleteResult<N>`.
* @returns The method is returning an array of `BinaryTreeDeleteResult<N>`.
*/
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C): BiTreeDeleteResult<N>[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C): BinaryTreeDeleteResult<N>[];
/**

@@ -123,3 +121,3 @@ * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a binary

*/
protected _swapProperties(srcNode: BSTNodeKeyOrNode<K, N>, destNode: BSTNodeKeyOrNode<K, N>): N | undefined;
protected _swapProperties(srcNode: BSTNKeyOrNode<K, N>, destNode: BSTNKeyOrNode<K, N>): N | undefined;
/**

@@ -126,0 +124,0 @@ * Time Complexity: O(1) - constant time, as it performs a fixed number of operations.

@@ -27,3 +27,2 @@ "use strict";

* 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
* 8. Memory Overhead: Stores balance factors (or heights) at each node, leading to slightly higher memory usage compared to a regular BST.
*/

@@ -33,3 +32,3 @@ class AVLTree extends bst_1.BST {

* The constructor function initializes an AVLTree object with optional elements and options.
* @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
* @param [elements] - The `elements` parameter is an optional iterable of `BTNExemplar<K, V, N>`
* objects. It represents a collection of elements that will be added to the AVL tree during

@@ -70,3 +69,3 @@ * initialization.

* The function checks if an exemplar is an instance of AVLTreeNode.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the AVLTreeNode class.

@@ -127,3 +126,3 @@ */

* parameter of type `N
* @returns The method is returning an array of `BiTreeDeleteResult<N>`.
* @returns The method is returning an array of `BinaryTreeDeleteResult<N>`.
*/

@@ -130,0 +129,0 @@ delete(identifier, callback = this._defaultOneParamCallback) {

@@ -8,4 +8,4 @@ /**

*/
import type { BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, BTNodeEntry, BTNodeExemplar, BTNodeKeyOrNode } from '../../types';
import { BinaryTreeNested, BinaryTreePrintOptions, BiTreeDeleteResult, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeDisplayLayout } from '../../types';
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNCallback, BTNEntry, BTNExemplar, BTNKeyOrNode, DFSOrderPattern, EntryCallback, NodeDisplayLayout } from '../../types';
import { FamilyPosition, IterationType } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -46,3 +46,3 @@ import { IterableEntryBase } from "../base";

* The constructor function initializes a binary tree object with optional elements and options.
* @param [elements] - An optional iterable of BTNodeExemplar objects. These objects represent the
* @param [elements] - An optional iterable of BTNExemplar objects. These objects represent the
* elements to be added to the binary tree.

@@ -54,3 +54,3 @@ * @param [options] - The `options` parameter is an optional object that can contain additional

*/
constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<BinaryTreeOptions<K>>);
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<BinaryTreeOptions<K>>);
protected _extractor: (key: K) => number;

@@ -79,9 +79,9 @@ get extractor(): (key: K) => number;

* The function "isNode" checks if an exemplar is an instance of the BinaryTreeNode class.
* @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<K, V,N>`.
* @param exemplar - The `exemplar` parameter is a variable of type `BTNExemplar<K, V,N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the class N.
*/
isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N;
isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N;
/**
* The function `exemplarToNode` converts an exemplar object into a node object.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the

@@ -92,10 +92,10 @@ * `exemplarToNode` function. It represents the value associated with the exemplar node. If no value

*/
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | null | undefined;
exemplarToNode(exemplar: BTNExemplar<K, V, N>, value?: V): N | null | undefined;
/**
* The function checks if a given value is an entry in a binary tree node.
* @param kne - BTNodeExemplar<K, V,N> - A generic type representing a node in a binary tree. It has
* @param kne - BTNExemplar<K, V,N> - A generic type representing a node in a binary tree. It has
* two type parameters V and N, representing the value and node type respectively.
* @returns a boolean value.
*/
isEntry(kne: BTNodeExemplar<K, V, N>): kne is BTNodeEntry<K, V>;
isEntry(kne: BTNExemplar<K, V, N>): kne is BTNEntry<K, V>;
/**

@@ -115,3 +115,3 @@ * Time Complexity O(log n) - O(n)

*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | null | undefined;
add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V): N | null | undefined;
/**

@@ -128,7 +128,7 @@ * Time Complexity: O(k log n) - O(k * n)

* adds each node with its corresponding value to the data structure.
* @param nodes - An iterable collection of BTNodeExemplar objects.
* @param nodes - An iterable collection of BTNExemplar objects.
* @param [values] - An optional iterable of values that will be assigned to each node being added.
* @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
*/
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>): (N | null | undefined)[];
addMany(nodes: Iterable<BTNExemplar<K, V, N>>, values?: Iterable<V | undefined>): (N | null | undefined)[];
/**

@@ -138,3 +138,3 @@ * Time Complexity: O(k * n) "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.

*/
refill(nodesOrKeysOrEntries: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>): void;
refill(nodesOrKeysOrEntries: Iterable<BTNExemplar<K, V, N>>, values?: Iterable<V | undefined>): void;
/**

@@ -144,5 +144,5 @@ * Time Complexity: O(k * n) "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.

*/
delete<C extends BTNCallback<N, K>>(identifier: K, callback?: C): BiTreeDeleteResult<N>[];
delete<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C): BiTreeDeleteResult<N>[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C): BiTreeDeleteResult<N>[];
delete<C extends BTNCallback<N, K>>(identifier: K, callback?: C): BinaryTreeDeleteResult<N>[];
delete<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C): BinaryTreeDeleteResult<N>[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C): BinaryTreeDeleteResult<N>[];
/**

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

*/
getDepth(distNode: BTNodeKeyOrNode<K, N>, beginRoot?: BTNodeKeyOrNode<K, N>): number;
getDepth(distNode: BTNKeyOrNode<K, N>, beginRoot?: BTNKeyOrNode<K, N>): number;
/**

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

*/
getHeight(beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): number;
getHeight(beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): number;
/**

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

*/
getMinHeight(beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): number;
getMinHeight(beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): number;
/**

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

*/
isPerfectlyBalanced(beginRoot?: BTNodeKeyOrNode<K, N>): boolean;
isPerfectlyBalanced(beginRoot?: BTNKeyOrNode<K, N>): boolean;
/**

@@ -229,5 +229,5 @@ * Time Complexity: O(n)

*/
getNodes<C extends BTNCallback<N, K>>(identifier: K, callback?: C, onlyOne?: boolean, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): N[];
getNodes<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, onlyOne?: boolean, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): N[];
getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, onlyOne?: boolean, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): N[];
getNodes<C extends BTNCallback<N, K>>(identifier: K, callback?: C, onlyOne?: boolean, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): N[];
getNodes<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, onlyOne?: boolean, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): N[];
getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, onlyOne?: boolean, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): N[];
/**

@@ -237,5 +237,5 @@ * Time Complexity: O(n)

*/
has<C extends BTNCallback<N, K>>(identifier: K, callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): boolean;
has<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): boolean;
has<C extends BTNCallback<N>>(identifier: ReturnType<C> | null | undefined, callback: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): boolean;
has<C extends BTNCallback<N, K>>(identifier: K, callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): boolean;
has<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): boolean;
has<C extends BTNCallback<N>>(identifier: ReturnType<C> | null | undefined, callback: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): boolean;
/**

@@ -245,5 +245,5 @@ * Time Complexity: O(n)

*/
getNode<C extends BTNCallback<N, K>>(identifier: K, callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
getNode<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
getNode<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
getNode<C extends BTNCallback<N, K>>(identifier: K, callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
getNode<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
getNode<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
/**

@@ -283,6 +283,6 @@ * Time Complexity: O(n)

*/
ensureNode(key: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
get<C extends BTNCallback<N, K>>(identifier: K, callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): V | undefined;
get<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): V | undefined;
get<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): V | undefined;
ensureNode(key: BTNKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
get<C extends BTNCallback<N, K>>(identifier: K, callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): V | undefined;
get<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): V | undefined;
get<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): V | undefined;
/**

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

*/
getPathToRoot(beginRoot: BTNodeKeyOrNode<K, N>, isReverse?: boolean): N[];
getPathToRoot(beginRoot: BTNKeyOrNode<K, N>, isReverse?: boolean): N[];
/**

@@ -335,3 +335,3 @@ * Time Complexity: O(log n)

*/
getLeftMost(beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
getLeftMost(beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
/**

@@ -356,3 +356,3 @@ * Time Complexity: O(log n)

*/
getRightMost(beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
getRightMost(beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType): N | null | undefined;
/**

@@ -374,3 +374,3 @@ * Time Complexity: O(log n)

*/
isSubtreeBST(beginRoot: BTNodeKeyOrNode<K, N>, iterationType?: IterationType): boolean;
isSubtreeBST(beginRoot: BTNKeyOrNode<K, N>, iterationType?: IterationType): boolean;
/**

@@ -396,5 +396,5 @@ * Time Complexity: O(n)

*/
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
subTreeTraverse<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
subTreeTraverse<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
/**

@@ -410,3 +410,3 @@ * Time complexity: O(n)

*/
isRealNode(node: BTNodeExemplar<K, V, N>): node is N;
isRealNode(node: BTNExemplar<K, V, N>): node is N;
/**

@@ -417,3 +417,3 @@ * The function checks if a given node is a BinaryTreeNode instance and has a key value of NaN.

*/
isNIL(node: BTNodeExemplar<K, V, N>): boolean;
isNIL(node: BTNExemplar<K, V, N>): boolean;
/**

@@ -424,3 +424,3 @@ * The function checks if a given node is a real node or null.

*/
isNodeOrNull(node: BTNodeExemplar<K, V, N>): node is N | null;
isNodeOrNull(node: BTNExemplar<K, V, N>): node is N | null;
/**

@@ -432,6 +432,6 @@ * The function "isNotNodeInstance" checks if a potential key is a K.

*/
isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K;
dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
dfs<C extends BTNCallback<N | null | undefined>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K;
dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
dfs<C extends BTNCallback<N | null | undefined>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
/**

@@ -441,5 +441,5 @@ * Time complexity: O(n)

*/
bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
bfs<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
bfs<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
/**

@@ -449,5 +449,5 @@ * Time complexity: O(n)

*/
listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[][];
listLevels<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: BTNodeKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[][];
listLevels<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: BTNKeyOrNode<K, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
/**

@@ -492,3 +492,3 @@ * Time Complexity: O(log n)

*/
morris<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNodeKeyOrNode<K, N>): ReturnType<C>[];
morris<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: BTNKeyOrNode<K, N>): ReturnType<C>[];
/**

@@ -554,3 +554,3 @@ * Time complexity: O(n)

*/
print(beginRoot?: BTNodeKeyOrNode<K, N>, options?: BinaryTreePrintOptions): void;
print(beginRoot?: BTNKeyOrNode<K, N>, options?: BinaryTreePrintOptions): void;
protected _getIterator(node?: N | null | undefined): IterableIterator<[K, V | undefined]>;

@@ -565,3 +565,3 @@ protected _displayAux(node: N | null | undefined, options: BinaryTreePrintOptions): NodeDisplayLayout;

*/
protected _swapProperties(srcNode: BTNodeKeyOrNode<K, N>, destNode: BTNodeKeyOrNode<K, N>): N | undefined;
protected _swapProperties(srcNode: BTNKeyOrNode<K, N>, destNode: BTNKeyOrNode<K, N>): N | undefined;
/**

@@ -587,3 +587,3 @@ * The function replaces an old node with a new node in a binary tree.

*/
protected _addTo(newNode: N | null | undefined, parent: BTNodeKeyOrNode<K, N>): N | null | undefined;
protected _addTo(newNode: N | null | undefined, parent: BTNKeyOrNode<K, N>): N | null | undefined;
/**

@@ -590,0 +590,0 @@ * The function sets the root property of an object to a given value, and if the value is not null,

@@ -8,4 +8,4 @@ /**

*/
import type { BSTNested, BSTNodeKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNodeExemplar } from '../../types';
import { BSTVariant, BTNodeKeyOrNode, CP, IterationType } from '../../types';
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNExemplar, BTNKeyOrNode } from '../../types';
import { BSTVariant, CP, IterationType } from '../../types';
import { BinaryTree, BinaryTreeNode } from './binary-tree';

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

* the tree with optional elements and options.
* @param [elements] - An optional iterable of BTNodeExemplar objects that will be added to the
* @param [elements] - An optional iterable of BTNExemplar objects that will be added to the
* binary search tree.

@@ -56,3 +56,3 @@ * @param [options] - The `options` parameter is an optional object that can contain additional

*/
constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<BSTOptions<K>>);
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<BSTOptions<K>>);
protected _root?: N;

@@ -81,10 +81,10 @@ get root(): N | undefined;

* The function checks if an exemplar is an instance of BSTNode.
* @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is a variable of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the BSTNode class.
*/
isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N;
isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N;
/**
* The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
* otherwise it returns undefined.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the

@@ -94,3 +94,3 @@ * `exemplarToNode` function. It represents the value associated with the exemplar node.

*/
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
exemplarToNode(exemplar: BTNExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -112,3 +112,3 @@ * Time Complexity: O(log n) - Average case for a balanced tree. In the worst case (unbalanced tree), it can be O(n).

*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -138,3 +138,3 @@ * Time Complexity: O(k log n) - Adding each element individually in a balanced tree.

*/
addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): (N | undefined)[];
addMany(keysOrNodesOrEntries: Iterable<BTNExemplar<K, V, N>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): (N | undefined)[];
/**

@@ -159,3 +159,3 @@ * Time Complexity: O(n log n) - Adding each element individually in a balanced tree.

*/
lastKey(beginRoot?: BSTNodeKeyOrNode<K, N>): K | undefined;
lastKey(beginRoot?: BSTNKeyOrNode<K, N>): K | undefined;
/**

@@ -186,3 +186,3 @@ * Time Complexity: O(log n) - Average case for a balanced tree.

*/
isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K;
isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K;
/**

@@ -201,3 +201,3 @@ * Time Complexity: O(log n) - Average case for a balanced tree.

*/
ensureNode(key: BSTNodeKeyOrNode<K, N>, iterationType?: IterationType): N | undefined;
ensureNode(key: BSTNKeyOrNode<K, N>, iterationType?: IterationType): N | undefined;
/**

@@ -226,3 +226,3 @@ * Time Complexity: O(log n) - Average case for a balanced tree. O(n) - Visiting each node once when identifier is not node's key.

*/
getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: BSTNodeKeyOrNode<K, N>, iterationType?: IterationType): N[];
getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: BSTNKeyOrNode<K, N>, iterationType?: IterationType): N[];
/**

@@ -253,3 +253,3 @@ * Time Complexity: O(log n) - Average case for a balanced tree. O(n) - Visiting each node once when identifier is not node's key.

*/
lesserOrGreaterTraverse<C extends BTNCallback<N>>(callback?: C, lesserOrGreater?: CP, targetNode?: BSTNodeKeyOrNode<K, N>, iterationType?: IterationType): ReturnType<C>[];
lesserOrGreaterTraverse<C extends BTNCallback<N>>(callback?: C, lesserOrGreater?: CP, targetNode?: BSTNKeyOrNode<K, N>, iterationType?: IterationType): ReturnType<C>[];
/**

@@ -256,0 +256,0 @@ * Time Complexity: O(log n) - Average case for a balanced tree. O(n) - Visiting each node once when identifier is not node's key.

@@ -61,3 +61,3 @@ "use strict";

* the tree with optional elements and options.
* @param [elements] - An optional iterable of BTNodeExemplar objects that will be added to the
* @param [elements] - An optional iterable of BTNExemplar objects that will be added to the
* binary search tree.

@@ -109,3 +109,3 @@ * @param [options] - The `options` parameter is an optional object that can contain additional

* The function checks if an exemplar is an instance of BSTNode.
* @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is a variable of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the BSTNode class.

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

* otherwise it returns undefined.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the

@@ -122,0 +122,0 @@ * `exemplarToNode` function. It represents the value associated with the exemplar node.

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

*/
import { BiTreeDeleteResult, BTNCallback, BTNodeExemplar, BTNodeKeyOrNode, IterationType, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
import { BinaryTreeDeleteResult, BTNCallback, BTNExemplar, BTNKeyOrNode, IterationType, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
import { BST, BSTNode } from './bst';

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

* initializes the tree with optional elements and options.
* @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
* @param [elements] - The `elements` parameter is an optional iterable of `BTNExemplar<K, V, N>`
* objects. It represents the initial elements that will be added to the RBTree during its

@@ -37,3 +37,3 @@ * construction. If this parameter is provided, the `addMany` method is called to add all the

*/
constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<RBTreeOptions<K>>);
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<RBTreeOptions<K>>);
protected _root: N;

@@ -66,7 +66,7 @@ get root(): N;

* The function checks if an exemplar is an instance of the RedBlackTreeNode class.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the RedBlackTreeNode
* class.
*/
isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N;
isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N;
/**

@@ -78,6 +78,6 @@ * The function "isNotNodeInstance" checks if a potential key is a K.

*/
isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K;
isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K;
/**
* The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the

@@ -88,3 +88,3 @@ * `exemplarToNode` function. It represents the value associated with the exemplar node. If a value

*/
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
exemplarToNode(exemplar: BTNExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -106,3 +106,3 @@ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)

*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -125,5 +125,5 @@ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)

* on its identifier. The `callback` function is optional and defaults to `this._defaultOneParam
* @returns an array of `BiTreeDeleteResult<N>`.
* @returns an array of `BinaryTreeDeleteResult<N>`.
*/
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null | undefined, callback?: C): BiTreeDeleteResult<N>[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null | undefined, callback?: C): BinaryTreeDeleteResult<N>[];
/**

@@ -130,0 +130,0 @@ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)

@@ -13,3 +13,2 @@ "use strict";

const bst_1 = require("./bst");
const binary_tree_1 = require("./binary-tree");
class RedBlackTreeNode extends bst_1.BSTNode {

@@ -33,3 +32,3 @@ constructor(key, value, color = types_1.RBTNColor.BLACK) {

* initializes the tree with optional elements and options.
* @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
* @param [elements] - The `elements` parameter is an optional iterable of `BTNExemplar<K, V, N>`
* objects. It represents the initial elements that will be added to the RBTree during its

@@ -83,3 +82,3 @@ * construction. If this parameter is provided, the `addMany` method is called to add all the

* The function checks if an exemplar is an instance of the RedBlackTreeNode class.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the RedBlackTreeNode

@@ -102,3 +101,3 @@ * class.

* The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the

@@ -214,3 +213,3 @@ * `exemplarToNode` function. It represents the value associated with the exemplar node. If a value

* on its identifier. The `callback` function is optional and defaults to `this._defaultOneParam
* @returns an array of `BiTreeDeleteResult<N>`.
* @returns an array of `BinaryTreeDeleteResult<N>`.
*/

@@ -311,3 +310,3 @@ delete(identifier, callback = this._defaultOneParamCallback) {

var _a;
if (identifier instanceof binary_tree_1.BinaryTreeNode)
if (identifier instanceof RedBlackTreeNode)
callback = (node => node);

@@ -314,0 +313,0 @@ beginRoot = this.ensureNode(beginRoot);

@@ -8,4 +8,4 @@ /**

*/
import type { BSTNodeKeyOrNode, BTNodeExemplar, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
import { BiTreeDeleteResult, BTNCallback, BTNodeKeyOrNode, IterationType, TreeMultimapNested } from '../../types';
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNExemplar, BTNKeyOrNode, TreeMultimapNested, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
import { IterationType } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -31,3 +31,3 @@ import { AVLTree, AVLTreeNode } from './avl-tree';

export declare class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K, V, N> = TreeMultimapNode<K, V, TreeMultimapNodeNested<K, V>>, TREE extends TreeMultimap<K, V, N, TREE> = TreeMultimap<K, V, N, TreeMultimapNested<K, V, N>>> extends AVLTree<K, V, N, TREE> implements IBinaryTree<K, V, N, TREE> {
constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<TreeMultimapOptions<K>>);
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<TreeMultimapOptions<K>>);
private _count;

@@ -48,7 +48,7 @@ get count(): number;

* The function checks if an exemplar is an instance of the TreeMultimapNode class.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the TreeMultimapNode
* class.
*/
isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N;
isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N;
/**

@@ -60,6 +60,6 @@ * The function "isNotNodeInstance" checks if a potential key is a K.

*/
isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K;
isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K;
/**
* The function `exemplarToNode` converts an exemplar object into a node object.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, which means it
* can be one of the following:

@@ -73,3 +73,3 @@ * @param {V} [value] - The `value` parameter is an optional argument that represents the value

*/
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | undefined;
exemplarToNode(exemplar: BTNExemplar<K, V, N>, value?: V, count?: number): N | undefined;
/**

@@ -95,3 +95,3 @@ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.

*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | undefined;
add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V, count?: number): N | undefined;
/**

@@ -111,3 +111,3 @@ * Time Complexity: O(k log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.

*/
addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<K, V, N>>): (N | undefined)[];
addMany(keysOrNodesOrEntries: Iterable<BTNExemplar<K, V, N>>): (N | undefined)[];
/**

@@ -150,5 +150,5 @@ * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.

* decremented by 1 and
* @returns an array of `BiTreeDeleteResult<N>`.
* @returns an array of `BinaryTreeDeleteResult<N>`.
*/
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BiTreeDeleteResult<N>[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<N>[];
/**

@@ -189,3 +189,3 @@ * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.

*/
protected _addTo(newNode: N | undefined, parent: BSTNodeKeyOrNode<K, N>): N | undefined;
protected _addTo(newNode: N | undefined, parent: BSTNKeyOrNode<K, N>): N | undefined;
/**

@@ -200,4 +200,4 @@ * The `_swapProperties` function swaps the key, value, count, and height properties between two nodes.

*/
protected _swapProperties(srcNode: BSTNodeKeyOrNode<K, N>, destNode: BSTNodeKeyOrNode<K, N>): N | undefined;
protected _swapProperties(srcNode: BSTNKeyOrNode<K, N>, destNode: BSTNKeyOrNode<K, N>): N | undefined;
protected _replaceNode(oldNode: N, newNode: N): N;
}

@@ -56,3 +56,3 @@ "use strict";

* The function checks if an exemplar is an instance of the TreeMultimapNode class.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the TreeMultimapNode

@@ -75,3 +75,3 @@ * class.

* The function `exemplarToNode` converts an exemplar object into a node object.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, which means it
* can be one of the following:

@@ -230,3 +230,3 @@ * @param {V} [value] - The `value` parameter is an optional argument that represents the value

* decremented by 1 and
* @returns an array of `BiTreeDeleteResult<N>`.
* @returns an array of `BinaryTreeDeleteResult<N>`.
*/

@@ -233,0 +233,0 @@ delete(identifier, callback = this._defaultOneParamCallback, ignoreCount = false) {

@@ -1,5 +0,11 @@

import type { DijkstraResult, VertexKey } from '../../types';
import { EntryCallback } from "../../types";
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { DijkstraResult, EntryCallback, VertexKey } from '../../types';
import { IterableEntryBase } from "../base";
import { IGraph } from '../../interfaces';
import { IterableEntryBase } from "../base";
export declare abstract class AbstractVertex<V = any> {

@@ -6,0 +12,0 @@ key: VertexKey;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractGraph = exports.AbstractEdge = exports.AbstractVertex = void 0;
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
const utils_1 = require("../../utils");
const priority_queue_1 = require("../priority-queue");
const base_1 = require("../base");
const heap_1 = require("../heap");
const queue_1 = require("../queue");
const base_1 = require("../base");
class AbstractVertex {

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

*/
dijkstraWithoutHeap(src, dest, getMinDist, genPaths) {
if (getMinDist === undefined)
getMinDist = false;
if (genPaths === undefined)
genPaths = false;
if (dest === undefined)
dest = undefined;
dijkstraWithoutHeap(src, dest = undefined, getMinDist = false, genPaths = false) {
let minDist = Infinity;

@@ -579,10 +566,4 @@ let minDest = undefined;

*/
dijkstra(src, dest, getMinDist, genPaths) {
dijkstra(src, dest = undefined, getMinDist = false, genPaths = false) {
var _a;
if (getMinDist === undefined)
getMinDist = false;
if (genPaths === undefined)
genPaths = false;
if (dest === undefined)
dest = undefined;
let minDist = Infinity;

@@ -605,3 +586,3 @@ let minDest = undefined;

}
const heap = new priority_queue_1.PriorityQueue([], { comparator: (a, b) => a.key - b.key });
const heap = new heap_1.Heap([], { comparator: (a, b) => a.key - b.key });
heap.add({ key: 0, value: srcVertex });

@@ -975,10 +956,25 @@ distMap.set(srcVertex, 0);

if (needCycles) {
let SCCs = new Map();
if (SCCs.size < 1) {
SCCs = getSCCs();
}
SCCs.forEach((SCC, low) => {
if (SCC.length > 1) {
cycles.set(low, SCC);
const visitedMap = new Map();
const stack = [];
const findCyclesDFS = (cur, parent) => {
visitedMap.set(cur, true);
stack.push(cur);
const neighbors = this.getNeighbors(cur);
for (const neighbor of neighbors) {
if (!visitedMap.get(neighbor)) {
findCyclesDFS(neighbor, cur);
}
else if (stack.includes(neighbor) && neighbor !== parent) {
const cycleStartIndex = stack.indexOf(neighbor);
const cycle = stack.slice(cycleStartIndex);
const cycleLow = Math.min(...cycle.map(v => dfnMap.get(v) || Infinity));
cycles.set(cycleLow, cycle);
}
}
stack.pop();
};
vertexMap.forEach(v => {
if (!visitedMap.get(v)) {
findCyclesDFS(v, undefined);
}
});

@@ -985,0 +981,0 @@ }

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

/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { VertexKey } from '../../types';
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
import type { VertexKey } from '../../types';
import { IGraph } from '../../interfaces';

@@ -4,0 +11,0 @@ export declare class DirectedVertex<V = any> extends AbstractVertex<V> {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DirectedGraph = exports.DirectedEdge = exports.DirectedVertex = void 0;
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
const abstract_graph_1 = require("./abstract-graph");
const utils_1 = require("../../utils");
const abstract_graph_1 = require("./abstract-graph");
class DirectedVertex extends abstract_graph_1.AbstractVertex {

@@ -14,0 +7,0 @@ /**

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

import { MapGraphCoordinate, VertexKey } from '../../types';
import type { MapGraphCoordinate, VertexKey } from '../../types';
import { DirectedEdge, DirectedGraph, DirectedVertex } from './directed-graph';

@@ -3,0 +3,0 @@ export declare class MapVertex<V = any> extends DirectedVertex<V> {

@@ -1,4 +0,11 @@

import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { VertexKey } from '../../types';
import { IGraph } from '../../interfaces';
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {

@@ -5,0 +12,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UndirectedGraph = exports.UndirectedEdge = exports.UndirectedVertex = void 0;
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
const abstract_graph_1 = require("./abstract-graph");
const utils_1 = require("../../utils");
const abstract_graph_1 = require("./abstract-graph");
class UndirectedVertex extends abstract_graph_1.AbstractVertex {

@@ -14,0 +7,0 @@ /**

@@ -8,4 +8,10 @@ /**

*/
import { EntryCallback, HashMapLinkedNode, HashMapOptions, HashMapStoreItem } from '../../types';
import { IterableEntryBase } from "../base";
import type { EntryCallback, HashMapLinkedNode, HashMapOptions, HashMapStoreItem } from '../../types';
import { IterableEntryBase } from '../base';
/**
* 1. Key-Value Pair Storage: HashMap stores key-value pairs. Each key maps to a value.
* 2. Fast Lookup: It's used when you need to quickly find, insert, or delete elements based on a key.
* 3. Unique Keys: Keys are unique. If you try to insert another entry with the same key, the old entry will be replaced by the new one.
* 4. Unordered Collection: HashMap does not guarantee the order of elements, and the order may change over time.
*/
export declare class HashMap<K = any, V = any> extends IterableEntryBase<K, V> {

@@ -121,2 +127,7 @@ protected _store: {

}
/**
* 1. Maintaining the Order of Element Insertion: Unlike HashMap, LinkedHashMap maintains the order in which elements are inserted. Therefore, when you traverse it, elements will be returned in the order they were inserted into the map.
* 2. Based on Hash Table and Linked List: It combines the structures of a hash table and a linked list, using the hash table to ensure fast access, while maintaining the order of elements through the linked list.
* 3. Time Complexity: Similar to HashMap, LinkedHashMap offers constant-time performance for get and put operations in most cases.
*/
export declare class LinkedHashMap<K = any, V = any> extends IterableEntryBase<K, V> {

@@ -174,2 +185,3 @@ protected _noObjMap: Record<string, HashMapLinkedNode<K, V | undefined>>;

has(key: K): boolean;
hasValue(value: V): boolean;
setMany(entries: Iterable<[K, V]>): void;

@@ -176,0 +188,0 @@ /**

"use strict";
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinkedHashMap = exports.HashMap = void 0;
const base_1 = require("../base");
const utils_1 = require("../../utils");
const base_1 = require("../base");
/**
* 1. Key-Value Pair Storage: HashMap stores key-value pairs. Each key maps to a value.
* 2. Fast Lookup: It's used when you need to quickly find, insert, or delete elements based on a key.
* 3. Unique Keys: Keys are unique. If you try to insert another entry with the same key, the old entry will be replaced by the new one.
* 4. Unordered Collection: HashMap does not guarantee the order of elements, and the order may change over time.
*/
class HashMap extends base_1.IterableEntryBase {

@@ -233,2 +232,7 @@ /**

exports.HashMap = HashMap;
/**
* 1. Maintaining the Order of Element Insertion: Unlike HashMap, LinkedHashMap maintains the order in which elements are inserted. Therefore, when you traverse it, elements will be returned in the order they were inserted into the map.
* 2. Based on Hash Table and Linked List: It combines the structures of a hash table and a linked list, using the hash table to ensure fast access, while maintaining the order of elements through the linked list.
* 3. Time Complexity: Similar to HashMap, LinkedHashMap offers constant-time performance for get and put operations in most cases.
*/
class LinkedHashMap extends base_1.IterableEntryBase {

@@ -369,2 +373,9 @@ constructor(elements, options = {

}
hasValue(value) {
for (const [, elementValue] of this) {
if (elementValue === value)
return true;
}
return false;
}
setMany(entries) {

@@ -371,0 +382,0 @@ for (const entry of entries) {

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

*/
export declare class HashTableNode<K, V> {
import type { HashFunction } from '../../types';
export declare class HashTableNode<K = any, V = any> {
key: K;

@@ -15,3 +16,2 @@ value: V;

}
import { HashFunction } from '../../types';
export declare class HashTable<K = any, V = any> {

@@ -18,0 +18,0 @@ protected static readonly DEFAULT_CAPACITY = 16;

@@ -7,5 +7,16 @@ /**

*/
import type { Comparator, DFSOrderPattern, ElementCallback } from '../../types';
import { HeapOptions } from "../../types";
import { IterableElementBase } from "../base";
import type { Comparator, DFSOrderPattern, ElementCallback, HeapOptions } from '../../types';
import { IterableElementBase } from '../base';
/**
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
* 2. Heap Properties: Each node in a heap follows a specific order property, which varies depending on the type of heap:
* Max Heap: The value of each parent node is greater than or equal to the value of its children.
* Min Heap: The value of each parent node is less than or equal to the value of its children.
* 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
* 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
* 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
* 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
* 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
*/
export declare class Heap<E = any> extends IterableElementBase<E> {

@@ -12,0 +23,0 @@ options: HeapOptions<E>;

@@ -11,2 +11,14 @@ "use strict";

const base_1 = require("../base");
/**
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
* 2. Heap Properties: Each node in a heap follows a specific order property, which varies depending on the type of heap:
* Max Heap: The value of each parent node is greater than or equal to the value of its children.
* Min Heap: The value of each parent node is less than or equal to the value of its children.
* 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
* 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
* 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
* 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
* 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
*/
class Heap extends base_1.IterableElementBase {

@@ -13,0 +25,0 @@ constructor(elements, options) {

@@ -8,6 +8,16 @@ /**

*/
import type { HeapOptions } from '../../types';
import { Heap } from './heap';
import type { HeapOptions } from '../../types';
/**
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
* 2. Heap Properties: The value of each parent node is greater than or equal to the value of its children.
* 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
* 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
* 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
* 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
* 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
*/
export declare class MaxHeap<E = any> extends Heap<E> {
constructor(elements?: Iterable<E>, options?: HeapOptions<E>);
}
"use strict";
/**
* data-structure-typed
*
* @author Kirk Qi
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
* @license MIT License
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MaxHeap = void 0;
const heap_1 = require("./heap");
/**
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
* 2. Heap Properties: The value of each parent node is greater than or equal to the value of its children.
* 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
* 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
* 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
* 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
* 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
*/
class MaxHeap extends heap_1.Heap {

@@ -13,0 +16,0 @@ constructor(elements, options = {

@@ -8,6 +8,16 @@ /**

*/
import type { HeapOptions } from '../../types';
import { Heap } from './heap';
import type { HeapOptions } from '../../types';
/**
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
* 2. Heap Properties: The value of each parent node is less than or equal to the value of its children.
* 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
* 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
* 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
* 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
* 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
*/
export declare class MinHeap<E = any> extends Heap<E> {
constructor(elements?: Iterable<E>, options?: HeapOptions<E>);
}
"use strict";
/**
* data-structure-typed
*
* @author Kirk Qi
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
* @license MIT License
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MinHeap = void 0;
const heap_1 = require("./heap");
/**
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
* 2. Heap Properties: The value of each parent node is less than or equal to the value of its children.
* 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
* 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
* 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
* 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
* 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
*/
class MinHeap extends heap_1.Heap {

@@ -13,0 +16,0 @@ constructor(elements, options = {

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

import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
/**

@@ -10,2 +8,4 @@ * data-structure-typed

*/
import type { ElementCallback } from '../../types';
import { IterableElementBase } from '../base';
export declare class DoublyLinkedListNode<E = any> {

@@ -22,2 +22,8 @@ value: E;

}
/**
* 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.
* 2. Bidirectional Traversal: Unlike singly linked lists, doubly linked lists can be easily traversed forwards or backwards. This makes insertions and deletions in the list more flexible and efficient.
* 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.
* 4. High Efficiency in Insertion and Deletion: Adding or removing elements in a linked list does not require moving other elements, making these operations more efficient than in arrays.
*/
export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {

@@ -24,0 +30,0 @@ /**

@@ -5,9 +5,2 @@ "use strict";

const base_1 = require("../base");
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
class DoublyLinkedListNode {

@@ -26,2 +19,8 @@ /**

exports.DoublyLinkedListNode = DoublyLinkedListNode;
/**
* 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.
* 2. Bidirectional Traversal: Unlike singly linked lists, doubly linked lists can be easily traversed forwards or backwards. This makes insertions and deletions in the list more flexible and efficient.
* 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.
* 4. High Efficiency in Insertion and Deletion: Adding or removing elements in a linked list does not require moving other elements, making these operations more efficient than in arrays.
*/
class DoublyLinkedList extends base_1.IterableElementBase {

@@ -28,0 +27,0 @@ /**

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

import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
/**

@@ -10,2 +8,4 @@ * data-structure-typed

*/
import type { ElementCallback } from "../../types";
import { IterableElementBase } from "../base";
export declare class SinglyLinkedListNode<E = any> {

@@ -12,0 +12,0 @@ value: E;

@@ -5,9 +5,2 @@ "use strict";

const base_1 = require("../base");
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
class SinglyLinkedListNode {

@@ -14,0 +7,0 @@ /**

@@ -8,6 +8,6 @@ /**

*/
import type { PriorityQueueOptions } from '../../types';
import { PriorityQueue } from './priority-queue';
import type { PriorityQueueOptions } from '../../types';
export declare class MaxPriorityQueue<E = any> extends PriorityQueue<E> {
constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MaxPriorityQueue = void 0;
/**
* data-structure-typed
*
* @author Kirk Qi
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
* @license MIT License
*/
const priority_queue_1 = require("./priority-queue");

@@ -12,0 +5,0 @@ class MaxPriorityQueue extends priority_queue_1.PriorityQueue {

@@ -8,6 +8,6 @@ /**

*/
import type { PriorityQueueOptions } from '../../types';
import { PriorityQueue } from './priority-queue';
import type { PriorityQueueOptions } from '../../types';
export declare class MinPriorityQueue<E = any> extends PriorityQueue<E> {
constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MinPriorityQueue = void 0;
/**
* data-structure-typed
*
* @author Kirk Qi
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
* @license MIT License
*/
const priority_queue_1 = require("./priority-queue");

@@ -12,0 +5,0 @@ class MinPriorityQueue extends priority_queue_1.PriorityQueue {

@@ -8,6 +8,14 @@ /**

*/
import type { PriorityQueueOptions } from '../../types';
import { Heap } from '../heap';
import { PriorityQueueOptions } from '../../types';
/**
* 1. Element Priority: In a PriorityQueue, elements are sorted according to their priority. Each dequeue (element removal) operation removes the element with the highest priority. The priority can be determined based on the natural ordering of the elements or through a provided comparator (Comparator).
* 2. Heap-Based Implementation: PriorityQueue is typically implemented using a binary heap, allowing both insertion and removal operations to be completed in O(log n) time, where n is the number of elements in the queue.
* 3. Task Scheduling: In systems where tasks need to be processed based on the urgency of tasks rather than the order of arrival.
* 4. Dijkstra's Algorithm: In shortest path algorithms for graphs, used to select the next shortest edge to visit.
* 5. Huffman Coding: Used to select the smallest node combination when constructing a Huffman tree.
* 6. Kth Largest Element in a Data Stream: Used to maintain a min-heap of size K for quickly finding the Kth largest element in stream data
*/
export declare class PriorityQueue<E = any> extends Heap<E> {
constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
}
"use strict";
/**
* data-structure-typed
*
* @author Kirk Qi
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
* @license MIT License
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.PriorityQueue = void 0;
const heap_1 = require("../heap");
/**
* 1. Element Priority: In a PriorityQueue, elements are sorted according to their priority. Each dequeue (element removal) operation removes the element with the highest priority. The priority can be determined based on the natural ordering of the elements or through a provided comparator (Comparator).
* 2. Heap-Based Implementation: PriorityQueue is typically implemented using a binary heap, allowing both insertion and removal operations to be completed in O(log n) time, where n is the number of elements in the queue.
* 3. Task Scheduling: In systems where tasks need to be processed based on the urgency of tasks rather than the order of arrival.
* 4. Dijkstra's Algorithm: In shortest path algorithms for graphs, used to select the next shortest edge to visit.
* 5. Huffman Coding: Used to select the smallest node combination when constructing a Huffman tree.
* 6. Kth Largest Element in a Data Stream: Used to maintain a min-heap of size K for quickly finding the Kth largest element in stream data
*/
class PriorityQueue extends heap_1.Heap {

@@ -13,0 +14,0 @@ constructor(elements, options) {

@@ -8,9 +8,10 @@ /**

*/
import { ElementCallback, IterableWithSizeOrLength } from "../../types";
import type { ElementCallback, IterableWithSizeOrLength } from "../../types";
import { IterableElementBase } from "../base";
/**
* Deque can provide random access with O(1) time complexity
* Deque is usually more compact and efficient in memory usage because it does not require additional space to store pointers.
* Deque may experience performance jitter, but DoublyLinkedList will not
* Deque is implemented using a dynamic array. Inserting or deleting beyond both ends of the array may require moving elements or reallocating space.
* 1. Operations at Both Ends: Supports adding and removing elements at both the front and back of the queue. This allows it to be used as a stack (last in, first out) and a queue (first in, first out).
* 2. Efficient Random Access: Being based on an array, it offers fast random access capability, allowing constant time access to any element.
* 3. Continuous Memory Allocation: Since it is based on an array, all elements are stored contiguously in memory, which can bring cache friendliness and efficient memory access.
* 4. Efficiency: Adding and removing elements at both ends of a deque is usually very fast. However, when the dynamic array needs to expand, it may involve copying the entire array to a larger one, and this operation has a time complexity of O(n).
* 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
*/

@@ -17,0 +18,0 @@ export declare class Deque<E> extends IterableElementBase<E> {

"use strict";
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Deque = void 0;
const base_1 = require("../base");
const utils_1 = require("../../utils");
const base_1 = require("../base");
/**
* Deque can provide random access with O(1) time complexity
* Deque is usually more compact and efficient in memory usage because it does not require additional space to store pointers.
* Deque may experience performance jitter, but DoublyLinkedList will not
* Deque is implemented using a dynamic array. Inserting or deleting beyond both ends of the array may require moving elements or reallocating space.
* 1. Operations at Both Ends: Supports adding and removing elements at both the front and back of the queue. This allows it to be used as a stack (last in, first out) and a queue (first in, first out).
* 2. Efficient Random Access: Being based on an array, it offers fast random access capability, allowing constant time access to any element.
* 3. Continuous Memory Allocation: Since it is based on an array, all elements are stored contiguously in memory, which can bring cache friendliness and efficient memory access.
* 4. Efficiency: Adding and removing elements at both ends of a deque is usually very fast. However, when the dynamic array needs to expand, it may involve copying the entire array to a larger one, and this operation has a time complexity of O(n).
* 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
*/

@@ -19,0 +13,0 @@ class Deque extends base_1.IterableElementBase {

@@ -6,5 +6,14 @@ /**

*/
import type { ElementCallback } from '../../types';
import { IterableElementBase } from "../base";
import { SinglyLinkedList } from '../linked-list';
import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
/**
* 1. First In, First Out (FIFO): The core feature of a queue is its first in, first out nature. The element added to the queue first will be the one to be removed first.
* 2. Operations: The main operations include enqueue (adding an element to the end of the queue) and dequeue (removing and returning the element at the front of the queue). Typically, there is also a peek operation (looking at the front element without removing it).
* 3. Uses: Queues are commonly used to manage a series of tasks or elements that need to be processed in order. For example, managing task queues in a multi-threaded environment, or in algorithms for data structures like trees and graphs for breadth-first search.
* 4. Task Scheduling: Managing the order of task execution in operating systems or applications.
* 5. Data Buffering: Acting as a buffer for data packets in network communication.
* 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store nodes that are to be visited.
* 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
*/
export declare class Queue<E = any> extends IterableElementBase<E> {

@@ -125,3 +134,3 @@ /**

*/
enqueue(value: E): void;
enqueue(value: E): Queue<E>;
/**

@@ -237,2 +246,8 @@ * Time Complexity: O(n) - same as shift().

}
/**
* 1. First In, First Out (FIFO) Strategy: Like other queue implementations, LinkedListQueue follows the first in, first out principle, meaning the element that is added to the queue first will be the first to be removed.
* 2. Based on Linked List: LinkedListQueue uses a linked list to store elements. Each node in the linked list contains data and a pointer to the next node.
* 3. Memory Usage: Since each element requires additional space to store a pointer to the next element, linked lists may use more memory compared to arrays.
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
*/
export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {

@@ -239,0 +254,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinkedListQueue = exports.Queue = void 0;
const base_1 = require("../base");
const linked_list_1 = require("../linked-list");
/**
* @license MIT
* @copyright Tyler Zeng <zrwusa@gmail.com>
* @class
* 1. First In, First Out (FIFO): The core feature of a queue is its first in, first out nature. The element added to the queue first will be the one to be removed first.
* 2. Operations: The main operations include enqueue (adding an element to the end of the queue) and dequeue (removing and returning the element at the front of the queue). Typically, there is also a peek operation (looking at the front element without removing it).
* 3. Uses: Queues are commonly used to manage a series of tasks or elements that need to be processed in order. For example, managing task queues in a multi-threaded environment, or in algorithms for data structures like trees and graphs for breadth-first search.
* 4. Task Scheduling: Managing the order of task execution in operating systems or applications.
* 5. Data Buffering: Acting as a buffer for data packets in network communication.
* 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store nodes that are to be visited.
* 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
*/
const linked_list_1 = require("../linked-list");
const base_1 = require("../base");
class Queue extends base_1.IterableElementBase {

@@ -160,3 +164,3 @@ /**

enqueue(value) {
this.push(value);
return this.push(value);
}

@@ -311,2 +315,8 @@ /**

exports.Queue = Queue;
/**
* 1. First In, First Out (FIFO) Strategy: Like other queue implementations, LinkedListQueue follows the first in, first out principle, meaning the element that is added to the queue first will be the first to be removed.
* 2. Based on Linked List: LinkedListQueue uses a linked list to store elements. Each node in the linked list contains data and a pointer to the next node.
* 3. Memory Usage: Since each element requires additional space to store a pointer to the next element, linked lists may use more memory compared to arrays.
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
*/
class LinkedListQueue extends linked_list_1.SinglyLinkedList {

@@ -313,0 +323,0 @@ /**

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

import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
/**
* @license MIT
* @copyright Tyler Zeng <zrwusa@gmail.com>
* @class
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { ElementCallback } from '../../types';
import { IterableElementBase } from '../base';
/**
* 1. Last In, First Out (LIFO): The core characteristic of a stack is its last in, first out nature, meaning the last element added to the stack will be the first to be removed.
* 2. Uses: Stacks are commonly used for managing a series of tasks or elements that need to be processed in a last in, first out manner. They are widely used in various scenarios, such as in function calls in programming languages, evaluation of arithmetic expressions, and backtracking algorithms.
* 3. Performance: Stack operations are typically O(1) in time complexity, meaning that regardless of the stack's size, adding, removing, and viewing the top element are very fast operations.
* 4. Function Calls: In most modern programming languages, the records of function calls are managed through a stack. When a function is called, its record (including parameters, local variables, and return address) is 'pushed' into the stack. When the function returns, its record is 'popped' from the stack.
* 5. Expression Evaluation: Used for the evaluation of arithmetic or logical expressions, especially when dealing with parenthesis matching and operator precedence.
* 6. Backtracking Algorithms: In problems where multiple branches need to be explored but only one branch can be explored at a time, stacks can be used to save the state at each branching point.
*/
export declare class Stack<E = any> extends IterableElementBase<E> {

@@ -9,0 +19,0 @@ /**

@@ -6,5 +6,8 @@ "use strict";

/**
* @license MIT
* @copyright Tyler Zeng <zrwusa@gmail.com>
* @class
* 1. Last In, First Out (LIFO): The core characteristic of a stack is its last in, first out nature, meaning the last element added to the stack will be the first to be removed.
* 2. Uses: Stacks are commonly used for managing a series of tasks or elements that need to be processed in a last in, first out manner. They are widely used in various scenarios, such as in function calls in programming languages, evaluation of arithmetic expressions, and backtracking algorithms.
* 3. Performance: Stack operations are typically O(1) in time complexity, meaning that regardless of the stack's size, adding, removing, and viewing the top element are very fast operations.
* 4. Function Calls: In most modern programming languages, the records of function calls are managed through a stack. When a function is called, its record (including parameters, local variables, and return address) is 'pushed' into the stack. When the function returns, its record is 'popped' from the stack.
* 5. Expression Evaluation: Used for the evaluation of arithmetic or logical expressions, especially when dealing with parenthesis matching and operator precedence.
* 6. Backtracking Algorithms: In problems where multiple branches need to be explored but only one branch can be explored at a time, stacks can be used to save the state at each branching point.
*/

@@ -107,3 +110,3 @@ class Stack extends base_1.IterableElementBase {

return undefined;
return this.elements.pop() || undefined;
return this.elements.pop();
}

@@ -110,0 +113,0 @@ /**

@@ -8,4 +8,4 @@ /**

*/
import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
import type { ElementCallback } from '../../types';
import { IterableElementBase } from '../base';
/**

@@ -22,3 +22,13 @@ * TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,

/**
* Trie represents a Trie data structure. It provides basic Trie operations and additional methods.
* 1. Node Structure: Each node in a Trie represents a string (or a part of a string). The root node typically represents an empty string.
* 2. Child Node Relationship: Each node's children represent the strings that can be formed by adding one character to the string at the current node. For example, if a node represents the string 'ca', one of its children might represent 'cat'.
* 3. Fast Retrieval: Trie allows retrieval in O(m) time complexity, where m is the length of the string to be searched.
* 4. Space Efficiency: Trie can store a large number of strings very space-efficiently, especially when these strings share common prefixes.
* 5. Autocomplete and Prediction: Trie can be used for implementing autocomplete and word prediction features, as it can quickly find all strings with a common prefix.
* 6. Sorting: Trie can be used to sort a set of strings in alphabetical order.
* 7. String Retrieval: For example, searching for a specific string in a large set of strings.
* 8. Autocomplete: Providing recommended words or phrases as a user types.
* 9. Spell Check: Checking the spelling of words.
* 10. IP Routing: Used in certain types of IP routing algorithms.
* 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data."
*/

@@ -25,0 +35,0 @@ export declare class Trie extends IterableElementBase<string> {

"use strict";
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
Object.defineProperty(exports, "__esModule", { value: true });

@@ -25,3 +18,13 @@ exports.Trie = exports.TrieNode = void 0;

/**
* Trie represents a Trie data structure. It provides basic Trie operations and additional methods.
* 1. Node Structure: Each node in a Trie represents a string (or a part of a string). The root node typically represents an empty string.
* 2. Child Node Relationship: Each node's children represent the strings that can be formed by adding one character to the string at the current node. For example, if a node represents the string 'ca', one of its children might represent 'cat'.
* 3. Fast Retrieval: Trie allows retrieval in O(m) time complexity, where m is the length of the string to be searched.
* 4. Space Efficiency: Trie can store a large number of strings very space-efficiently, especially when these strings share common prefixes.
* 5. Autocomplete and Prediction: Trie can be used for implementing autocomplete and word prediction features, as it can quickly find all strings with a common prefix.
* 6. Sorting: Trie can be used to sort a set of strings in alphabetical order.
* 7. String Retrieval: For example, searching for a specific string in a large set of strings.
* 8. Autocomplete: Providing recommended words or phrases as a user types.
* 9. Spell Check: Checking the spelling of words.
* 10. IP Routing: Used in certain types of IP routing algorithms.
* 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data."
*/

@@ -28,0 +31,0 @@ class Trie extends base_1.IterableElementBase {

import { BinaryTree, BinaryTreeNode } from '../data-structures';
import { BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BiTreeDeleteResult, BTNCallback, BTNodeExemplar } from '../types';
import { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, BTNExemplar } from '../types';
export interface IBinaryTree<K = number, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTreeNested<K, V, N>> {
createNode(key: K, value?: N['value']): N;
createTree(options?: Partial<BinaryTreeOptions<K>>): TREE;
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | null | undefined;
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>): (N | null | undefined)[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BiTreeDeleteResult<N>[];
add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V, count?: number): N | null | undefined;
addMany(nodes: Iterable<BTNExemplar<K, V, N>>, values?: Iterable<V | undefined>): (N | null | undefined)[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<N>[];
}

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

export type Comparator<K> = (a: K, b: K) => number;
export declare enum BSTVariant {

@@ -6,4 +5,2 @@ MIN = "MIN",

}
export type DFSOrderPattern = 'pre' | 'in' | 'post';
export type BTNCallback<N, D = any> = (node: N) => D;
export declare enum CP {

@@ -14,2 +11,25 @@ lt = "lt",

}
/**
* Enum representing different loop types.
*
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
*/
export declare enum IterationType {
ITERATIVE = "ITERATIVE",
RECURSIVE = "RECURSIVE"
}
export declare enum FamilyPosition {
ROOT = "ROOT",
LEFT = "LEFT",
RIGHT = "RIGHT",
ROOT_LEFT = "ROOT_LEFT",
ROOT_RIGHT = "ROOT_RIGHT",
ISOLATED = "ISOLATED",
MAL_NODE = "MAL_NODE"
}
export type Comparator<K> = (a: K, b: K) => number;
export type DFSOrderPattern = 'pre' | 'in' | 'post';
export type NodeDisplayLayout = [string[], number, number, number];
export type BTNCallback<N, D = any> = (node: N) => D;
export interface IterableWithSize<T> extends Iterable<T> {

@@ -27,7 +47,11 @@ size: number | ((...args: any[]) => number);

};
export type BTNodeEntry<K, V> = [K | null | undefined, V | undefined];
export type BTNodeKeyOrNode<K, N> = K | null | undefined | N;
export type BTNodeExemplar<K, V, N> = BTNodeEntry<K, V> | BTNodeKeyOrNode<K, N>;
export type BTNEntry<K, V> = [K | null | undefined, V | undefined];
export type BTNKeyOrNode<K, N> = K | null | undefined | N;
export type BTNExemplar<K, V, N> = BTNEntry<K, V> | BTNKeyOrNode<K, N>;
export type BTNodePureKeyOrNode<K, N> = K | N;
export type BTNodePureExemplar<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>;
export type BTNodePureKeyOrNode<K, N> = K | N;
export type BSTNodeKeyOrNode<K, N> = K | undefined | N;
export type BSTNKeyOrNode<K, N> = K | undefined | N;
export type BinaryTreeDeleteResult<N> = {
deleted: N | null | undefined;
needBalanced: N | null | undefined;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CP = exports.BSTVariant = void 0;
exports.FamilyPosition = exports.IterationType = exports.CP = exports.BSTVariant = void 0;
var BSTVariant;

@@ -15,1 +15,22 @@ (function (BSTVariant) {

})(CP = exports.CP || (exports.CP = {}));
/**
* Enum representing different loop types.
*
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
*/
var IterationType;
(function (IterationType) {
IterationType["ITERATIVE"] = "ITERATIVE";
IterationType["RECURSIVE"] = "RECURSIVE";
})(IterationType = exports.IterationType || (exports.IterationType = {}));
var FamilyPosition;
(function (FamilyPosition) {
FamilyPosition["ROOT"] = "ROOT";
FamilyPosition["LEFT"] = "LEFT";
FamilyPosition["RIGHT"] = "RIGHT";
FamilyPosition["ROOT_LEFT"] = "ROOT_LEFT";
FamilyPosition["ROOT_RIGHT"] = "ROOT_RIGHT";
FamilyPosition["ISOLATED"] = "ISOLATED";
FamilyPosition["MAL_NODE"] = "MAL_NODE";
})(FamilyPosition = exports.FamilyPosition || (exports.FamilyPosition = {}));
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
/**
* Enum representing different loop types.
*
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
*/
export declare enum IterationType {
ITERATIVE = "ITERATIVE",
RECURSIVE = "RECURSIVE"
}
export declare enum FamilyPosition {
ROOT = "ROOT",
LEFT = "LEFT",
RIGHT = "RIGHT",
ROOT_LEFT = "ROOT_LEFT",
ROOT_RIGHT = "ROOT_RIGHT",
ISOLATED = "ISOLATED",
MAL_NODE = "MAL_NODE"
}
export type BiTreeDeleteResult<N> = {
deleted: N | null | undefined;
needBalanced: N | null | undefined;
};
import { IterationType } from "../../common";
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;

@@ -31,2 +9,1 @@ export type BinaryTreeNested<K, V, N extends BinaryTreeNode<K, V, N>> = BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;

};
export type NodeDisplayLayout = [string[], number, number, number];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FamilyPosition = exports.IterationType = void 0;
/**
* Enum representing different loop types.
*
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
*/
var IterationType;
(function (IterationType) {
IterationType["ITERATIVE"] = "ITERATIVE";
IterationType["RECURSIVE"] = "RECURSIVE";
})(IterationType = exports.IterationType || (exports.IterationType = {}));
var FamilyPosition;
(function (FamilyPosition) {
FamilyPosition["ROOT"] = "ROOT";
FamilyPosition["LEFT"] = "LEFT";
FamilyPosition["RIGHT"] = "RIGHT";
FamilyPosition["ROOT_LEFT"] = "ROOT_LEFT";
FamilyPosition["ROOT_RIGHT"] = "ROOT_RIGHT";
FamilyPosition["ISOLATED"] = "ISOLATED";
FamilyPosition["MAL_NODE"] = "MAL_NODE";
})(FamilyPosition = exports.FamilyPosition || (exports.FamilyPosition = {}));
import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
import { BSTOptions } from "./bst";
import type { BSTOptions } from "./bst";
export declare enum RBTNColor {

@@ -4,0 +4,0 @@ RED = 1,

import { TreeMultimap, TreeMultimapNode } from '../../../data-structures';
import { AVLTreeOptions } from './avl-tree';
import type { AVLTreeOptions } from './avl-tree';
export type TreeMultimapNodeNested<K, V> = TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type TreeMultimapNested<K, V, N extends TreeMultimapNode<K, V, N>> = TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type TreeMultimapOptions<K> = Omit<AVLTreeOptions<K>, 'isMergeDuplicatedNodeByKey'> & {};
{
"name": "red-black-tree-typed",
"version": "1.49.0",
"version": "1.49.1",
"description": "RedBlackTree. Javascript & Typescript Data Structure.",

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

"dependencies": {
"data-structure-typed": "^1.48.9"
"data-structure-typed": "^1.49.1"
}
}

@@ -13,7 +13,8 @@ /**

AVLTreeOptions,
BiTreeDeleteResult,
BSTNodeKeyOrNode,
BTNodeExemplar
BinaryTreeDeleteResult,
BSTNKeyOrNode,
BTNCallback,
BTNExemplar,
BTNKeyOrNode
} from '../../types';
import { BTNCallback, BTNodeKeyOrNode } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -38,3 +39,2 @@

* 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
* 8. Memory Overhead: Stores balance factors (or heights) at each node, leading to slightly higher memory usage compared to a regular BST.
*/

@@ -47,3 +47,3 @@ export class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, N, TREE> = AVLTree<K, V, N, AVLTreeNested<K, V, N>>>

* The constructor function initializes an AVLTree object with optional elements and options.
* @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
* @param [elements] - The `elements` parameter is an optional iterable of `BTNExemplar<K, V, N>`
* objects. It represents a collection of elements that will be added to the AVL tree during

@@ -55,3 +55,3 @@ * initialization.

*/
constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<AVLTreeOptions<K>>) {
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<AVLTreeOptions<K>>) {
super([], options);

@@ -90,6 +90,6 @@ if (elements) super.addMany(elements);

* The function checks if an exemplar is an instance of AVLTreeNode.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the AVLTreeNode class.
*/
override isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N {
override isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N {
return exemplar instanceof AVLTreeNode;

@@ -104,3 +104,3 @@ }

*/
override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
override isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K {
return !(potentialKey instanceof AVLTreeNode)

@@ -127,3 +127,3 @@ }

*/
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
override add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V): N | undefined {
if (keyOrNodeOrEntry === null) return undefined;

@@ -153,3 +153,3 @@ const inserted = super.add(keyOrNodeOrEntry, value);

* parameter of type `N
* @returns The method is returning an array of `BiTreeDeleteResult<N>`.
* @returns The method is returning an array of `BinaryTreeDeleteResult<N>`.
*/

@@ -159,3 +159,3 @@ override delete<C extends BTNCallback<N>>(

callback: C = this._defaultOneParamCallback as C
): BiTreeDeleteResult<N>[] {
): BinaryTreeDeleteResult<N>[] {
if ((identifier as any) instanceof AVLTreeNode) callback = (node => node) as C;

@@ -182,3 +182,3 @@ const deletedResults = super.delete(identifier, callback);

*/
protected override _swapProperties(srcNode: BSTNodeKeyOrNode<K, N>, destNode: BSTNodeKeyOrNode<K, N>): N | undefined {
protected override _swapProperties(srcNode: BSTNKeyOrNode<K, N>, destNode: BSTNKeyOrNode<K, N>): N | undefined {
srcNode = this.ensureNode(srcNode);

@@ -185,0 +185,0 @@ destNode = this.ensureNode(destNode);

@@ -10,10 +10,11 @@ /**

BSTNested,
BSTNodeKeyOrNode,
BSTNKeyOrNode,
BSTNodeNested,
BSTOptions,
BTNCallback,
BTNodeExemplar,
BTNExemplar,
BTNKeyOrNode,
BTNodePureExemplar
} from '../../types';
import { BSTVariant, BTNodeKeyOrNode, CP, IterationType } from '../../types';
import { BSTVariant, CP, IterationType } from '../../types';
import { BinaryTree, BinaryTreeNode } from './binary-tree';

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

* the tree with optional elements and options.
* @param [elements] - An optional iterable of BTNodeExemplar objects that will be added to the
* @param [elements] - An optional iterable of BTNExemplar objects that will be added to the
* binary search tree.

@@ -97,3 +98,3 @@ * @param [options] - The `options` parameter is an optional object that can contain additional

*/
constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<BSTOptions<K>>) {
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<BSTOptions<K>>) {
super([], options);

@@ -153,6 +154,6 @@

* The function checks if an exemplar is an instance of BSTNode.
* @param exemplar - The `exemplar` parameter is a variable of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is a variable of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the BSTNode class.
*/
override isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N {
override isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N {
return exemplar instanceof BSTNode;

@@ -165,3 +166,3 @@ }

* otherwise it returns undefined.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the

@@ -171,3 +172,3 @@ * `exemplarToNode` function. It represents the value associated with the exemplar node.

*/
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
override exemplarToNode(exemplar: BTNExemplar<K, V, N>, value?: V): N | undefined {
let node: N | undefined;

@@ -210,3 +211,3 @@ if (exemplar === null || exemplar === undefined) {

*/
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
override add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V): N | undefined {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);

@@ -283,3 +284,3 @@ if (newNode === undefined) return;

override addMany(
keysOrNodesOrEntries: Iterable<BTNodeExemplar<K, V, N>>,
keysOrNodesOrEntries: Iterable<BTNExemplar<K, V, N>>,
values?: Iterable<V | undefined>,

@@ -308,3 +309,3 @@ isBalanceAdd = true,

const isRealBTNExemplar = (kve: BTNodeExemplar<K, V, N>): kve is BTNodePureExemplar<K, V, N> => {
const isRealBTNExemplar = (kve: BTNExemplar<K, V, N>): kve is BTNodePureExemplar<K, V, N> => {
if (kve === undefined || kve === null) return false;

@@ -391,3 +392,3 @@ return !(this.isEntry(kve) && (kve[0] === undefined || kve[0] === null));

*/
lastKey(beginRoot: BSTNodeKeyOrNode<K, N> = this.root): K | undefined {
lastKey(beginRoot: BSTNKeyOrNode<K, N> = this.root): K | undefined {
let current = this.ensureNode(beginRoot);

@@ -461,3 +462,3 @@ if (!current) return undefined;

*/
override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
override isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K {
return !(potentialKey instanceof BSTNode)

@@ -480,3 +481,3 @@ }

*/
override ensureNode(key: BSTNodeKeyOrNode<K, N>, iterationType = IterationType.ITERATIVE): N | undefined {
override ensureNode(key: BSTNKeyOrNode<K, N>, iterationType = IterationType.ITERATIVE): N | undefined {
return this.isNotNodeInstance(key) ? this.getNodeByKey(key, iterationType) : key;

@@ -512,3 +513,3 @@ }

onlyOne = false,
beginRoot: BSTNodeKeyOrNode<K, N> = this.root,
beginRoot: BSTNKeyOrNode<K, N> = this.root,
iterationType = this.iterationType

@@ -594,3 +595,3 @@ ): N[] {

lesserOrGreater: CP = CP.lt,
targetNode: BSTNodeKeyOrNode<K, N> = this.root,
targetNode: BSTNKeyOrNode<K, N> = this.root,
iterationType = this.iterationType

@@ -597,0 +598,0 @@ ): ReturnType<C>[] {

@@ -10,7 +10,7 @@ /**

import {
BiTreeDeleteResult,
BSTNodeKeyOrNode,
BinaryTreeDeleteResult,
BSTNKeyOrNode,
BTNCallback,
BTNodeExemplar,
BTNodeKeyOrNode,
BTNExemplar,
BTNKeyOrNode,
IterationType,

@@ -24,3 +24,2 @@ RBTNColor,

import { IBinaryTree } from '../../interfaces';
import { BinaryTreeNode } from './binary-tree';

@@ -54,3 +53,3 @@ export class RedBlackTreeNode<K = any, V = any, N extends RedBlackTreeNode<K, V, N> = RedBlackTreeNodeNested<K, V>> extends BSTNode<

* initializes the tree with optional elements and options.
* @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
* @param [elements] - The `elements` parameter is an optional iterable of `BTNExemplar<K, V, N>`
* objects. It represents the initial elements that will be added to the RBTree during its

@@ -63,3 +62,3 @@ * construction. If this parameter is provided, the `addMany` method is called to add all the

*/
constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<RBTreeOptions<K>>) {
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<RBTreeOptions<K>>) {
super([], options);

@@ -115,7 +114,7 @@

* The function checks if an exemplar is an instance of the RedBlackTreeNode class.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the RedBlackTreeNode
* class.
*/
override isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N {
override isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N {
return exemplar instanceof RedBlackTreeNode;

@@ -130,3 +129,3 @@ }

*/
override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
override isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K {
return !(potentialKey instanceof RedBlackTreeNode)

@@ -137,3 +136,3 @@ }

* The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the

@@ -144,3 +143,3 @@ * `exemplarToNode` function. It represents the value associated with the exemplar node. If a value

*/
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
override exemplarToNode(exemplar: BTNExemplar<K, V, N>, value?: V): N | undefined {
let node: N | undefined;

@@ -184,3 +183,3 @@

*/
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
override add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V): N | undefined {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);

@@ -254,3 +253,3 @@ if (newNode === undefined) return;

* on its identifier. The `callback` function is optional and defaults to `this._defaultOneParam
* @returns an array of `BiTreeDeleteResult<N>`.
* @returns an array of `BinaryTreeDeleteResult<N>`.
*/

@@ -260,4 +259,4 @@ delete<C extends BTNCallback<N>>(

callback: C = this._defaultOneParamCallback as C
): BiTreeDeleteResult<N>[] {
const ans: BiTreeDeleteResult<N>[] = [];
): BinaryTreeDeleteResult<N>[] {
const ans: BinaryTreeDeleteResult<N>[] = [];
if (identifier === null) return ans;

@@ -379,6 +378,6 @@ const helper = (node: N | undefined): void => {

callback: C = this._defaultOneParamCallback as C,
beginRoot: BSTNodeKeyOrNode<K, N> = this.root,
beginRoot: BSTNKeyOrNode<K, N> = this.root,
iterationType = this.iterationType
): N | null | undefined {
if ((identifier as any) instanceof BinaryTreeNode) callback = (node => node) as C;
if ((identifier as any) instanceof RedBlackTreeNode) callback = (node => node) as C;
beginRoot = this.ensureNode(beginRoot);

@@ -385,0 +384,0 @@ return this.getNodes(identifier, callback, true, beginRoot, iterationType)[0] ?? undefined;

@@ -8,11 +8,13 @@ /**

*/
import type { BSTNodeKeyOrNode, BTNodeExemplar, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
import {
BiTreeDeleteResult,
import type {
BinaryTreeDeleteResult,
BSTNKeyOrNode,
BTNCallback,
BTNodeKeyOrNode,
FamilyPosition,
IterationType,
TreeMultimapNested
BTNExemplar,
BTNKeyOrNode,
TreeMultimapNested,
TreeMultimapNodeNested,
TreeMultimapOptions
} from '../../types';
import { FamilyPosition, IterationType } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -52,3 +54,3 @@ import { AVLTree, AVLTreeNode } from './avl-tree';

constructor(elements?: Iterable<BTNodeExemplar<K, V, N>>, options?: Partial<TreeMultimapOptions<K>>) {
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<TreeMultimapOptions<K>>) {
super([], options);

@@ -89,7 +91,7 @@ if (elements) this.addMany(elements);

* The function checks if an exemplar is an instance of the TreeMultimapNode class.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
* @returns a boolean value indicating whether the exemplar is an instance of the TreeMultimapNode
* class.
*/
override isNode(exemplar: BTNodeExemplar<K, V, N>): exemplar is N {
override isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N {
return exemplar instanceof TreeMultimapNode;

@@ -104,3 +106,3 @@ }

*/
override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
override isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K {
return !(potentialKey instanceof TreeMultimapNode)

@@ -111,3 +113,3 @@ }

* The function `exemplarToNode` converts an exemplar object into a node object.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, which means it
* can be one of the following:

@@ -121,3 +123,3 @@ * @param {V} [value] - The `value` parameter is an optional argument that represents the value

*/
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V, count = 1): N | undefined {
override exemplarToNode(exemplar: BTNExemplar<K, V, N>, value?: V, count = 1): N | undefined {
let node: N | undefined;

@@ -164,3 +166,3 @@ if (exemplar === undefined || exemplar === null) {

*/
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count = 1): N | undefined {
override add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V, count = 1): N | undefined {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, value, count);

@@ -192,3 +194,3 @@ if (newNode === undefined) return;

*/
override addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<K, V, N>>): (N | undefined)[] {
override addMany(keysOrNodesOrEntries: Iterable<BTNExemplar<K, V, N>>): (N | undefined)[] {
return super.addMany(keysOrNodesOrEntries);

@@ -273,3 +275,3 @@ }

* decremented by 1 and
* @returns an array of `BiTreeDeleteResult<N>`.
* @returns an array of `BinaryTreeDeleteResult<N>`.
*/

@@ -280,4 +282,4 @@ override delete<C extends BTNCallback<N>>(

ignoreCount = false
): BiTreeDeleteResult<N>[] {
const deletedResult: BiTreeDeleteResult<N>[] = [];
): BinaryTreeDeleteResult<N>[] {
const deletedResult: BinaryTreeDeleteResult<N>[] = [];
if (!this.root) return deletedResult;

@@ -383,3 +385,3 @@

*/
protected override _addTo(newNode: N | undefined, parent: BSTNodeKeyOrNode<K, N>): N | undefined {
protected override _addTo(newNode: N | undefined, parent: BSTNKeyOrNode<K, N>): N | undefined {
parent = this.ensureNode(parent);

@@ -419,3 +421,3 @@ if (parent) {

*/
protected override _swapProperties(srcNode: BSTNodeKeyOrNode<K, N>, destNode: BSTNodeKeyOrNode<K, N>): N | undefined {
protected override _swapProperties(srcNode: BSTNKeyOrNode<K, N>, destNode: BSTNKeyOrNode<K, N>): N | undefined {
srcNode = this.ensureNode(srcNode);

@@ -422,0 +424,0 @@ destNode = this.ensureNode(destNode);

@@ -8,9 +8,8 @@ /**

*/
import type { DijkstraResult, EntryCallback, VertexKey } from '../../types';
import { uuidV4 } from '../../utils';
import { PriorityQueue } from '../priority-queue';
import type { DijkstraResult, VertexKey } from '../../types';
import { EntryCallback } from "../../types";
import { IterableEntryBase } from "../base";
import { IGraph } from '../../interfaces';
import { Heap } from '../heap';
import { Queue } from '../queue';
import { IterableEntryBase } from "../base";

@@ -531,10 +530,6 @@ export abstract class AbstractVertex<V = any> {

src: VO | VertexKey,
dest?: VO | VertexKey | undefined,
getMinDist?: boolean,
genPaths?: boolean
dest: VO | VertexKey | undefined = undefined,
getMinDist: boolean = false,
genPaths: boolean = false
): DijkstraResult<VO> {
if (getMinDist === undefined) getMinDist = false;
if (genPaths === undefined) genPaths = false;
if (dest === undefined) dest = undefined;
let minDist = Infinity;

@@ -680,10 +675,7 @@ let minDest: VO | undefined = undefined;

src: VO | VertexKey,
dest?: VO | VertexKey | undefined,
getMinDist?: boolean,
genPaths?: boolean
dest: VO | VertexKey | undefined = undefined,
getMinDist: boolean = false,
genPaths: boolean = false
): DijkstraResult<VO> {
if (getMinDist === undefined) getMinDist = false;
if (genPaths === undefined) genPaths = false;
if (dest === undefined) dest = undefined;
let minDist = Infinity;

@@ -708,3 +700,3 @@ let minDest: VO | undefined = undefined;

const heap = new PriorityQueue<{ key: number; value: VO }>([], { comparator: (a, b) => a.key - b.key });
const heap = new Heap<{ key: number; value: VO }>([], { comparator: (a, b) => a.key - b.key });
heap.add({ key: 0, value: srcVertex });

@@ -1101,12 +1093,30 @@

const cycles: Map<number, VO[]> = new Map();
if (needCycles) {
let SCCs: Map<number, VO[]> = new Map();
if (SCCs.size < 1) {
SCCs = getSCCs();
}
const visitedMap: Map<VO, boolean> = new Map();
const stack: VO[] = [];
const findCyclesDFS = (cur: VO, parent: VO | undefined) => {
visitedMap.set(cur, true);
stack.push(cur);
SCCs.forEach((SCC, low) => {
if (SCC.length > 1) {
cycles.set(low, SCC);
const neighbors = this.getNeighbors(cur);
for (const neighbor of neighbors) {
if (!visitedMap.get(neighbor)) {
findCyclesDFS(neighbor, cur);
} else if (stack.includes(neighbor) && neighbor !== parent) {
const cycleStartIndex = stack.indexOf(neighbor);
const cycle = stack.slice(cycleStartIndex);
const cycleLow = Math.min(...cycle.map(v => dfnMap.get(v) || Infinity));
cycles.set(cycleLow, cycle);
}
}
stack.pop();
};
vertexMap.forEach(v => {
if (!visitedMap.get(v)) {
findCyclesDFS(v, undefined);
}
});

@@ -1113,0 +1123,0 @@ }

@@ -8,6 +8,6 @@ /**

*/
import { arrayRemove } from '../../utils';
import type { TopologicalStatus, VertexKey } from '../../types';
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
import type { TopologicalStatus, VertexKey } from '../../types';
import { IGraph } from '../../interfaces';
import { arrayRemove } from '../../utils';

@@ -14,0 +14,0 @@ export class DirectedVertex<V = any> extends AbstractVertex<V> {

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

import { MapGraphCoordinate, VertexKey } from '../../types';
import type { MapGraphCoordinate, VertexKey } from '../../types';
import { DirectedEdge, DirectedGraph, DirectedVertex } from './directed-graph';

@@ -3,0 +3,0 @@

@@ -8,6 +8,6 @@ /**

*/
import { arrayRemove } from '../../utils';
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
import type { VertexKey } from '../../types';
import { IGraph } from '../../interfaces';
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
import { arrayRemove } from '../../utils';

@@ -14,0 +14,0 @@ export class UndirectedVertex<V = any> extends AbstractVertex<V> {

@@ -8,7 +8,12 @@ /**

*/
import type { EntryCallback, HashMapLinkedNode, HashMapOptions, HashMapStoreItem } from '../../types';
import { IterableEntryBase } from '../base';
import { isWeakKey, rangeCheck } from '../../utils';
import { EntryCallback, HashMapLinkedNode, HashMapOptions, HashMapStoreItem } from '../../types';
import { IterableEntryBase } from "../base";
/**
* 1. Key-Value Pair Storage: HashMap stores key-value pairs. Each key maps to a value.
* 2. Fast Lookup: It's used when you need to quickly find, insert, or delete elements based on a key.
* 3. Unique Keys: Keys are unique. If you try to insert another entry with the same key, the old entry will be replaced by the new one.
* 4. Unordered Collection: HashMap does not guarantee the order of elements, and the order may change over time.
*/
export class HashMap<K = any, V = any> extends IterableEntryBase<K, V> {

@@ -252,2 +257,7 @@ protected _store: { [key: string]: HashMapStoreItem<K, V> } = {};

/**
* 1. Maintaining the Order of Element Insertion: Unlike HashMap, LinkedHashMap maintains the order in which elements are inserted. Therefore, when you traverse it, elements will be returned in the order they were inserted into the map.
* 2. Based on Hash Table and Linked List: It combines the structures of a hash table and a linked list, using the hash table to ensure fast access, while maintaining the order of elements through the linked list.
* 3. Time Complexity: Similar to HashMap, LinkedHashMap offers constant-time performance for get and put operations in most cases.
*/
export class LinkedHashMap<K = any, V = any> extends IterableEntryBase<K, V> {

@@ -406,2 +416,9 @@

hasValue(value: V): boolean {
for (const [, elementValue] of this) {
if (elementValue === value) return true;
}
return false;
}
setMany(entries: Iterable<[K, V]>): void {

@@ -408,0 +425,0 @@ for (const entry of entries) {

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

export class HashTableNode<K, V> {
import type { HashFunction } from '../../types';
export class HashTableNode<K = any, V = any> {
key: K;

@@ -22,4 +24,2 @@ value: V;

import { HashFunction } from '../../types';
export class HashTable<K = any, V = any> {

@@ -26,0 +26,0 @@ protected static readonly DEFAULT_CAPACITY = 16;

@@ -8,6 +8,17 @@ /**

import type { Comparator, DFSOrderPattern, ElementCallback } from '../../types';
import { HeapOptions } from "../../types";
import { IterableElementBase } from "../base";
import type { Comparator, DFSOrderPattern, ElementCallback, HeapOptions } from '../../types';
import { IterableElementBase } from '../base';
/**
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
* 2. Heap Properties: Each node in a heap follows a specific order property, which varies depending on the type of heap:
* Max Heap: The value of each parent node is greater than or equal to the value of its children.
* Min Heap: The value of each parent node is less than or equal to the value of its children.
* 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
* 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
* 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
* 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
* 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
*/
export class Heap<E = any> extends IterableElementBase<E> {

@@ -14,0 +25,0 @@ options: HeapOptions<E>;

@@ -8,6 +8,15 @@ /**

*/
import type { HeapOptions } from '../../types';
import { Heap } from './heap';
import type { HeapOptions } from '../../types';
/**
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
* 2. Heap Properties: The value of each parent node is greater than or equal to the value of its children.
* 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
* 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
* 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
* 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
* 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
*/
export class MaxHeap<E = any> extends Heap<E> {

@@ -14,0 +23,0 @@ constructor(

@@ -8,6 +8,15 @@ /**

*/
import type { HeapOptions } from '../../types';
import { Heap } from './heap';
import type { HeapOptions } from '../../types';
/**
* 1. Complete Binary Tree: Heaps are typically complete binary trees, meaning every level is fully filled except possibly for the last level, which has nodes as far left as possible.
* 2. Heap Properties: The value of each parent node is less than or equal to the value of its children.
* 3. Root Node Access: In a heap, the largest element (in a max heap) or the smallest element (in a min heap) is always at the root of the tree.
* 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).
* 5. Managing Dynamic Data Sets: Heaps effectively manage dynamic data sets, especially when frequent access to the largest or smallest elements is required.
* 6. Non-linear Search: While a heap allows rapid access to its largest or smallest element, it is less efficient for other operations, such as searching for a specific element, as it is not designed for these tasks.
* 7. Efficient Sorting Algorithms: For example, heap sort. Heap sort uses the properties of a heap to sort elements.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
*/
export class MinHeap<E = any> extends Heap<E> {

@@ -14,0 +23,0 @@ constructor(

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

import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
/**

@@ -11,2 +8,5 @@ * data-structure-typed

*/
import type { ElementCallback } from '../../types';
import { IterableElementBase } from '../base';
export class DoublyLinkedListNode<E = any> {

@@ -29,2 +29,8 @@ value: E;

/**
* 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.
* 2. Bidirectional Traversal: Unlike singly linked lists, doubly linked lists can be easily traversed forwards or backwards. This makes insertions and deletions in the list more flexible and efficient.
* 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.
* 4. High Efficiency in Insertion and Deletion: Adding or removing elements in a linked list does not require moving other elements, making these operations more efficient than in arrays.
*/
export class DoublyLinkedList<E = any> extends IterableElementBase<E> {

@@ -31,0 +37,0 @@ /**

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

import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
/**

@@ -11,2 +8,5 @@ * data-structure-typed

*/
import type { ElementCallback } from "../../types";
import { IterableElementBase } from "../base";
export class SinglyLinkedListNode<E = any> {

@@ -13,0 +13,0 @@ value: E;

@@ -8,4 +8,4 @@ /**

*/
import type { PriorityQueueOptions } from '../../types';
import { PriorityQueue } from './priority-queue';
import type { PriorityQueueOptions } from '../../types';

@@ -12,0 +12,0 @@ export class MaxPriorityQueue<E = any> extends PriorityQueue<E> {

@@ -8,4 +8,4 @@ /**

*/
import type { PriorityQueueOptions } from '../../types';
import { PriorityQueue } from './priority-queue';
import type { PriorityQueueOptions } from '../../types';

@@ -12,0 +12,0 @@ export class MinPriorityQueue<E = any> extends PriorityQueue<E> {

@@ -8,6 +8,13 @@ /**

*/
import type { PriorityQueueOptions } from '../../types';
import { Heap } from '../heap';
import { PriorityQueueOptions } from '../../types';
/**
* 1. Element Priority: In a PriorityQueue, elements are sorted according to their priority. Each dequeue (element removal) operation removes the element with the highest priority. The priority can be determined based on the natural ordering of the elements or through a provided comparator (Comparator).
* 2. Heap-Based Implementation: PriorityQueue is typically implemented using a binary heap, allowing both insertion and removal operations to be completed in O(log n) time, where n is the number of elements in the queue.
* 3. Task Scheduling: In systems where tasks need to be processed based on the urgency of tasks rather than the order of arrival.
* 4. Dijkstra's Algorithm: In shortest path algorithms for graphs, used to select the next shortest edge to visit.
* 5. Huffman Coding: Used to select the smallest node combination when constructing a Huffman tree.
* 6. Kth Largest Element in a Data Stream: Used to maintain a min-heap of size K for quickly finding the Kth largest element in stream data
*/
export class PriorityQueue<E = any> extends Heap<E> {

@@ -14,0 +21,0 @@ constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>) {

@@ -8,15 +8,13 @@ /**

*/
import { ElementCallback, IterableWithSizeOrLength } from "../../types";
import type { ElementCallback, IterableWithSizeOrLength } from "../../types";
import { IterableElementBase } from "../base";
import { calcMinUnitsRequired, rangeCheck } from "../../utils";
import { IterableElementBase } from "../base";
/**
* Deque can provide random access with O(1) time complexity
* Deque is usually more compact and efficient in memory usage because it does not require additional space to store pointers.
* Deque may experience performance jitter, but DoublyLinkedList will not
* Deque is implemented using a dynamic array. Inserting or deleting beyond both ends of the array may require moving elements or reallocating space.
* 1. Operations at Both Ends: Supports adding and removing elements at both the front and back of the queue. This allows it to be used as a stack (last in, first out) and a queue (first in, first out).
* 2. Efficient Random Access: Being based on an array, it offers fast random access capability, allowing constant time access to any element.
* 3. Continuous Memory Allocation: Since it is based on an array, all elements are stored contiguously in memory, which can bring cache friendliness and efficient memory access.
* 4. Efficiency: Adding and removing elements at both ends of a deque is usually very fast. However, when the dynamic array needs to expand, it may involve copying the entire array to a larger one, and this operation has a time complexity of O(n).
* 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
*/
export class Deque<E> extends IterableElementBase<E> {

@@ -23,0 +21,0 @@ protected _bucketFirst = 0;

@@ -6,6 +6,15 @@ /**

*/
import type { ElementCallback } from '../../types';
import { IterableElementBase } from "../base";
import { SinglyLinkedList } from '../linked-list';
import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
/**
* 1. First In, First Out (FIFO): The core feature of a queue is its first in, first out nature. The element added to the queue first will be the one to be removed first.
* 2. Operations: The main operations include enqueue (adding an element to the end of the queue) and dequeue (removing and returning the element at the front of the queue). Typically, there is also a peek operation (looking at the front element without removing it).
* 3. Uses: Queues are commonly used to manage a series of tasks or elements that need to be processed in order. For example, managing task queues in a multi-threaded environment, or in algorithms for data structures like trees and graphs for breadth-first search.
* 4. Task Scheduling: Managing the order of task execution in operating systems or applications.
* 5. Data Buffering: Acting as a buffer for data packets in network communication.
* 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store nodes that are to be visited.
* 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
*/
export class Queue<E = any> extends IterableElementBase<E> {

@@ -183,3 +192,3 @@ /**

enqueue(value: E) {
this.push(value);
return this.push(value);
}

@@ -351,2 +360,8 @@

/**
* 1. First In, First Out (FIFO) Strategy: Like other queue implementations, LinkedListQueue follows the first in, first out principle, meaning the element that is added to the queue first will be the first to be removed.
* 2. Based on Linked List: LinkedListQueue uses a linked list to store elements. Each node in the linked list contains data and a pointer to the next node.
* 3. Memory Usage: Since each element requires additional space to store a pointer to the next element, linked lists may use more memory compared to arrays.
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
*/
export class LinkedListQueue<E = any> extends SinglyLinkedList<E> {

@@ -353,0 +368,0 @@ /**

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

import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
/**
* data-structure-typed
*
* @author Tyler Zeng
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { ElementCallback } from '../../types';
import { IterableElementBase } from '../base';
/**
* @license MIT
* @copyright Tyler Zeng <zrwusa@gmail.com>
* @class
* 1. Last In, First Out (LIFO): The core characteristic of a stack is its last in, first out nature, meaning the last element added to the stack will be the first to be removed.
* 2. Uses: Stacks are commonly used for managing a series of tasks or elements that need to be processed in a last in, first out manner. They are widely used in various scenarios, such as in function calls in programming languages, evaluation of arithmetic expressions, and backtracking algorithms.
* 3. Performance: Stack operations are typically O(1) in time complexity, meaning that regardless of the stack's size, adding, removing, and viewing the top element are very fast operations.
* 4. Function Calls: In most modern programming languages, the records of function calls are managed through a stack. When a function is called, its record (including parameters, local variables, and return address) is 'pushed' into the stack. When the function returns, its record is 'popped' from the stack.
* 5. Expression Evaluation: Used for the evaluation of arithmetic or logical expressions, especially when dealing with parenthesis matching and operator precedence.
* 6. Backtracking Algorithms: In problems where multiple branches need to be explored but only one branch can be explored at a time, stacks can be used to save the state at each branching point.
*/

@@ -118,3 +128,3 @@ export class Stack<E = any> extends IterableElementBase<E> {

return this.elements.pop() || undefined;
return this.elements.pop();
}

@@ -121,0 +131,0 @@

@@ -8,6 +8,5 @@ /**

*/
import type { ElementCallback } from '../../types';
import { IterableElementBase } from '../base';
import { IterableElementBase } from "../base";
import { ElementCallback } from "../../types";
/**

@@ -30,3 +29,13 @@ * TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,

/**
* Trie represents a Trie data structure. It provides basic Trie operations and additional methods.
* 1. Node Structure: Each node in a Trie represents a string (or a part of a string). The root node typically represents an empty string.
* 2. Child Node Relationship: Each node's children represent the strings that can be formed by adding one character to the string at the current node. For example, if a node represents the string 'ca', one of its children might represent 'cat'.
* 3. Fast Retrieval: Trie allows retrieval in O(m) time complexity, where m is the length of the string to be searched.
* 4. Space Efficiency: Trie can store a large number of strings very space-efficiently, especially when these strings share common prefixes.
* 5. Autocomplete and Prediction: Trie can be used for implementing autocomplete and word prediction features, as it can quickly find all strings with a common prefix.
* 6. Sorting: Trie can be used to sort a set of strings in alphabetical order.
* 7. String Retrieval: For example, searching for a specific string in a large set of strings.
* 8. Autocomplete: Providing recommended words or phrases as a user types.
* 9. Spell Check: Checking the spelling of words.
* 10. IP Routing: Used in certain types of IP routing algorithms.
* 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data."
*/

@@ -33,0 +42,0 @@ export class Trie extends IterableElementBase<string> {

import { BinaryTree, BinaryTreeNode } from '../data-structures';
import {
BinaryTreeDeleteResult,
BinaryTreeNested,
BinaryTreeNodeNested,
BinaryTreeOptions,
BiTreeDeleteResult,
BTNCallback,
BTNodeExemplar,
BTNExemplar,
} from '../types';

@@ -16,7 +16,7 @@

add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | null | undefined;
add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V, count?: number): N | null | undefined;
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>): (N | null | undefined)[];
addMany(nodes: Iterable<BTNExemplar<K, V, N>>, values?: Iterable<V | undefined>): (N | null | undefined)[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BiTreeDeleteResult<N>[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<N>[];
}

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

export type Comparator<K> = (a: K, b: K) => number;
export enum BSTVariant {

@@ -8,6 +6,2 @@ MIN = 'MIN',

export type DFSOrderPattern = 'pre' | 'in' | 'post';
export type BTNCallback<N, D = any> = (node: N) => D;
export enum CP {

@@ -19,2 +13,31 @@ lt = 'lt',

/**
* Enum representing different loop types.
*
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
*/
export enum IterationType {
ITERATIVE = 'ITERATIVE',
RECURSIVE = 'RECURSIVE'
}
export enum FamilyPosition {
ROOT = 'ROOT',
LEFT = 'LEFT',
RIGHT = 'RIGHT',
ROOT_LEFT = 'ROOT_LEFT',
ROOT_RIGHT = 'ROOT_RIGHT',
ISOLATED = 'ISOLATED',
MAL_NODE = 'MAL_NODE'
}
export type Comparator<K> = (a: K, b: K) => number;
export type DFSOrderPattern = 'pre' | 'in' | 'post';
export type NodeDisplayLayout = [string[], number, number, number];
export type BTNCallback<N, D = any> = (node: N) => D;
export interface IterableWithSize<T> extends Iterable<T> {

@@ -32,12 +55,14 @@ size: number | ((...args: any[]) => number);

export type BTNodeEntry<K, V> = [K | null | undefined, V | undefined];
export type BTNEntry<K, V> = [K | null | undefined, V | undefined];
export type BTNodeKeyOrNode<K, N> = K | null | undefined | N;
export type BTNKeyOrNode<K, N> = K | null | undefined | N;
export type BTNodeExemplar<K, V, N> = BTNodeEntry<K, V> | BTNodeKeyOrNode<K, N>
export type BTNExemplar<K, V, N> = BTNEntry<K, V> | BTNKeyOrNode<K, N>
export type BTNodePureExemplar<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>
export type BTNodePureKeyOrNode<K, N> = K | N;
export type BSTNodeKeyOrNode<K, N> = K | undefined | N;
export type BTNodePureExemplar<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>;
export type BSTNKeyOrNode<K, N> = K | undefined | N;
export type BinaryTreeDeleteResult<N> = { deleted: N | null | undefined; needBalanced: N | null | undefined };

@@ -8,3 +8,2 @@ import { AVLTree, AVLTreeNode } from '../../../data-structures';

export type AVLTreeOptions<K> = BSTOptions<K> & {};
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
import { IterationType } from "../../common";
/**
* Enum representing different loop types.
*
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
*/
export enum IterationType {
ITERATIVE = 'ITERATIVE',
RECURSIVE = 'RECURSIVE'
}
export enum FamilyPosition {
ROOT = 'ROOT',
LEFT = 'LEFT',
RIGHT = 'RIGHT',
ROOT_LEFT = 'ROOT_LEFT',
ROOT_RIGHT = 'ROOT_RIGHT',
ISOLATED = 'ISOLATED',
MAL_NODE = 'MAL_NODE'
}
export type BiTreeDeleteResult<N> = { deleted: N | null | undefined; needBalanced: N | null | undefined };
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

@@ -35,3 +12,1 @@

}
export type NodeDisplayLayout = [string[], number, number, number];

@@ -5,3 +5,2 @@ import { BST, BSTNode } from '../../../data-structures';

// prettier-ignore
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

@@ -8,0 +7,0 @@

import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
import { BSTOptions } from "./bst";
import type { BSTOptions } from "./bst";

@@ -4,0 +4,0 @@ export enum RBTNColor { RED = 1, BLACK = 0}

import { TreeMultimap, TreeMultimapNode } from '../../../data-structures';
import { AVLTreeOptions } from './avl-tree';
import type { AVLTreeOptions } from './avl-tree';

@@ -4,0 +4,0 @@ export type TreeMultimapNodeNested<K, V> = TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc