Socket
Socket
Sign inDemoInstall

min-heap-typed

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

min-heap-typed - npm Package Compare versions

Comparing version 1.51.9 to 1.52.0

dist/data-structures/base/iterable-element-base.d.ts

3

dist/data-structures/base/index.d.ts

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

export * from './iterable-base';
export * from './iterable-entry-base';
export * from './iterable-element-base';

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

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./iterable-base"), exports);
__exportStar(require("./iterable-entry-base"), exports);
__exportStar(require("./iterable-element-base"), exports);

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

*/
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, Comparable, IterationType, KeyOrNodeOrEntry } from '../../types';
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, IterationType, KeyOrNodeOrEntry } from '../../types';
import { BTNEntry } from '../../types';
import { IBinaryTree } from '../../interfaces';
import { AVLTree, AVLTreeNode } from './avl-tree';
export declare class AVLTreeMultiMapNode<K extends Comparable, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> {
export declare class AVLTreeMultiMapNode<K = any, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> {
/**

@@ -41,3 +41,3 @@ * The constructor function initializes a BinaryTreeNode object with a key, value, and count.

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

@@ -44,0 +44,0 @@ * The constructor initializes a new AVLTreeMultiMap object with optional initial elements.

@@ -9,6 +9,6 @@ /**

import { BST, BSTNode } from './bst';
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, Comparable, KeyOrNodeOrEntry } from '../../types';
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry } from '../../types';
import { BTNEntry } from '../../types';
import { IBinaryTree } from '../../interfaces';
export declare class AVLTreeNode<K extends Comparable, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
/**

@@ -45,3 +45,3 @@ * The constructor function initializes a new instance of a class with a key and an optional value,

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

@@ -48,0 +48,0 @@ * This is a constructor function for an AVLTree class that initializes the tree with keys, nodes,

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

*/
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNCallback, BTNEntry, Comparable, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, KeyOrNodeOrEntry, NodeDisplayLayout } from '../../types';
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BinaryTreePrintOptions, BTNCallback, BTNEntry, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, KeyOrNodeOrEntry, NodeDisplayLayout } from '../../types';
import { IBinaryTree } from '../../interfaces';

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

*/
export declare class BinaryTreeNode<K extends Comparable, V = any, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>> {
export declare class BinaryTreeNode<K = any, V = any, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>> {
key: K;

@@ -70,7 +70,7 @@ value?: V;

*/
export declare class BinaryTree<K extends Comparable, V = any, R = BTNEntry<K, V>, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTree<K, V, R, NODE, BinaryTreeNested<K, V, R, NODE>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, R, NODE, TREE> {
export declare class BinaryTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTree<K, V, R, NODE, BinaryTreeNested<K, V, R, NODE>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, R, NODE, TREE> {
iterationType: IterationType;
/**
* The constructor function initializes a binary tree object with optional keysOrNodesOrEntriesOrRawElements and options.
* @param [keysOrNodesOrEntriesOrRawElements] - An optional iterable of KeyOrNodeOrEntry objects. These objects represent the
* @param [keysOrNodesOrEntriesOrRawElements] - Optional iterable of KeyOrNodeOrEntry objects. These objects represent the
* nodes to be added to the binary tree.

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

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

*/
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, Comparable, Comparator, CP, DFSOrderPattern, IterationType, KeyOrNodeOrEntry } from '../../types';
import type { BSTNested, BSTNKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, Comparator, CP, DFSOrderPattern, IterationType, KeyOrNodeOrEntry } from '../../types';
import { BTNEntry } from '../../types';
import { BinaryTree, BinaryTreeNode } from './binary-tree';
import { IBinaryTree } from '../../interfaces';
export declare class BSTNode<K extends Comparable, V = any, NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V>> extends BinaryTreeNode<K, V, NODE> {
export declare class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V>> extends BinaryTreeNode<K, V, NODE> {
parent?: NODE;

@@ -51,3 +51,3 @@ constructor(key: K, value?: V);

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

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

isAVLBalanced(iterationType?: IterationType): boolean;
/**
* Time complexity: O(n)
* Space complexity: O(n)
*/
protected _DEFAULT_COMPARATOR: (a: K, b: K) => number;
/**
* Time complexity: O(n)
* Space complexity: O(n)
*/
protected _comparator: Comparator<K>;

@@ -365,0 +357,0 @@ /**

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

this._root = undefined;
/**
* Time complexity: O(n)
* Space complexity: O(n)
*/
this._DEFAULT_COMPARATOR = (a, b) => {
if (typeof a === 'object' && typeof b === 'object' && this.comparator === this._DEFAULT_COMPARATOR) {
throw TypeError('When comparing two object types, it is necessary to customize a [comparator] function of options parameter during the instantiation of the data structure.');
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(`When comparing object types, a custom comparator must be defined in the constructor's options parameter.`);
}

@@ -88,6 +84,2 @@ if (a > b)

};
/**
* Time complexity: O(n)
* Space complexity: O(n)
*/
this._comparator = this._DEFAULT_COMPARATOR;

@@ -94,0 +86,0 @@ if (options) {

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

import type { BinaryTreeDeleteResult, BTNCallback, Comparable, CRUD, KeyOrNodeOrEntry, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
import type { BinaryTreeDeleteResult, BTNCallback, CRUD, KeyOrNodeOrEntry, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
import { BTNEntry } from '../../types';
import { BST, BSTNode } from './bst';
import { IBinaryTree } from '../../interfaces';
export declare class RedBlackTreeNode<K extends Comparable, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
/**

@@ -30,3 +30,3 @@ * The constructor function initializes a Red-Black Tree Node with a key, an optional value, and a

}
export declare class RedBlackTree<K extends Comparable, V = any, R = BTNEntry<K, V>, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, TREE extends RedBlackTree<K, V, R, NODE, TREE> = RedBlackTree<K, V, R, NODE, RedBlackTreeNested<K, V, R, NODE>>> extends BST<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, TREE extends RedBlackTree<K, V, R, NODE, TREE> = RedBlackTree<K, V, R, NODE, RedBlackTreeNested<K, V, R, NODE>>> extends BST<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
/**

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

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

*/
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, Comparable, IterationType, KeyOrNodeOrEntry, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, IterationType, KeyOrNodeOrEntry, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
import { BTNEntry } from '../../types';
import { IBinaryTree } from '../../interfaces';
import { RedBlackTree, RedBlackTreeNode } from './rb-tree';
export declare class TreeMultiMapNode<K extends Comparable, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
/**

@@ -40,3 +40,3 @@ * The constructor function initializes a Red-Black Tree node with a key, value, count, and color.

}
export declare class TreeMultiMap<K extends Comparable, V = any, R = BTNEntry<K, V>, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, TREE extends TreeMultiMap<K, V, R, NODE, TREE> = TreeMultiMap<K, V, R, NODE, TreeMultiMapNested<K, V, R, NODE>>> extends RedBlackTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, TREE extends TreeMultiMap<K, V, R, NODE, TREE> = TreeMultiMap<K, V, R, NODE, TreeMultiMapNested<K, V, R, NODE>>> extends RedBlackTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
/**

@@ -43,0 +43,0 @@ * The constructor function initializes a TreeMultiMap object with optional initial data.

@@ -153,3 +153,3 @@ /**

*/
map<U>(callbackfn: EntryCallback<K, V, U>, thisArg?: any): HashMap<K, U>;
map<VM>(callbackfn: EntryCallback<K, V, VM>, thisArg?: any): HashMap<K, VM>;
/**

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

*/
map<NV>(callback: EntryCallback<K, V, NV>, thisArg?: any): LinkedHashMap<K, NV>;
map<VM>(callback: EntryCallback<K, V, VM>, thisArg?: any): LinkedHashMap<K, VM>;
/**

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

@@ -19,26 +19,23 @@ /**

* 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.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prime's minimum-spanning tree algorithm, which use heaps to improve performance.
*/
export declare class Heap<E = any> extends IterableElementBase<E> {
export declare class Heap<E = any, R = any> extends IterableElementBase<E, R, Heap<E, R>> {
/**
* The constructor initializes a heap data structure with optional elements and options.
* @param elements - The `elements` parameter is an iterable object that contains the initial
* elements to be added to the heap. It is an optional parameter and if not provided, the heap will
* elements to be added to the heap.
* It is an optional parameter, and if not provided, the heap will
* be initialized as empty.
* @param [options] - The `options` parameter is an optional object that can contain additional
* configuration options for the heap. In this case, it is used to specify a custom comparator
* function for comparing elements in the heap. The comparator function is used to determine the
* configuration options for the heap.
* In this case, it is used to specify a custom comparator
* function for comparing elements in the heap.
* The comparator function is used to determine the
* order of elements in the heap.
*/
constructor(elements?: Iterable<E>, options?: HeapOptions<E>);
protected _comparator: (a: E, b: E) => number;
/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator(): (a: E, b: E) => number;
constructor(elements?: Iterable<E> | Iterable<R>, options?: HeapOptions<E, R>);
protected _elements: E[];
/**
* The function returns an array of elements.
* @returns The elements array is being returned.
* @returns The element array is being returned.
*/

@@ -61,11 +58,6 @@ get elements(): E[];

*/
static heapify<E>(elements: Iterable<E>, options: HeapOptions<E>): Heap<E>;
static heapify<E = any, R = any>(elements: Iterable<E>, options: HeapOptions<E, R>): Heap<E>;
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
* where n is the number of elements in the heap.
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*

@@ -79,9 +71,4 @@ * Insert an element into the heap and maintain the heap properties.

* Space Complexity: O(1)
* where n is the number of elements in the heap.
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @returns The top element or undefined if the heap is empty.

@@ -93,6 +80,2 @@ */

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -115,6 +98,2 @@ * Peek at the top element of the heap without removing it.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -128,6 +107,2 @@ * Clear and add elements of the heap

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(1)
*

@@ -140,9 +115,4 @@ * Use a comparison function to check whether a binary heap contains a specific element.

/**
* Time Complexity: O(n)
* Time Complexity: O(n)
* Space Complexity: O(1)
* The worst-case O(n) This is because, in the worst case, the element to be deleted is located at the end of the heap (not the root), and after deletion, we may need to reorganize the elements by performing a sinkDown operation.
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(1)
*

@@ -160,7 +130,2 @@ * The `delete` function removes an element from an array-like data structure, maintaining the order

* Space Complexity: O(log n)
* where log n is the height of the heap.
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(log n)
*

@@ -175,6 +140,2 @@ * Depth-first search (DFS) method, different traversal orders can be selected。

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -188,6 +149,2 @@ * Convert the heap to an array.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -197,10 +154,6 @@ * Clone the heap, creating a new heap with the same elements.

*/
clone(): Heap<E>;
clone(): Heap<E, R>;
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*

@@ -214,6 +167,2 @@ * Sort the elements in the heap and return them as an array.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*

@@ -226,6 +175,2 @@ * Fix the entire heap to maintain heap properties.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -244,29 +189,33 @@ * The `filter` function creates a new Heap object containing elements that pass a given callback

*/
filter(callback: ElementCallback<E, boolean>, thisArg?: any): Heap<E>;
filter(callback: ElementCallback<E, R, boolean, Heap<E, R>>, thisArg?: any): Heap<E, R>;
/**
* Time Complexity: O(n)
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The callback parameter is a function that will be called for each element in the
* original heap. It takes three arguments: the current element, the index of the current element,
* and the original heap itself. The callback function should return a value of type T, which will be
* added to the mapped heap.
* @param comparator - The `comparator` parameter is a function that is used to compare elements in
* the heap. It takes two arguments, `a` and `b`, and returns a negative number if `a` is less than
* `b`, a positive number if `a` is greater than `b`, or
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used when you want to bind a
* specific object as the context for the callback function. If `thisArg` is not provided,
* `undefined` is used as
* @returns a new instance of the Heap class, which is created using the mapped elements from the
* original Heap.
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `Heap` class with the mapped elements.
*/
map<T>(callback: ElementCallback<E, T>, comparator: Comparator<T>, thisArg?: any): Heap<T>;
map<EM, RM>(callback: ElementCallback<E, R, EM, Heap<E, R>>, comparator: Comparator<EM>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Heap<EM, RM>;
protected _DEFAULT_COMPARATOR: (a: E, b: E) => number;
protected _comparator: Comparator<E>;
/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator(): Comparator<E>;
/**
* The function `_getIterator` returns an iterable iterator for the elements in the class.

@@ -278,6 +227,2 @@ */

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*

@@ -291,6 +236,2 @@ * Float operation to maintain heap properties after adding an element.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*

@@ -365,6 +306,2 @@ * Sinking operation to maintain heap properties after removing the top element.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -379,6 +316,2 @@ * Insert an element into the heap and maintain the heap properties.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -393,6 +326,2 @@ * Insert an element into the heap and maintain the heap properties.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -434,3 +363,3 @@ * Peek at the top element of the heap without removing it.

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @returns The top element or undefined if the heap is empty.

@@ -447,3 +376,3 @@ */

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @returns The top element or undefined if the heap is empty.

@@ -496,4 +425,4 @@ */

* Space Complexity: O(1)
*.
* Remove and return the top element (smallest or largest element) from the heap.
*
* Remove and return the top element (the smallest or largest element) from the heap.
* @param node - The node to be removed.

@@ -511,3 +440,3 @@ * @protected

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @param y

@@ -526,3 +455,3 @@ * @param x

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @protected

@@ -529,0 +458,0 @@ */

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

* 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.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prime's minimum-spanning tree algorithm, which use heaps to improve performance.
*/

@@ -28,20 +28,26 @@ class Heap extends base_1.IterableElementBase {

* @param elements - The `elements` parameter is an iterable object that contains the initial
* elements to be added to the heap. It is an optional parameter and if not provided, the heap will
* elements to be added to the heap.
* It is an optional parameter, and if not provided, the heap will
* be initialized as empty.
* @param [options] - The `options` parameter is an optional object that can contain additional
* configuration options for the heap. In this case, it is used to specify a custom comparator
* function for comparing elements in the heap. The comparator function is used to determine the
* configuration options for the heap.
* In this case, it is used to specify a custom comparator
* function for comparing elements in the heap.
* The comparator function is used to determine the
* order of elements in the heap.
*/
constructor(elements = [], options) {
super();
this._comparator = (a, b) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
super(options);
this._elements = [];
this._DEFAULT_COMPARATOR = (a, b) => {
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(`When comparing object types, a custom comparator must be defined in the constructor's options parameter.`);
}
else {
return a - b;
}
if (a > b)
return 1;
if (a < b)
return -1;
return 0;
};
this._elements = [];
this._comparator = this._DEFAULT_COMPARATOR;
if (options) {

@@ -54,3 +60,6 @@ const { comparator } = options;

for (const el of elements) {
this.add(el);
if (this.toElementFn)
this.add(this.toElementFn(el));
else
this.add(el);
}

@@ -60,11 +69,4 @@ }

/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator() {
return this._comparator;
}
/**
* The function returns an array of elements.
* @returns The elements array is being returned.
* @returns The element array is being returned.
*/

@@ -100,7 +102,2 @@ get elements() {

* Space Complexity: O(1)
* where n is the number of elements in the heap.
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*

@@ -117,9 +114,4 @@ * Insert an element into the heap and maintain the heap properties.

* Space Complexity: O(1)
* where n is the number of elements in the heap.
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @returns The top element or undefined if the heap is empty.

@@ -141,6 +133,2 @@ */

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -169,6 +157,2 @@ * Peek at the top element of the heap without removing it.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -185,6 +169,2 @@ * Clear and add elements of the heap

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(1)
*

@@ -199,9 +179,4 @@ * Use a comparison function to check whether a binary heap contains a specific element.

/**
* Time Complexity: O(n)
* Time Complexity: O(n)
* Space Complexity: O(1)
* The worst-case O(n) This is because, in the worst case, the element to be deleted is located at the end of the heap (not the root), and after deletion, we may need to reorganize the elements by performing a sinkDown operation.
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(1)
*

@@ -235,7 +210,2 @@ * The `delete` function removes an element from an array-like data structure, maintaining the order

* Space Complexity: O(log n)
* where log n is the height of the heap.
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(log n)
*

@@ -275,6 +245,2 @@ * Depth-first search (DFS) method, different traversal orders can be selected。

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -290,6 +256,2 @@ * Convert the heap to an array.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -300,5 +262,3 @@ * Clone the heap, creating a new heap with the same elements.

clone() {
const clonedHeap = new Heap([], { comparator: this.comparator });
clonedHeap._elements = [...this.elements];
return clonedHeap;
return new Heap(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}

@@ -308,6 +268,2 @@ /**

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*

@@ -319,6 +275,6 @@ * Sort the elements in the heap and return them as an array.

const visitedNode = [];
const cloned = this.clone();
const cloned = new Heap(this, { comparator: this.comparator });
while (cloned.size !== 0) {
const top = cloned.poll();
if (top)
if (top !== undefined)
visitedNode.push(top);

@@ -331,6 +287,2 @@ }

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*

@@ -348,6 +300,2 @@ * Fix the entire heap to maintain heap properties.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -367,3 +315,3 @@ * The `filter` function creates a new Heap object containing elements that pass a given callback

filter(callback, thisArg) {
const filteredList = new Heap();
const filteredList = new Heap([], { toElementFn: this.toElementFn, comparator: this.comparator });
let index = 0;

@@ -379,27 +327,24 @@ for (const current of this) {

/**
* Time Complexity: O(n)
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The callback parameter is a function that will be called for each element in the
* original heap. It takes three arguments: the current element, the index of the current element,
* and the original heap itself. The callback function should return a value of type T, which will be
* added to the mapped heap.
* @param comparator - The `comparator` parameter is a function that is used to compare elements in
* the heap. It takes two arguments, `a` and `b`, and returns a negative number if `a` is less than
* `b`, a positive number if `a` is greater than `b`, or
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used when you want to bind a
* specific object as the context for the callback function. If `thisArg` is not provided,
* `undefined` is used as
* @returns a new instance of the Heap class, which is created using the mapped elements from the
* original Heap.
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `Heap` class with the mapped elements.
*/
map(callback, comparator, thisArg) {
const mappedHeap = new Heap([], { comparator: comparator });
map(callback, comparator, toElementFn, thisArg) {
const mappedHeap = new Heap([], { comparator, toElementFn });
let index = 0;

@@ -413,2 +358,9 @@ for (const el of this) {

/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator() {
return this._comparator;
}
/**
* The function `_getIterator` returns an iterable iterator for the elements in the class.

@@ -424,6 +376,2 @@ */

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*

@@ -449,6 +397,2 @@ * Float operation to maintain heap properties after adding an element.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*

@@ -554,6 +498,2 @@ * Sinking operation to maintain heap properties after removing the top element.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -570,6 +510,2 @@ * Insert an element into the heap and maintain the heap properties.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -594,6 +530,2 @@ * Insert an element into the heap and maintain the heap properties.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -664,3 +596,3 @@ * Peek at the top element of the heap without removing it.

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @returns The top element or undefined if the heap is empty.

@@ -679,3 +611,3 @@ */

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @returns The top element or undefined if the heap is empty.

@@ -791,4 +723,4 @@ */

* Space Complexity: O(1)
*.
* Remove and return the top element (smallest or largest element) from the heap.
*
* Remove and return the top element (the smallest or largest element) from the heap.
* @param node - The node to be removed.

@@ -813,3 +745,3 @@ * @protected

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @param y

@@ -835,3 +767,3 @@ * @param x

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @protected

@@ -838,0 +770,0 @@ */

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

*/
import type { HeapOptions } from '../../types';
import type { Comparator, ElementCallback, HeapOptions } from '../../types';
import { Heap } from './heap';

@@ -19,6 +19,52 @@ /**

* 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.
* 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>);
export declare class MaxHeap<E = any, R = any> extends Heap<E, R> {
constructor(elements?: Iterable<E> | Iterable<R>, options?: HeapOptions<E, R>);
/**
* The `clone` function returns a new instance of the `MaxHeap` class with the same properties as the
* current instance.
* @returns The `clone()` method is returning a new instance of the `MaxHeap` class with the same
* properties as the current instance.
*/
clone(): MaxHeap<E, R>;
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MaxHeap object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MaxHeap` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback: ElementCallback<E, R, boolean, MaxHeap<E, R>>, thisArg?: any): MaxHeap<E, R>;
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MaxHeap` class with the mapped elements.
*/
map<EM, RM>(callback: ElementCallback<E, R, EM, MaxHeap<E, R>>, comparator: Comparator<EM>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): MaxHeap<EM, RM>;
}

@@ -13,18 +13,84 @@ "use strict";

* 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.
* 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 {
constructor(elements = [], options = {
comparator: (a, b) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
constructor(elements = [], options) {
super(elements, Object.assign({ comparator: (a, b) => {
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(`When comparing object types, a custom comparator must be defined in the constructor's options parameter.`);
}
if (a < b)
return 1;
if (a > b)
return -1;
return 0;
} }, options));
}
/**
* The `clone` function returns a new instance of the `MaxHeap` class with the same properties as the
* current instance.
* @returns The `clone()` method is returning a new instance of the `MaxHeap` class with the same
* properties as the current instance.
*/
clone() {
return new MaxHeap(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MaxHeap object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MaxHeap` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback, thisArg) {
const filteredList = new MaxHeap([], { toElementFn: this.toElementFn, comparator: this.comparator });
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredList.add(current);
}
else {
return b - a;
}
index++;
}
}) {
super(elements, options);
return filteredList;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MaxHeap` class with the mapped elements.
*/
map(callback, comparator, toElementFn, thisArg) {
const mappedHeap = new MaxHeap([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedHeap.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedHeap;
}
}
exports.MaxHeap = MaxHeap;

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

*/
import type { HeapOptions } from '../../types';
import type { Comparator, ElementCallback, HeapOptions } from '../../types';
import { Heap } from './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.
* 2. MinHeap 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.

@@ -18,7 +18,53 @@ * 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).

* 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.
* 7. Efficient Sorting Algorithms: For example, heap sort. MinHeap 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>);
export declare class MinHeap<E = any, R = any> extends Heap<E, R> {
constructor(elements?: Iterable<E> | Iterable<R>, options?: HeapOptions<E, R>);
/**
* The `clone` function returns a new instance of the `MinHeap` class with the same comparator and
* toElementFn as the original instance.
* @returns The `clone()` method is returning a new instance of the `MinHeap` class with the same
* properties as the current instance.
*/
clone(): MinHeap<E, R>;
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MinHeap object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MinHeap` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback: ElementCallback<E, R, boolean, MinHeap<E, R>>, thisArg?: any): MinHeap<E, R>;
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MinHeap` class with the mapped elements.
*/
map<EM, RM>(callback: ElementCallback<E, R, EM, MinHeap<E, R>>, comparator: Comparator<EM>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): MinHeap<EM, RM>;
}

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

* 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.
* 2. MinHeap 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.

@@ -13,19 +13,76 @@ * 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).

* 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.
* 7. Efficient Sorting Algorithms: For example, heap sort. MinHeap 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 {
constructor(elements = [], options = {
comparator: (a, b) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
constructor(elements = [], options) {
super(elements, options);
}
/**
* The `clone` function returns a new instance of the `MinHeap` class with the same comparator and
* toElementFn as the original instance.
* @returns The `clone()` method is returning a new instance of the `MinHeap` class with the same
* properties as the current instance.
*/
clone() {
return new MinHeap(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MinHeap object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MinHeap` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback, thisArg) {
const filteredList = new MinHeap([], { toElementFn: this.toElementFn, comparator: this.comparator });
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredList.add(current);
}
else {
return a - b;
}
index++;
}
}) {
super(elements, options);
return filteredList;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MinHeap` class with the mapped elements.
*/
map(callback, comparator, toElementFn, thisArg) {
const mappedHeap = new MinHeap([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedHeap.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedHeap;
}
}
exports.MinHeap = MinHeap;

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

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

@@ -64,10 +64,4 @@ export declare class DoublyLinkedListNode<E = any> {

*/
export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
/**
* The constructor initializes a linked list with optional elements.
* @param elements - The `elements` parameter is an optional iterable object that contains the
* initial elements to be added to the data structure. It defaults to an empty array if no elements
* are provided.
*/
constructor(elements?: Iterable<E>);
export declare class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R, DoublyLinkedList<E, R>> {
constructor(elements?: Iterable<E> | Iterable<R>, options?: DoublyLinkedListOptions<E, R>);
protected _head: DoublyLinkedListNode<E> | undefined;

@@ -130,3 +124,3 @@ /**

*/
static fromArray<E>(data: E[]): DoublyLinkedList<E>;
static fromArray<E>(data: E[]): DoublyLinkedList<E, any>;
/**

@@ -399,3 +393,3 @@ * Time Complexity: O(1)

*/
clone(): DoublyLinkedList<E>;
clone(): DoublyLinkedList<E, R>;
/**

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

*/
filter(callback: ElementCallback<E, boolean>, thisArg?: any): DoublyLinkedList<E>;
filter(callback: ElementCallback<E, R, boolean, DoublyLinkedList<E, R>>, thisArg?: any): DoublyLinkedList<E, R>;
/**

@@ -429,19 +423,19 @@ * Time Complexity: O(n)

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new DoublyLinkedList by applying a callback function to each element
* in the original list.
* The `map` function takes a callback function and returns a new DoublyLinkedList with the results
* of applying the callback to each element in the original list.
* @param callback - The callback parameter is a function that will be called for each element in the
* DoublyLinkedList. It takes three arguments: the current element, the index of the current element,
* and the DoublyLinkedList itself. The callback function should return a value that will be added to
* the new DoublyLinkedList that
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new `DoublyLinkedList` object that contains the results
* of applying the provided `callback` function to each element in the original `DoublyLinkedList`
* object.
* original DoublyLinkedList. It takes three arguments: current (the current element being
* processed), index (the index of the current element), and this (the original DoublyLinkedList).
* The callback function should return a value of type
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* convert the raw element (`RR`) to the desired element type (`T`). It takes the raw element as
* input and returns the converted element. If this parameter is not provided, the raw element will
* be used as is.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `DoublyLinkedList` class with elements of type `T` and `RR`.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): DoublyLinkedList<T>;
map<EM, RM>(callback: ElementCallback<E, R, EM, DoublyLinkedList<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): DoublyLinkedList<EM, RM>;
/**

@@ -448,0 +442,0 @@ * The function returns an iterator that iterates over the values of a linked list.

@@ -73,10 +73,4 @@ "use strict";

class DoublyLinkedList extends base_1.IterableElementBase {
/**
* The constructor initializes a linked list with optional elements.
* @param elements - The `elements` parameter is an optional iterable object that contains the
* initial elements to be added to the data structure. It defaults to an empty array if no elements
* are provided.
*/
constructor(elements = []) {
super();
constructor(elements = [], options) {
super(options);
this._head = undefined;

@@ -87,3 +81,7 @@ this._tail = undefined;

for (const el of elements) {
this.push(el);
if (this.toElementFn) {
this.push(this.toElementFn(el));
}
else
this.push(el);
}

@@ -668,3 +666,3 @@ }

clone() {
return new DoublyLinkedList(this.values());
return new DoublyLinkedList(this);
}

@@ -693,3 +691,3 @@ /**

filter(callback, thisArg) {
const filteredList = new DoublyLinkedList();
const filteredList = new DoublyLinkedList([], { toElementFn: this.toElementFn });
let index = 0;

@@ -709,20 +707,20 @@ for (const current of this) {

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new DoublyLinkedList by applying a callback function to each element
* in the original list.
* The `map` function takes a callback function and returns a new DoublyLinkedList with the results
* of applying the callback to each element in the original list.
* @param callback - The callback parameter is a function that will be called for each element in the
* DoublyLinkedList. It takes three arguments: the current element, the index of the current element,
* and the DoublyLinkedList itself. The callback function should return a value that will be added to
* the new DoublyLinkedList that
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new `DoublyLinkedList` object that contains the results
* of applying the provided `callback` function to each element in the original `DoublyLinkedList`
* object.
* original DoublyLinkedList. It takes three arguments: current (the current element being
* processed), index (the index of the current element), and this (the original DoublyLinkedList).
* The callback function should return a value of type
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* convert the raw element (`RR`) to the desired element type (`T`). It takes the raw element as
* input and returns the converted element. If this parameter is not provided, the raw element will
* be used as is.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `DoublyLinkedList` class with elements of type `T` and `RR`.
*/
map(callback, thisArg) {
const mappedList = new DoublyLinkedList();
map(callback, toElementFn, thisArg) {
const mappedList = new DoublyLinkedList([], { toElementFn });
let index = 0;

@@ -729,0 +727,0 @@ for (const current of this) {

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

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

@@ -44,10 +44,4 @@ export declare class SinglyLinkedListNode<E = any> {

}
export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
/**
* The constructor initializes a new instance of a class with an optional iterable of elements.
* @param elements - The `elements` parameter is an optional iterable object that contains the
* initial elements to be added to the instance of the class. If no `elements` are provided, an empty
* array will be used as the default value.
*/
constructor(elements?: Iterable<E>);
export declare class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R, SinglyLinkedList<E, R>> {
constructor(elements?: Iterable<E> | Iterable<R>, options?: SinglyLinkedListOptions<E, R>);
protected _head: SinglyLinkedListNode<E> | undefined;

@@ -98,3 +92,3 @@ /**

*/
static fromArray<E>(data: E[]): SinglyLinkedList<E>;
static fromArray<E>(data: E[]): SinglyLinkedList<E, any>;
/**

@@ -354,3 +348,3 @@ * Time Complexity: O(1)

*/
clone(): SinglyLinkedList<E>;
clone(): SinglyLinkedList<E, R>;
/**

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

*/
filter(callback: ElementCallback<E, boolean>, thisArg?: any): SinglyLinkedList<E>;
filter(callback: ElementCallback<E, R, boolean, SinglyLinkedList<E, R>>, thisArg?: any): SinglyLinkedList<E, R>;
/**

@@ -384,16 +378,19 @@ * Time Complexity: O(n)

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new SinglyLinkedList by applying a callback function to each element
* of the original list.
* The `map` function takes a callback function and returns a new SinglyLinkedList with the results
* of applying the callback to each element in the original list.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the linked list. It takes three arguments:
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new `SinglyLinkedList` object that contains the results
* of applying the provided `callback` function to each element in the original list.
* the original list. It takes three arguments: `current` (the current element being processed),
* `index` (the index of the current element), and `this` (the original list). It should return a
* value
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* convert the raw element (`RR`) to the desired element type (`T`). It takes the raw element as
* input and returns the converted element. If this parameter is not provided, the raw element will
* be used as is.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `SinglyLinkedList` class with the mapped elements.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): SinglyLinkedList<T>;
map<EM, RM>(callback: ElementCallback<E, R, EM, SinglyLinkedList<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): SinglyLinkedList<EM, RM>;
/**

@@ -400,0 +397,0 @@ * The function `_getIterator` returns an iterable iterator that yields the values of a linked list.

@@ -49,14 +49,14 @@ "use strict";

class SinglyLinkedList extends base_1.IterableElementBase {
/**
* The constructor initializes a new instance of a class with an optional iterable of elements.
* @param elements - The `elements` parameter is an optional iterable object that contains the
* initial elements to be added to the instance of the class. If no `elements` are provided, an empty
* array will be used as the default value.
*/
constructor(elements = []) {
super();
constructor(elements = [], options) {
super(options);
this._size = 0;
if (elements) {
for (const el of elements)
this.push(el);
for (const el of elements) {
if (this.toElementFn) {
this.push(this.toElementFn(el));
}
else {
this.push(el);
}
}
}

@@ -612,3 +612,3 @@ }

clone() {
return new SinglyLinkedList(this.values());
return new SinglyLinkedList(this, { toElementFn: this.toElementFn });
}

@@ -637,3 +637,3 @@ /**

filter(callback, thisArg) {
const filteredList = new SinglyLinkedList();
const filteredList = new SinglyLinkedList([], { toElementFn: this.toElementFn });
let index = 0;

@@ -653,17 +653,20 @@ for (const current of this) {

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new SinglyLinkedList by applying a callback function to each element
* of the original list.
* The `map` function takes a callback function and returns a new SinglyLinkedList with the results
* of applying the callback to each element in the original list.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the linked list. It takes three arguments:
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new `SinglyLinkedList` object that contains the results
* of applying the provided `callback` function to each element in the original list.
* the original list. It takes three arguments: `current` (the current element being processed),
* `index` (the index of the current element), and `this` (the original list). It should return a
* value
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* convert the raw element (`RR`) to the desired element type (`T`). It takes the raw element as
* input and returns the converted element. If this parameter is not provided, the raw element will
* be used as is.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `SinglyLinkedList` class with the mapped elements.
*/
map(callback, thisArg) {
const mappedList = new SinglyLinkedList();
map(callback, toElementFn, thisArg) {
const mappedList = new SinglyLinkedList([], { toElementFn });
let index = 0;

@@ -670,0 +673,0 @@ for (const current of this) {

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

*/
import type { PriorityQueueOptions } from '../../types';
import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
import { PriorityQueue } from './priority-queue';
export declare class MaxPriorityQueue<E = any> extends PriorityQueue<E> {
export declare class MaxPriorityQueue<E = any, R = any> extends PriorityQueue<E, R> {
/**

@@ -19,6 +19,52 @@ * The constructor initializes a PriorityQueue with optional elements and options, including a

* @param options - The `options` parameter is an object that contains additional configuration
* options for the priority queue. In this case, it has a property called `comparator` which is a
* options for the priority queue. In this case, it has a property called `comparator,` which is a
* function used to compare elements in the priority queue.
*/
constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
constructor(elements?: Iterable<E> | Iterable<R>, options?: PriorityQueueOptions<E, R>);
/**
* The `clone` function returns a new instance of the `MaxPriorityQueue` class with the same
* comparator and toElementFn as the current instance.
* @returns The method is returning a new instance of the MaxPriorityQueue class with the same
* comparator and toElementFn as the current instance.
*/
clone(): MaxPriorityQueue<E, R>;
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MaxPriorityQueue object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MaxPriorityQueue` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback: ElementCallback<E, R, boolean, MaxPriorityQueue<E, R>>, thisArg?: any): MaxPriorityQueue<E, R>;
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MaxPriorityQueue` class with the mapped elements.
*/
map<EM, RM>(callback: ElementCallback<E, R, EM, MaxPriorityQueue<E, R>>, comparator: Comparator<EM>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): MaxPriorityQueue<EM, RM>;
}

@@ -13,18 +13,87 @@ "use strict";

* @param options - The `options` parameter is an object that contains additional configuration
* options for the priority queue. In this case, it has a property called `comparator` which is a
* options for the priority queue. In this case, it has a property called `comparator,` which is a
* function used to compare elements in the priority queue.
*/
constructor(elements = [], options = {
comparator: (a, b) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
constructor(elements = [], options) {
super(elements, Object.assign({ comparator: (a, b) => {
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(`When comparing object types, a custom comparator must be defined in the constructor's options parameter.`);
}
if (a < b)
return 1;
if (a > b)
return -1;
return 0;
} }, options));
}
/**
* The `clone` function returns a new instance of the `MaxPriorityQueue` class with the same
* comparator and toElementFn as the current instance.
* @returns The method is returning a new instance of the MaxPriorityQueue class with the same
* comparator and toElementFn as the current instance.
*/
clone() {
return new MaxPriorityQueue(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MaxPriorityQueue object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MaxPriorityQueue` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback, thisArg) {
const filteredPriorityQueue = new MaxPriorityQueue([], {
toElementFn: this.toElementFn,
comparator: this.comparator
});
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredPriorityQueue.add(current);
}
else {
return b - a;
}
index++;
}
}) {
super(elements, options);
return filteredPriorityQueue;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MaxPriorityQueue` class with the mapped elements.
*/
map(callback, comparator, toElementFn, thisArg) {
const mappedPriorityQueue = new MaxPriorityQueue([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedPriorityQueue.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedPriorityQueue;
}
}
exports.MaxPriorityQueue = MaxPriorityQueue;

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

*/
import type { PriorityQueueOptions } from '../../types';
import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
import { PriorityQueue } from './priority-queue';
export declare class MinPriorityQueue<E = any> extends PriorityQueue<E> {
export declare class MinPriorityQueue<E = any, R = any> extends PriorityQueue<E, R> {
/**

@@ -19,7 +19,53 @@ * The constructor initializes a PriorityQueue with optional elements and options, including a

* @param options - The `options` parameter is an object that contains additional configuration
* options for the priority queue. In this case, it has a property called `comparator` which is a
* options for the priority queue. In this case, it has a property called `comparator,` which is a
* function used to compare elements in the priority queue. The `comparator` function takes two
* parameters `a` and `b`,
* parameters `a` and `b`
*/
constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
constructor(elements?: Iterable<E> | Iterable<R>, options?: PriorityQueueOptions<E, R>);
/**
* The `clone` function returns a new instance of the `MinPriorityQueue` class with the same
* comparator and toElementFn as the original instance.
* @returns The method is returning a new instance of the `MinPriorityQueue` class with the same
* properties as the current instance.
*/
clone(): MinPriorityQueue<E, R>;
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MinPriorityQueue object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MinPriorityQueue` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback: ElementCallback<E, R, boolean, MinPriorityQueue<E, R>>, thisArg?: any): MinPriorityQueue<E, R>;
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MinPriorityQueue` class with the mapped elements.
*/
map<EM, RM>(callback: ElementCallback<E, R, EM, MinPriorityQueue<E, R>>, comparator: Comparator<EM>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): MinPriorityQueue<EM, RM>;
}

@@ -13,19 +13,79 @@ "use strict";

* @param options - The `options` parameter is an object that contains additional configuration
* options for the priority queue. In this case, it has a property called `comparator` which is a
* options for the priority queue. In this case, it has a property called `comparator,` which is a
* function used to compare elements in the priority queue. The `comparator` function takes two
* parameters `a` and `b`,
* parameters `a` and `b`
*/
constructor(elements = [], options = {
comparator: (a, b) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
constructor(elements = [], options) {
super(elements, options);
}
/**
* The `clone` function returns a new instance of the `MinPriorityQueue` class with the same
* comparator and toElementFn as the original instance.
* @returns The method is returning a new instance of the `MinPriorityQueue` class with the same
* properties as the current instance.
*/
clone() {
return new MinPriorityQueue(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MinPriorityQueue object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MinPriorityQueue` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback, thisArg) {
const filteredPriorityQueue = new MinPriorityQueue([], {
toElementFn: this.toElementFn,
comparator: this.comparator
});
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredPriorityQueue.add(current);
}
else {
return a - b;
}
index++;
}
}) {
super(elements, options);
return filteredPriorityQueue;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MinPriorityQueue` class with the mapped elements.
*/
map(callback, comparator, toElementFn, thisArg) {
const mappedPriorityQueue = new MinPriorityQueue([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedPriorityQueue.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedPriorityQueue;
}
}
exports.MinPriorityQueue = MinPriorityQueue;

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

*/
import type { PriorityQueueOptions } from '../../types';
import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
import { Heap } from '../heap';

@@ -19,7 +19,7 @@ /**

*/
export declare class PriorityQueue<E = any> extends Heap<E> {
export declare class PriorityQueue<E = any, R = any> extends Heap<E, R> {
/**
* The constructor initializes a priority queue with optional elements and options.
* @param elements - The `elements` parameter is an iterable object that contains the initial
* elements to be added to the priority queue. It is an optional parameter and if not provided, the
* elements to be added to the priority queue. It is an optional parameter, and if not provided, the
* priority queue will be initialized as empty.

@@ -29,3 +29,49 @@ * @param [options] - The `options` parameter is an optional object that can be used to customize the

*/
constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
constructor(elements?: Iterable<E> | Iterable<R>, options?: PriorityQueueOptions<E, R>);
/**
* The `clone` function returns a new instance of the `PriorityQueue` class with the same comparator
* and toElementFn as the original instance.
* @returns The method is returning a new instance of the `PriorityQueue` class with the same
* elements and properties as the current instance.
*/
clone(): PriorityQueue<E, R>;
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new PriorityQueue object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `PriorityQueue` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback: ElementCallback<E, R, boolean, PriorityQueue<E, R>>, thisArg?: any): PriorityQueue<E, R>;
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `PriorityQueue` class with the mapped elements.
*/
map<EM, RM>(callback: ElementCallback<E, R, EM, PriorityQueue<E, R>>, comparator: Comparator<EM>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): PriorityQueue<EM, RM>;
}

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

* @param elements - The `elements` parameter is an iterable object that contains the initial
* elements to be added to the priority queue. It is an optional parameter and if not provided, the
* elements to be added to the priority queue. It is an optional parameter, and if not provided, the
* priority queue will be initialized as empty.

@@ -26,3 +26,72 @@ * @param [options] - The `options` parameter is an optional object that can be used to customize the

}
/**
* The `clone` function returns a new instance of the `PriorityQueue` class with the same comparator
* and toElementFn as the original instance.
* @returns The method is returning a new instance of the `PriorityQueue` class with the same
* elements and properties as the current instance.
*/
clone() {
return new PriorityQueue(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new PriorityQueue object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `PriorityQueue` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
filter(callback, thisArg) {
const filteredPriorityQueue = new PriorityQueue([], {
toElementFn: this.toElementFn,
comparator: this.comparator
});
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredPriorityQueue.add(current);
}
index++;
}
return filteredPriorityQueue;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `PriorityQueue` class with the mapped elements.
*/
map(callback, comparator, toElementFn, thisArg) {
const mappedPriorityQueue = new PriorityQueue([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedPriorityQueue.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedPriorityQueue;
}
}
exports.PriorityQueue = PriorityQueue;

@@ -17,5 +17,5 @@ /**

*/
export declare class Deque<E> extends IterableElementBase<E> {
export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E, R>> {
/**
* The constructor initializes a Deque object with an optional iterable of elements and options.
* The constructor initializes a Deque object with optional iterable of elements and options.
* @param elements - An iterable object (such as an array or a Set) that contains the initial

@@ -30,3 +30,3 @@ * elements to be added to the deque. It can also be an object with a `length` or `size` property

*/
constructor(elements?: IterableWithSizeOrLength<E>, options?: DequeOptions);
constructor(elements?: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R>, options?: DequeOptions<E, R>);
protected _bucketSize: number;

@@ -397,3 +397,3 @@ /**

*/
clone(): Deque<E>;
clone(): Deque<E, R>;
/**

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

*/
filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Deque<E>;
filter(predicate: ElementCallback<E, R, boolean, Deque<E, R>>, thisArg?: any): Deque<E, R>;
/**

@@ -426,15 +426,17 @@ * Time Complexity: O(n)

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new Deque by applying a callback function to each element of the
* original Deque.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the deque. It takes three arguments:
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns a new Deque object with the mapped values.
* The `map` function takes a callback function and applies it to each element in the deque,
* returning a new deque with the results.
* @param callback - The callback parameter is a function that will be called for each element in the
* deque. It takes three arguments: the current element, the index of the element, and the deque
* itself. It should return a value of type EM.
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* transform the raw element (`RM`) into a new element (`EM`) before adding it to the new deque. If
* provided, this function will be called for each raw element in the original deque.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new Deque object with elements of type EM and raw elements of type RM.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): Deque<T>;
map<EM, RM>(callback: ElementCallback<E, R, EM, Deque<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Deque<EM, RM>;
/**

@@ -441,0 +443,0 @@ * Time Complexity: O(n)

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

/**
* The constructor initializes a Deque object with an optional iterable of elements and options.
* The constructor initializes a Deque object with optional iterable of elements and options.
* @param elements - An iterable object (such as an array or a Set) that contains the initial

@@ -27,3 +27,3 @@ * elements to be added to the deque. It can also be an object with a `length` or `size` property

constructor(elements = [], options) {
super();
super(options);
this._bucketSize = 1 << 12;

@@ -62,4 +62,9 @@ this._bucketFirst = 0;

this._firstInBucket = this._lastInBucket = (this._bucketSize - (_size % this._bucketSize)) >> 1;
for (const element of elements) {
this.push(element);
for (const el of elements) {
if (this.toElementFn) {
this.push(this.toElementFn(el));
}
else {
this.push(el);
}
}

@@ -714,3 +719,3 @@ }

clone() {
return new Deque([...this], { bucketSize: this.bucketSize });
return new Deque(this, { bucketSize: this.bucketSize, toElementFn: this.toElementFn });
}

@@ -738,3 +743,3 @@ /**

filter(predicate, thisArg) {
const newDeque = new Deque([], { bucketSize: this._bucketSize });
const newDeque = new Deque([], { bucketSize: this._bucketSize, toElementFn: this.toElementFn });
let index = 0;

@@ -754,16 +759,18 @@ for (const el of this) {

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new Deque by applying a callback function to each element of the
* original Deque.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the deque. It takes three arguments:
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns a new Deque object with the mapped values.
* The `map` function takes a callback function and applies it to each element in the deque,
* returning a new deque with the results.
* @param callback - The callback parameter is a function that will be called for each element in the
* deque. It takes three arguments: the current element, the index of the element, and the deque
* itself. It should return a value of type EM.
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* transform the raw element (`RM`) into a new element (`EM`) before adding it to the new deque. If
* provided, this function will be called for each raw element in the original deque.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new Deque object with elements of type EM and raw elements of type RM.
*/
map(callback, thisArg) {
const newDeque = new Deque([], { bucketSize: this._bucketSize });
map(callback, toElementFn, thisArg) {
const newDeque = new Deque([], { bucketSize: this._bucketSize, toElementFn });
let index = 0;

@@ -770,0 +777,0 @@ for (const el of this) {

@@ -6,3 +6,3 @@ /**

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

@@ -19,10 +19,4 @@ import { SinglyLinkedList } from '../linked-list';

*/
export declare class Queue<E = any> extends IterableElementBase<E> {
/**
* The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
* @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
* will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
* initialized as an empty array.
*/
constructor(elements?: Iterable<E>);
export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E, R>> {
constructor(elements?: Iterable<E> | Iterable<R>, options?: QueueOptions<E, R>);
protected _elements: E[];

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

*/
clone(): Queue<E>;
clone(): Queue<E, R>;
/**

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

*/
filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Queue<E>;
filter(predicate: ElementCallback<E, R, boolean, Queue<E, R>>, thisArg?: any): Queue<E, R>;
/**

@@ -211,24 +205,10 @@ * Time Complexity: O(n)

*/
map<EM, RM>(callback: ElementCallback<E, R, EM, Queue<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Queue<EM, RM>;
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function takes a callback function and applies it to each element in the queue,
* returning a new queue with the results.
* @param callback - The callback parameter is a function that will be called for each element in the
* queue. It takes three arguments: the current element, the index of the current element, and the
* queue itself. The callback function should return a new value that will be added to the new queue.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new `Queue` object with the transformed elements.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): Queue<T>;
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -245,3 +225,3 @@ * The function `_getIterator` returns an iterable iterator for the elements in the class.

*/
export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
export declare class LinkedListQueue<E = any, R = any> extends SinglyLinkedList<E, R> {
/**

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

*/
clone(): LinkedListQueue<E>;
clone(): LinkedListQueue<E, R>;
}

@@ -16,15 +16,13 @@ "use strict";

class Queue extends base_1.IterableElementBase {
/**
* The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
* @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
* will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
* initialized as an empty array.
*/
constructor(elements = []) {
super();
constructor(elements = [], options) {
super(options);
this._elements = [];
this._offset = 0;
if (elements) {
for (const el of elements)
this.push(el);
for (const el of elements) {
if (this.toElementFn)
this.push(this.toElementFn(el));
else
this.push(el);
}
}

@@ -171,3 +169,3 @@ }

at(index) {
return this.elements[index];
return this.elements[index + this._offset];
}

@@ -229,3 +227,3 @@ /**

clone() {
return new Queue(this.elements.slice(this.offset));
return new Queue(this.elements.slice(this.offset), { toElementFn: this.toElementFn });
}

@@ -253,3 +251,3 @@ /**

filter(predicate, thisArg) {
const newDeque = new Queue([]);
const newDeque = new Queue([], { toElementFn: this.toElementFn });
let index = 0;

@@ -268,18 +266,4 @@ for (const el of this) {

*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function takes a callback function and applies it to each element in the queue,
* returning a new queue with the results.
* @param callback - The callback parameter is a function that will be called for each element in the
* queue. It takes three arguments: the current element, the index of the current element, and the
* queue itself. The callback function should return a new value that will be added to the new queue.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new `Queue` object with the transformed elements.
*/
map(callback, thisArg) {
const newDeque = new Queue([]);
map(callback, toElementFn, thisArg) {
const newDeque = new Queue([], { toElementFn });
let index = 0;

@@ -303,3 +287,3 @@ for (const el of this) {

*_getIterator() {
for (const item of this.elements) {
for (const item of this.elements.slice(this.offset)) {
yield item;

@@ -330,5 +314,5 @@ }

clone() {
return new LinkedListQueue(this.values());
return new LinkedListQueue(this, { toElementFn: this.toElementFn });
}
}
exports.LinkedListQueue = LinkedListQueue;

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

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

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

*/
export declare class Stack<E = any> extends IterableElementBase<E> {
/**
* The constructor initializes an array of elements, which can be provided as an optional parameter.
* @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
* of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
* is provided and is an array, it is assigned to the `_elements
*/
constructor(elements?: Iterable<E>);
export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E, R>> {
constructor(elements?: Iterable<E> | Iterable<R>, options?: StackOptions<E, R>);
protected _elements: E[];

@@ -142,3 +136,3 @@ /**

*/
clone(): Stack<E>;
clone(): Stack<E, R>;
/**

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

*/
filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Stack<E>;
filter(predicate: ElementCallback<E, R, boolean, Stack<E, R>>, thisArg?: any): Stack<E, R>;
/**

@@ -171,15 +165,16 @@ * Time Complexity: O(n)

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function takes a callback function and applies it to each element in the stack,
* returning a new stack with the results.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the stack. It takes three arguments:
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` method is returning a new `Stack` object.
* @param callback - The callback parameter is a function that will be called for each element in the
* stack. It takes three arguments: the current element, the index of the element, and the stack
* itself. It should return a new value that will be added to the new stack.
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* transform the raw element (`RM`) into a new element (`EM`) before pushing it into the new stack.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new Stack object with elements of type EM and raw elements of type RM.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): Stack<T>;
map<EM, RM>(callback: ElementCallback<E, R, EM, Stack<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Stack<EM, RM>;
/**

@@ -186,0 +181,0 @@ * Time Complexity: O(n)

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

class Stack extends base_1.IterableElementBase {
/**
* The constructor initializes an array of elements, which can be provided as an optional parameter.
* @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
* of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
* is provided and is an array, it is assigned to the `_elements
*/
constructor(elements = []) {
super();
constructor(elements = [], options) {
super(options);
this._elements = [];
if (elements) {
for (const el of elements)
this.push(el);
for (const el of elements) {
if (this.toElementFn) {
this.push(this.toElementFn(el));
}
else {
this.push(el);
}
}
}

@@ -172,3 +172,3 @@ }

clone() {
return new Stack(this.elements.slice());
return new Stack(this, { toElementFn: this.toElementFn });
}

@@ -196,3 +196,3 @@ /**

filter(predicate, thisArg) {
const newStack = new Stack();
const newStack = new Stack([], { toElementFn: this.toElementFn });
let index = 0;

@@ -212,16 +212,17 @@ for (const el of this) {

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function takes a callback function and applies it to each element in the stack,
* returning a new stack with the results.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the stack. It takes three arguments:
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` method is returning a new `Stack` object.
* @param callback - The callback parameter is a function that will be called for each element in the
* stack. It takes three arguments: the current element, the index of the element, and the stack
* itself. It should return a new value that will be added to the new stack.
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* transform the raw element (`RM`) into a new element (`EM`) before pushing it into the new stack.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new Stack object with elements of type EM and raw elements of type RM.
*/
map(callback, thisArg) {
const newStack = new Stack();
map(callback, toElementFn, thisArg) {
const newStack = new Stack([], { toElementFn });
let index = 0;

@@ -228,0 +229,0 @@ for (const el of this) {

@@ -69,3 +69,3 @@ /**

*/
export declare class Trie extends IterableElementBase<string, Trie> {
export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
/**

@@ -77,3 +77,3 @@ * The constructor function for the Trie class.

*/
constructor(words?: Iterable<string>, options?: TrieOptions);
constructor(words?: Iterable<string> | Iterable<R>, options?: TrieOptions<R>);
protected _size: number;

@@ -248,3 +248,3 @@ /**

*/
clone(): Trie;
clone(): Trie<R>;
/**

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

*/
filter(predicate: ElementCallback<string, boolean>, thisArg?: any): Trie;
filter(predicate: ElementCallback<string, R, boolean, Trie<R>>, thisArg?: any): Trie<R>;
/**

@@ -278,12 +278,17 @@ * Time Complexity: O(n)

*
* The `map` function creates a new Trie by applying a callback function to each element in the Trie.
* The `map` function creates a new Trie by applying a callback function to each element in the
* current Trie.
* @param callback - The callback parameter is a function that will be called for each element in the
* Trie. It takes three arguments: the current element in the Trie, the index of the current element,
* and the Trie itself. The callback function should return a new value for the element.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new Trie object.
* Trie. It takes four arguments:
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* convert the raw element (`RM`) into a string representation. This can be useful if the raw element
* is not already a string or if you want to customize how the element is converted into a string. If
* this parameter is
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new Trie object.
*/
map(callback: ElementCallback<string, string>, thisArg?: any): Trie;
map<RM>(callback: ElementCallback<string, R, string, Trie<R>>, toElementFn?: (rawElement: RM) => string, thisArg?: any): Trie<RM>;
/**

@@ -290,0 +295,0 @@ * Time Complexity: O(n)

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

constructor(words = [], options) {
super();
super(options);
this._size = 0;

@@ -97,4 +97,10 @@ this._caseSensitive = true;

if (words) {
for (const word of words)
this.add(word);
for (const word of words) {
if (this.toElementFn) {
this.add(this.toElementFn(word));
}
else {
this.add(word);
}
}
}

@@ -438,3 +444,3 @@ }

clone() {
return new Trie(this.values(), { caseSensitive: this.caseSensitive });
return new Trie(this, { caseSensitive: this.caseSensitive, toElementFn: this.toElementFn });
}

@@ -460,3 +466,3 @@ /**

filter(predicate, thisArg) {
const results = new Trie();
const results = new Trie([], { toElementFn: this.toElementFn, caseSensitive: this.caseSensitive });
let index = 0;

@@ -479,13 +485,18 @@ for (const word of this) {

*
* The `map` function creates a new Trie by applying a callback function to each element in the Trie.
* The `map` function creates a new Trie by applying a callback function to each element in the
* current Trie.
* @param callback - The callback parameter is a function that will be called for each element in the
* Trie. It takes three arguments: the current element in the Trie, the index of the current element,
* and the Trie itself. The callback function should return a new value for the element.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new Trie object.
* Trie. It takes four arguments:
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* convert the raw element (`RM`) into a string representation. This can be useful if the raw element
* is not already a string or if you want to customize how the element is converted into a string. If
* this parameter is
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new Trie object.
*/
map(callback, thisArg) {
const newTrie = new Trie();
map(callback, toElementFn, thisArg) {
const newTrie = new Trie([], { toElementFn, caseSensitive: this.caseSensitive });
let index = 0;

@@ -492,0 +503,0 @@ for (const word of this) {

import { BinaryTree, BinaryTreeNode } from '../data-structures';
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, Comparable, KeyOrNodeOrEntry } from '../types';
export interface IBinaryTree<K extends Comparable, V = any, R = [K, V], NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>> {
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, KeyOrNodeOrEntry } from '../types';
export interface IBinaryTree<K = any, V = any, R = [K, V], NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>> {
createNode(key: K, value?: NODE['value']): NODE;

@@ -5,0 +5,0 @@ createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;

import { IterableElementBase, IterableEntryBase } from '../../../data-structures';
export type EntryCallback<K, V, R> = (value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
export type ElementCallback<V, R> = (element: V, index: number, container: IterableElementBase<V>) => R;
export type ElementCallback<E, R, RT, C> = (element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
export type ReduceEntryCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
export type ReduceElementCallback<V, R> = (accumulator: R, element: V, index: number, container: IterableElementBase<V>) => R;
export type ReduceElementCallback<E, R, RT, C> = (accumulator: RT, element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
export type IterableElementBaseOptions<E, R> = {
toElementFn?: (rawElement: R) => E;
};
import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
import type { AVLTreeOptions } from './avl-tree';
import { Comparable } from "../../utils";
export type AVLTreeMultiMapNodeNested<K extends Comparable, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type AVLTreeMultiMapNested<K extends Comparable, V, R, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type AVLTreeMultiMapNested<K, V, R, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};
import { AVLTree, AVLTreeNode } from '../../../data-structures';
import { BSTOptions } from './bst';
import { Comparable } from "../../utils";
export type AVLTreeNodeNested<K extends Comparable, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type AVLTreeNested<K extends Comparable, V, R, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type AVLTreeNested<K, V, R, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
import { BTNEntry, IterationType } from '../../common';
import { Comparable } from '../../utils';
export type BinaryTreeNodeNested<K extends Comparable, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type BinaryTreeNested<K extends Comparable, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type BinaryTreeOptions<K, V, R> = {

@@ -7,0 +6,0 @@ iterationType?: IterationType;

import { BST, BSTNode } from '../../../data-structures';
import type { BinaryTreeOptions } from './binary-tree';
import { Comparator } from '../../common';
import { Comparable } from '../../utils';
export type BSTNodeNested<K extends Comparable, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type BSTNested<K extends Comparable, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type BSTNested<K, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
comparator?: Comparator<K>;
};
import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
import type { BSTOptions } from "./bst";
import { Comparable } from "../../utils";
export type RBTNColor = 'RED' | 'BLACK';
export type RedBlackTreeNodeNested<K extends Comparable, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type RedBlackTreeNested<K extends Comparable, V, R, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type RedBlackTreeNested<K, V, R, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type RBTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures';
import type { RBTreeOptions } from './rb-tree';
import { Comparable } from '../../utils';
export type TreeMultiMapNodeNested<K extends Comparable, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type TreeMultiMapNested<K extends Comparable, V, R, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
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, R, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
export type TreeMultiMapOptions<K, V, R> = RBTreeOptions<K, V, R> & {};
import { Comparator } from '../../common';
export type HeapOptions<T> = {
comparator?: Comparator<T>;
import { IterableElementBaseOptions } from '../base';
export type HeapOptions<E, R> = IterableElementBaseOptions<E, R> & {
comparator?: Comparator<E>;
};

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

export {};
import { IterableElementBaseOptions } from '../base';
export type DoublyLinkedListOptions<E, R> = IterableElementBaseOptions<E, R> & {};

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

export {};
import { IterableElementBaseOptions } from '../base';
export type SinglyLinkedListOptions<E, R> = IterableElementBaseOptions<E, R> & {};
import { HeapOptions } from '../heap';
export type PriorityQueueOptions<T> = HeapOptions<T> & {};
export type PriorityQueueOptions<E, R> = HeapOptions<E, R> & {};

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

export type DequeOptions = {
import { IterableElementBaseOptions } from '../base';
export type DequeOptions<E, R> = {
bucketSize?: number;
};
} & IterableElementBaseOptions<E, R>;

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

export {};
import { IterableElementBaseOptions } from '../base';
export type QueueOptions<E, R> = IterableElementBaseOptions<E, R> & {};

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

export {};
import { IterableElementBaseOptions } from '../base';
export type StackOptions<E, R> = IterableElementBaseOptions<E, R> & {};

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

export type TrieOptions = {
import { IterableElementBaseOptions } from '../base';
export type TrieOptions<R> = {
caseSensitive?: boolean;
};
} & IterableElementBaseOptions<string, R>;
{
"name": "min-heap-typed",
"version": "1.51.9",
"version": "1.52.0",
"description": "Min Heap. Javascript & Typescript Data Structure.",

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

"dependencies": {
"data-structure-typed": "^1.51.9"
"data-structure-typed": "^1.52.0"
}
}

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

export * from './iterable-base';
export * from './iterable-entry-base';
export * from './iterable-element-base';

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

BTNCallback,
Comparable,
IterationType,

@@ -25,3 +24,3 @@ KeyOrNodeOrEntry

export class AVLTreeMultiMapNode<
K extends Comparable,
K = any,
V = any,

@@ -69,3 +68,3 @@ NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V>

export class AVLTreeMultiMap<
K extends Comparable,
K = any,
V = any,

@@ -72,0 +71,0 @@ R = BTNEntry<K, V>,

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

BTNCallback,
Comparable,
KeyOrNodeOrEntry

@@ -24,3 +23,3 @@ } from '../../types';

export class AVLTreeNode<
K extends Comparable,
K = any,
V = any,

@@ -72,3 +71,3 @@ NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>

export class AVLTree<
K extends Comparable,
K = any,
V = any,

@@ -75,0 +74,0 @@ R = BTNEntry<K, V>,

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

BTNPureKeyOrNodeOrEntry,
Comparable,
Comparator,

@@ -28,7 +27,7 @@ CP,

export class BSTNode<
K extends Comparable,
V = any,
NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V>
> extends BinaryTreeNode<K, V, NODE> {
export class BSTNode<K = any, V = any, NODE extends BSTNode<K, V, NODE> = BSTNodeNested<K, V>> extends BinaryTreeNode<
K,
V,
NODE
> {
override parent?: NODE;

@@ -99,3 +98,3 @@

export class BST<
K extends Comparable,
K = any,
V = any,

@@ -805,11 +804,6 @@ R = BTNEntry<K, V>,

/**
* Time complexity: O(n)
* Space complexity: O(n)
*/
protected _DEFAULT_COMPARATOR = (a: K, b: K): number => {
if (typeof a === 'object' && typeof b === 'object' && this.comparator === this._DEFAULT_COMPARATOR) {
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(
'When comparing two object types, it is necessary to customize a [comparator] function of options parameter during the instantiation of the data structure.'
`When comparing object types, a custom comparator must be defined in the constructor's options parameter.`
);

@@ -822,7 +816,2 @@ }

/**
* Time complexity: O(n)
* Space complexity: O(n)
*/
protected _comparator: Comparator<K> = this._DEFAULT_COMPARATOR;

@@ -829,0 +818,0 @@

import type {
BinaryTreeDeleteResult,
BTNCallback,
Comparable,
CRUD,

@@ -17,3 +16,3 @@ KeyOrNodeOrEntry,

export class RedBlackTreeNode<
K extends Comparable,
K = any,
V = any,

@@ -58,3 +57,3 @@ NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>

export class RedBlackTree<
K extends Comparable,
K = any,
V = any,

@@ -61,0 +60,0 @@ R = BTNEntry<K, V>,

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

BTNCallback,
Comparable,
IterationType,

@@ -26,3 +25,3 @@ KeyOrNodeOrEntry,

export class TreeMultiMapNode<
K extends Comparable,
K = any,
V = any,

@@ -69,3 +68,3 @@ NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>

export class TreeMultiMap<
K extends Comparable,
K = any,
V = any,

@@ -72,0 +71,0 @@ R = BTNEntry<K, V>,

@@ -273,4 +273,4 @@ /**

*/
map<U>(callbackfn: EntryCallback<K, V, U>, thisArg?: any): HashMap<K, U> {
const resultMap = new HashMap<K, U>();
map<VM>(callbackfn: EntryCallback<K, V, VM>, thisArg?: any): HashMap<K, VM> {
const resultMap = new HashMap<K, VM>();
let index = 0;

@@ -902,4 +902,4 @@ for (const [key, value] of this) {

*/
map<NV>(callback: EntryCallback<K, V, NV>, thisArg?: any): LinkedHashMap<K, NV> {
const mappedMap = new LinkedHashMap<K, NV>();
map<VM>(callback: EntryCallback<K, V, VM>, thisArg?: any): LinkedHashMap<K, VM> {
const mappedMap = new LinkedHashMap<K, VM>();
let index = 0;

@@ -906,0 +906,0 @@ for (const [key, value] of this) {

@@ -21,17 +21,20 @@ /**

* 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.
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prime's minimum-spanning tree algorithm, which use heaps to improve performance.
*/
export class Heap<E = any> extends IterableElementBase<E> {
export class Heap<E = any, R = any> extends IterableElementBase<E, R, Heap<E, R>> {
/**
* The constructor initializes a heap data structure with optional elements and options.
* @param elements - The `elements` parameter is an iterable object that contains the initial
* elements to be added to the heap. It is an optional parameter and if not provided, the heap will
* elements to be added to the heap.
* It is an optional parameter, and if not provided, the heap will
* be initialized as empty.
* @param [options] - The `options` parameter is an optional object that can contain additional
* configuration options for the heap. In this case, it is used to specify a custom comparator
* function for comparing elements in the heap. The comparator function is used to determine the
* configuration options for the heap.
* In this case, it is used to specify a custom comparator
* function for comparing elements in the heap.
* The comparator function is used to determine the
* order of elements in the heap.
*/
constructor(elements: Iterable<E> = [], options?: HeapOptions<E>) {
super();
constructor(elements: Iterable<E> | Iterable<R> = [], options?: HeapOptions<E, R>) {
super(options);

@@ -45,3 +48,4 @@ if (options) {

for (const el of elements) {
this.add(el);
if (this.toElementFn) this.add(this.toElementFn(el as R));
else this.add(el as E);
}

@@ -51,18 +55,2 @@ }

protected _comparator = (a: E, b: E) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
} else {
return a - b;
}
};
/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator() {
return this._comparator;
}
protected _elements: E[] = [];

@@ -72,3 +60,3 @@

* The function returns an array of elements.
* @returns The elements array is being returned.
* @returns The element array is being returned.
*/

@@ -100,3 +88,3 @@ get elements(): E[] {

*/
static heapify<E>(elements: Iterable<E>, options: HeapOptions<E>): Heap<E> {
static heapify<E = any, R = any>(elements: Iterable<E>, options: HeapOptions<E, R>): Heap<E> {
return new Heap<E>(elements, options);

@@ -108,8 +96,2 @@ }

* Space Complexity: O(1)
* where n is the number of elements in the heap.
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*

@@ -127,10 +109,4 @@ * Insert an element into the heap and maintain the heap properties.

* Space Complexity: O(1)
* where n is the number of elements in the heap.
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @returns The top element or undefined if the heap is empty.

@@ -152,7 +128,2 @@ */

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -184,7 +155,2 @@ * Peek at the top element of the heap without removing it.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -202,7 +168,2 @@ * Clear and add elements of the heap

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(1)
*

@@ -218,10 +179,4 @@ * Use a comparison function to check whether a binary heap contains a specific element.

/**
* Time Complexity: O(n)
* Time Complexity: O(n)
* Space Complexity: O(1)
* The worst-case O(n) This is because, in the worst case, the element to be deleted is located at the end of the heap (not the root), and after deletion, we may need to reorganize the elements by performing a sinkDown operation.
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(1)
*

@@ -253,8 +208,2 @@ * The `delete` function removes an element from an array-like data structure, maintaining the order

* Space Complexity: O(log n)
* where log n is the height of the heap.
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(log n)
*

@@ -297,7 +246,2 @@ * Depth-first search (DFS) method, different traversal orders can be selected。

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -314,7 +258,2 @@ * Convert the heap to an array.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -324,6 +263,4 @@ * Clone the heap, creating a new heap with the same elements.

*/
clone(): Heap<E> {
const clonedHeap = new Heap<E>([], { comparator: this.comparator });
clonedHeap._elements = [...this.elements];
return clonedHeap;
clone(): Heap<E, R> {
return new Heap<E, R>(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}

@@ -334,7 +271,2 @@

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*

@@ -346,6 +278,6 @@ * Sort the elements in the heap and return them as an array.

const visitedNode: E[] = [];
const cloned = this.clone();
const cloned = new Heap<E, R>(this, { comparator: this.comparator });
while (cloned.size !== 0) {
const top = cloned.poll();
if (top) visitedNode.push(top);
if (top !== undefined) visitedNode.push(top);
}

@@ -358,7 +290,2 @@ return visitedNode;

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*

@@ -376,7 +303,2 @@ * Fix the entire heap to maintain heap properties.

* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*

@@ -395,4 +317,4 @@ * The `filter` function creates a new Heap object containing elements that pass a given callback

*/
filter(callback: ElementCallback<E, boolean>, thisArg?: any): Heap<E> {
const filteredList = new Heap<E>();
filter(callback: ElementCallback<E, R, boolean, Heap<E, R>>, thisArg?: any): Heap<E, R> {
const filteredList = new Heap<E, R>([], { toElementFn: this.toElementFn, comparator: this.comparator });
let index = 0;

@@ -409,28 +331,29 @@ for (const current of this) {

/**
* Time Complexity: O(n)
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The callback parameter is a function that will be called for each element in the
* original heap. It takes three arguments: the current element, the index of the current element,
* and the original heap itself. The callback function should return a value of type T, which will be
* added to the mapped heap.
* @param comparator - The `comparator` parameter is a function that is used to compare elements in
* the heap. It takes two arguments, `a` and `b`, and returns a negative number if `a` is less than
* `b`, a positive number if `a` is greater than `b`, or
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used when you want to bind a
* specific object as the context for the callback function. If `thisArg` is not provided,
* `undefined` is used as
* @returns a new instance of the Heap class, which is created using the mapped elements from the
* original Heap.
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `Heap` class with the mapped elements.
*/
map<T>(callback: ElementCallback<E, T>, comparator: Comparator<T>, thisArg?: any): Heap<T> {
const mappedHeap: Heap<T> = new Heap<T>([], { comparator: comparator });
map<EM, RM>(
callback: ElementCallback<E, R, EM, Heap<E, R>>,
comparator: Comparator<EM>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): Heap<EM, RM> {
const mappedHeap: Heap<EM, RM> = new Heap<EM, RM>([], { comparator, toElementFn });
let index = 0;

@@ -444,3 +367,24 @@ for (const el of this) {

protected _DEFAULT_COMPARATOR = (a: E, b: E): number => {
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(
`When comparing object types, a custom comparator must be defined in the constructor's options parameter.`
);
}
if (a > b) return 1;
if (a < b) return -1;
return 0;
};
protected _comparator: Comparator<E> = this._DEFAULT_COMPARATOR;
/**
* The function returns the value of the _comparator property.
* @returns The `_comparator` property is being returned.
*/
get comparator() {
return this._comparator;
}
/**
* The function `_getIterator` returns an iterable iterator for the elements in the class.

@@ -457,7 +401,2 @@ */

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*

@@ -483,7 +422,2 @@ * Float operation to maintain heap properties after adding an element.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*

@@ -610,7 +544,2 @@ * Sinking operation to maintain heap properties after removing the top element.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -628,7 +557,2 @@ * Insert an element into the heap and maintain the heap properties.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -656,7 +580,2 @@ * Insert an element into the heap and maintain the heap properties.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*

@@ -732,3 +651,3 @@ * Peek at the top element of the heap without removing it.

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @returns The top element or undefined if the heap is empty.

@@ -749,3 +668,3 @@ */

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @returns The top element or undefined if the heap is empty.

@@ -876,4 +795,4 @@ */

* Space Complexity: O(1)
*.
* Remove and return the top element (smallest or largest element) from the heap.
*
* Remove and return the top element (the smallest or largest element) from the heap.
* @param node - The node to be removed.

@@ -897,3 +816,3 @@ * @protected

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @param y

@@ -921,3 +840,3 @@ * @param x

*
* Remove and return the top element (smallest or largest element) from the heap.
* Remove and return the top element (the smallest or largest element) from the heap.
* @protected

@@ -924,0 +843,0 @@ */

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

*/
import type { HeapOptions } from '../../types';
import type { Comparator, ElementCallback, HeapOptions } from '../../types';
import { Heap } from './heap';

@@ -20,19 +20,94 @@

* 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.
* 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> {
constructor(
elements: Iterable<E> = [],
options: HeapOptions<E> = {
comparator: (a: E, b: E) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
} else {
return b - a;
export class MaxHeap<E = any, R = any> extends Heap<E, R> {
constructor(elements: Iterable<E> | Iterable<R> = [], options?: HeapOptions<E, R>) {
super(elements, {
comparator: (a: E, b: E): number => {
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(
`When comparing object types, a custom comparator must be defined in the constructor's options parameter.`
);
}
if (a < b) return 1;
if (a > b) return -1;
return 0;
},
...options
});
}
/**
* The `clone` function returns a new instance of the `MaxHeap` class with the same properties as the
* current instance.
* @returns The `clone()` method is returning a new instance of the `MaxHeap` class with the same
* properties as the current instance.
*/
override clone(): MaxHeap<E, R> {
return new MaxHeap<E, R>(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MaxHeap object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MaxHeap` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
override filter(callback: ElementCallback<E, R, boolean, MaxHeap<E, R>>, thisArg?: any): MaxHeap<E, R> {
const filteredList = new MaxHeap<E, R>([], { toElementFn: this.toElementFn, comparator: this.comparator });
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredList.add(current);
}
index++;
}
) {
super(elements, options);
return filteredList;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MaxHeap` class with the mapped elements.
*/
override map<EM, RM>(
callback: ElementCallback<E, R, EM, MaxHeap<E, R>>,
comparator: Comparator<EM>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): MaxHeap<EM, RM> {
const mappedHeap: MaxHeap<EM, RM> = new MaxHeap<EM, RM>([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedHeap.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedHeap;
}
}

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

*/
import type { HeapOptions } from '../../types';
import type { Comparator, ElementCallback, HeapOptions } from '../../types';
import { Heap } from './heap';

@@ -14,3 +14,3 @@

* 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.
* 2. MinHeap 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.

@@ -20,20 +20,83 @@ * 4. Efficient Insertion and Deletion: Due to its structure, a heap allows for insertion and deletion operations in logarithmic time (O(log n)).

* 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.
* 7. Efficient Sorting Algorithms: For example, heap sort. MinHeap 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> {
constructor(
elements: Iterable<E> = [],
options: HeapOptions<E> = {
comparator: (a: E, b: E) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
} else {
return a - b;
}
export class MinHeap<E = any, R = any> extends Heap<E, R> {
constructor(elements: Iterable<E> | Iterable<R> = [], options?: HeapOptions<E, R>) {
super(elements, options);
}
/**
* The `clone` function returns a new instance of the `MinHeap` class with the same comparator and
* toElementFn as the original instance.
* @returns The `clone()` method is returning a new instance of the `MinHeap` class with the same
* properties as the current instance.
*/
override clone(): MinHeap<E, R> {
return new MinHeap<E, R>(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MinHeap object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MinHeap` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
override filter(callback: ElementCallback<E, R, boolean, MinHeap<E, R>>, thisArg?: any): MinHeap<E, R> {
const filteredList = new MinHeap<E, R>([], { toElementFn: this.toElementFn, comparator: this.comparator });
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredList.add(current);
}
index++;
}
) {
super(elements, options);
return filteredList;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MinHeap` class with the mapped elements.
*/
override map<EM, RM>(
callback: ElementCallback<E, R, EM, MinHeap<E, R>>,
comparator: Comparator<EM>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): MinHeap<EM, RM> {
const mappedHeap: MinHeap<EM, RM> = new MinHeap<EM, RM>([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedHeap.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedHeap;
}
}

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

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

@@ -91,11 +91,5 @@

*/
export class DoublyLinkedList<E = any> extends IterableElementBase<E> {
/**
* The constructor initializes a linked list with optional elements.
* @param elements - The `elements` parameter is an optional iterable object that contains the
* initial elements to be added to the data structure. It defaults to an empty array if no elements
* are provided.
*/
constructor(elements: Iterable<E> = []) {
super();
export class DoublyLinkedList<E = any, R = any> extends IterableElementBase<E, R, DoublyLinkedList<E, R>> {
constructor(elements: Iterable<E> | Iterable<R> = [], options?: DoublyLinkedListOptions<E, R>) {
super(options);
this._head = undefined;

@@ -106,3 +100,5 @@ this._tail = undefined;

for (const el of elements) {
this.push(el);
if (this.toElementFn) {
this.push(this.toElementFn(el as R));
} else this.push(el as E);
}

@@ -735,4 +731,4 @@ }

*/
clone(): DoublyLinkedList<E> {
return new DoublyLinkedList(this.values());
clone(): DoublyLinkedList<E, R> {
return new DoublyLinkedList<E, R>(this);
}

@@ -762,4 +758,4 @@

*/
filter(callback: ElementCallback<E, boolean>, thisArg?: any): DoublyLinkedList<E> {
const filteredList = new DoublyLinkedList<E>();
filter(callback: ElementCallback<E, R, boolean, DoublyLinkedList<E, R>>, thisArg?: any): DoublyLinkedList<E, R> {
const filteredList = new DoublyLinkedList<E, R>([], { toElementFn: this.toElementFn });
let index = 0;

@@ -781,20 +777,24 @@ for (const current of this) {

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new DoublyLinkedList by applying a callback function to each element
* in the original list.
* The `map` function takes a callback function and returns a new DoublyLinkedList with the results
* of applying the callback to each element in the original list.
* @param callback - The callback parameter is a function that will be called for each element in the
* DoublyLinkedList. It takes three arguments: the current element, the index of the current element,
* and the DoublyLinkedList itself. The callback function should return a value that will be added to
* the new DoublyLinkedList that
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new `DoublyLinkedList` object that contains the results
* of applying the provided `callback` function to each element in the original `DoublyLinkedList`
* object.
* original DoublyLinkedList. It takes three arguments: current (the current element being
* processed), index (the index of the current element), and this (the original DoublyLinkedList).
* The callback function should return a value of type
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* convert the raw element (`RR`) to the desired element type (`T`). It takes the raw element as
* input and returns the converted element. If this parameter is not provided, the raw element will
* be used as is.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `DoublyLinkedList` class with elements of type `T` and `RR`.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): DoublyLinkedList<T> {
const mappedList = new DoublyLinkedList<T>();
map<EM, RM>(
callback: ElementCallback<E, R, EM, DoublyLinkedList<E, R>>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): DoublyLinkedList<EM, RM> {
const mappedList = new DoublyLinkedList<EM, RM>([], { toElementFn });
let index = 0;

@@ -801,0 +801,0 @@ for (const current of this) {

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

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

@@ -63,13 +63,13 @@

export class SinglyLinkedList<E = any> extends IterableElementBase<E> {
/**
* The constructor initializes a new instance of a class with an optional iterable of elements.
* @param elements - The `elements` parameter is an optional iterable object that contains the
* initial elements to be added to the instance of the class. If no `elements` are provided, an empty
* array will be used as the default value.
*/
constructor(elements: Iterable<E> = []) {
super();
export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R, SinglyLinkedList<E, R>> {
constructor(elements: Iterable<E> | Iterable<R> = [], options?: SinglyLinkedListOptions<E, R>) {
super(options);
if (elements) {
for (const el of elements) this.push(el);
for (const el of elements) {
if (this.toElementFn) {
this.push(this.toElementFn(el as R));
} else {
this.push(el as E);
}
}
}

@@ -678,4 +678,4 @@ }

*/
clone(): SinglyLinkedList<E> {
return new SinglyLinkedList<E>(this.values());
clone(): SinglyLinkedList<E, R> {
return new SinglyLinkedList<E, R>(this, { toElementFn: this.toElementFn });
}

@@ -705,4 +705,4 @@

*/
filter(callback: ElementCallback<E, boolean>, thisArg?: any): SinglyLinkedList<E> {
const filteredList = new SinglyLinkedList<E>();
filter(callback: ElementCallback<E, R, boolean, SinglyLinkedList<E, R>>, thisArg?: any): SinglyLinkedList<E, R> {
const filteredList = new SinglyLinkedList<E, R>([], { toElementFn: this.toElementFn });
let index = 0;

@@ -722,18 +722,26 @@ for (const current of this) {

*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new SinglyLinkedList by applying a callback function to each element
* of the original list.
* The `map` function takes a callback function and returns a new SinglyLinkedList with the results
* of applying the callback to each element in the original list.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the linked list. It takes three arguments:
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new `SinglyLinkedList` object that contains the results
* of applying the provided `callback` function to each element in the original list.
* the original list. It takes three arguments: `current` (the current element being processed),
* `index` (the index of the current element), and `this` (the original list). It should return a
* value
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* convert the raw element (`RR`) to the desired element type (`T`). It takes the raw element as
* input and returns the converted element. If this parameter is not provided, the raw element will
* be used as is.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `SinglyLinkedList` class with the mapped elements.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): SinglyLinkedList<T> {
const mappedList = new SinglyLinkedList<T>();
map<EM, RM>(
callback: ElementCallback<E, R, EM, SinglyLinkedList<E, R>>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): SinglyLinkedList<EM, RM> {
const mappedList = new SinglyLinkedList<EM, RM>([], { toElementFn });
let index = 0;

@@ -740,0 +748,0 @@ for (const current of this) {

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

*/
import type { PriorityQueueOptions } from '../../types';
import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
import { PriorityQueue } from './priority-queue';
export class MaxPriorityQueue<E = any> extends PriorityQueue<E> {
export class MaxPriorityQueue<E = any, R = any> extends PriorityQueue<E, R> {
/**

@@ -20,19 +20,100 @@ * The constructor initializes a PriorityQueue with optional elements and options, including a

* @param options - The `options` parameter is an object that contains additional configuration
* options for the priority queue. In this case, it has a property called `comparator` which is a
* options for the priority queue. In this case, it has a property called `comparator,` which is a
* function used to compare elements in the priority queue.
*/
constructor(
elements: Iterable<E> = [],
options: PriorityQueueOptions<E> = {
comparator: (a: E, b: E) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
} else {
return b - a;
constructor(elements: Iterable<E> | Iterable<R> = [], options?: PriorityQueueOptions<E, R>) {
super(elements, {
comparator: (a: E, b: E): number => {
if (typeof a === 'object' || typeof b === 'object') {
throw TypeError(
`When comparing object types, a custom comparator must be defined in the constructor's options parameter.`
);
}
if (a < b) return 1;
if (a > b) return -1;
return 0;
},
...options
});
}
/**
* The `clone` function returns a new instance of the `MaxPriorityQueue` class with the same
* comparator and toElementFn as the current instance.
* @returns The method is returning a new instance of the MaxPriorityQueue class with the same
* comparator and toElementFn as the current instance.
*/
override clone(): MaxPriorityQueue<E, R> {
return new MaxPriorityQueue<E, R>(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MaxPriorityQueue object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MaxPriorityQueue` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
override filter(
callback: ElementCallback<E, R, boolean, MaxPriorityQueue<E, R>>,
thisArg?: any
): MaxPriorityQueue<E, R> {
const filteredPriorityQueue = new MaxPriorityQueue<E, R>([], {
toElementFn: this.toElementFn,
comparator: this.comparator
});
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredPriorityQueue.add(current);
}
index++;
}
) {
super(elements, options);
return filteredPriorityQueue;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MaxPriorityQueue` class with the mapped elements.
*/
override map<EM, RM>(
callback: ElementCallback<E, R, EM, MaxPriorityQueue<E, R>>,
comparator: Comparator<EM>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): MaxPriorityQueue<EM, RM> {
const mappedPriorityQueue = new MaxPriorityQueue<EM, RM>([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedPriorityQueue.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedPriorityQueue;
}
}

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

*/
import type { PriorityQueueOptions } from '../../types';
import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
import { PriorityQueue } from './priority-queue';
export class MinPriorityQueue<E = any> extends PriorityQueue<E> {
export class MinPriorityQueue<E = any, R = any> extends PriorityQueue<E, R> {
/**

@@ -20,20 +20,89 @@ * The constructor initializes a PriorityQueue with optional elements and options, including a

* @param options - The `options` parameter is an object that contains additional configuration
* options for the priority queue. In this case, it has a property called `comparator` which is a
* options for the priority queue. In this case, it has a property called `comparator,` which is a
* function used to compare elements in the priority queue. The `comparator` function takes two
* parameters `a` and `b`,
* parameters `a` and `b`
*/
constructor(
elements: Iterable<E> = [],
options: PriorityQueueOptions<E> = {
comparator: (a: E, b: E) => {
if (!(typeof a === 'number' && typeof b === 'number')) {
throw new Error('The a, b params of compare function must be number');
} else {
return a - b;
}
constructor(elements: Iterable<E> | Iterable<R> = [], options?: PriorityQueueOptions<E, R>) {
super(elements, options);
}
/**
* The `clone` function returns a new instance of the `MinPriorityQueue` class with the same
* comparator and toElementFn as the original instance.
* @returns The method is returning a new instance of the `MinPriorityQueue` class with the same
* properties as the current instance.
*/
override clone(): MinPriorityQueue<E, R> {
return new MinPriorityQueue<E, R>(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new MinPriorityQueue object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `MinPriorityQueue` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
override filter(
callback: ElementCallback<E, R, boolean, MinPriorityQueue<E, R>>,
thisArg?: any
): MinPriorityQueue<E, R> {
const filteredPriorityQueue = new MinPriorityQueue<E, R>([], {
toElementFn: this.toElementFn,
comparator: this.comparator
});
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredPriorityQueue.add(current);
}
index++;
}
) {
super(elements, options);
return filteredPriorityQueue;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `MinPriorityQueue` class with the mapped elements.
*/
override map<EM, RM>(
callback: ElementCallback<E, R, EM, MinPriorityQueue<E, R>>,
comparator: Comparator<EM>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): MinPriorityQueue<EM, RM> {
const mappedPriorityQueue: MinPriorityQueue<EM, RM> = new MinPriorityQueue<EM, RM>([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedPriorityQueue.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedPriorityQueue;
}
}

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

*/
import type { PriorityQueueOptions } from '../../types';
import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
import { Heap } from '../heap';

@@ -20,7 +20,7 @@

*/
export class PriorityQueue<E = any> extends Heap<E> {
export class PriorityQueue<E = any, R = any> extends Heap<E, R> {
/**
* The constructor initializes a priority queue with optional elements and options.
* @param elements - The `elements` parameter is an iterable object that contains the initial
* elements to be added to the priority queue. It is an optional parameter and if not provided, the
* elements to be added to the priority queue. It is an optional parameter, and if not provided, the
* priority queue will be initialized as empty.

@@ -30,5 +30,82 @@ * @param [options] - The `options` parameter is an optional object that can be used to customize the

*/
constructor(elements: Iterable<E> = [], options?: PriorityQueueOptions<E>) {
constructor(elements: Iterable<E> | Iterable<R> = [], options?: PriorityQueueOptions<E, R>) {
super(elements, options);
}
/**
* The `clone` function returns a new instance of the `PriorityQueue` class with the same comparator
* and toElementFn as the original instance.
* @returns The method is returning a new instance of the `PriorityQueue` class with the same
* elements and properties as the current instance.
*/
override clone(): PriorityQueue<E, R> {
return new PriorityQueue<E, R>(this, { comparator: this.comparator, toElementFn: this.toElementFn });
}
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `filter` function creates a new PriorityQueue object containing elements that pass a given callback
* function.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: the current element, the index of the current element, and the
* heap itself. The callback function should return a boolean value indicating whether the current
* element should be included in the filtered list
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `filter` method is returning a new `PriorityQueue` object that contains the elements that pass
* the filter condition specified by the `callback` function.
*/
override filter(callback: ElementCallback<E, R, boolean, PriorityQueue<E, R>>, thisArg?: any): PriorityQueue<E, R> {
const filteredPriorityQueue = new PriorityQueue<E, R>([], {
toElementFn: this.toElementFn,
comparator: this.comparator
});
let index = 0;
for (const current of this) {
if (callback.call(thisArg, current, index, this)) {
filteredPriorityQueue.add(current);
}
index++;
}
return filteredPriorityQueue;
}
/**
* Time Complexity: O(n log n)
* Space Complexity: O(n)
*
* The `map` function creates a new heap by applying a callback function to each element of the
* original heap.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the heap. It takes three arguments: `el` (the current element), `index` (the index of the current
* element), and `this` (the heap itself). The callback function should return a value of
* @param comparator - The `comparator` parameter is a function that defines the order of the
* elements in the heap. It takes two elements `a` and `b` as arguments and returns a negative number
* if `a` should be placed before `b`, a positive number if `a` should be placed after
* @param [toElementFn] - The `toElementFn` parameter is an optional function that converts the raw
* element `RR` to the desired type `T`. It takes a single argument `rawElement` of type `RR` and
* returns a value of type `T`. This function is used to transform the elements of the original
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new instance of the `PriorityQueue` class with the mapped elements.
*/
override map<EM, RM>(
callback: ElementCallback<E, R, EM, PriorityQueue<E, R>>,
comparator: Comparator<EM>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): PriorityQueue<EM, RM> {
const mappedPriorityQueue: PriorityQueue<EM, RM> = new PriorityQueue<EM, RM>([], { comparator, toElementFn });
let index = 0;
for (const el of this) {
mappedPriorityQueue.add(callback.call(thisArg, el, index, this));
index++;
}
return mappedPriorityQueue;
}
}

@@ -19,5 +19,5 @@ /**

*/
export class Deque<E> extends IterableElementBase<E> {
export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E, R>> {
/**
* The constructor initializes a Deque object with an optional iterable of elements and options.
* The constructor initializes a Deque object with optional iterable of elements and options.
* @param elements - An iterable object (such as an array or a Set) that contains the initial

@@ -32,4 +32,4 @@ * elements to be added to the deque. It can also be an object with a `length` or `size` property

*/
constructor(elements: IterableWithSizeOrLength<E> = [], options?: DequeOptions) {
super();
constructor(elements: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R> = [], options?: DequeOptions<E, R>) {
super(options);

@@ -58,4 +58,8 @@ if (options) {

for (const element of elements) {
this.push(element);
for (const el of elements) {
if (this.toElementFn) {
this.push(this.toElementFn(el as R));
} else {
this.push(el as E);
}
}

@@ -753,4 +757,4 @@ }

*/
clone(): Deque<E> {
return new Deque<E>([...this], { bucketSize: this.bucketSize });
clone(): Deque<E, R> {
return new Deque<E, R>(this, { bucketSize: this.bucketSize, toElementFn: this.toElementFn });
}

@@ -779,4 +783,4 @@

*/
filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Deque<E> {
const newDeque = new Deque<E>([], { bucketSize: this._bucketSize });
filter(predicate: ElementCallback<E, R, boolean, Deque<E, R>>, thisArg?: any): Deque<E, R> {
const newDeque = new Deque<E, R>([], { bucketSize: this._bucketSize, toElementFn: this.toElementFn });
let index = 0;

@@ -796,17 +800,24 @@ for (const el of this) {

*/
/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function creates a new Deque by applying a callback function to each element of the
* original Deque.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the deque. It takes three arguments:
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns a new Deque object with the mapped values.
* The `map` function takes a callback function and applies it to each element in the deque,
* returning a new deque with the results.
* @param callback - The callback parameter is a function that will be called for each element in the
* deque. It takes three arguments: the current element, the index of the element, and the deque
* itself. It should return a value of type EM.
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* transform the raw element (`RM`) into a new element (`EM`) before adding it to the new deque. If
* provided, this function will be called for each raw element in the original deque.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new Deque object with elements of type EM and raw elements of type RM.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): Deque<T> {
const newDeque = new Deque<T>([], { bucketSize: this._bucketSize });
map<EM, RM>(
callback: ElementCallback<E, R, EM, Deque<E, R>>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): Deque<EM, RM> {
const newDeque = new Deque<EM, RM>([], { bucketSize: this._bucketSize, toElementFn });
let index = 0;

@@ -813,0 +824,0 @@ for (const el of this) {

@@ -6,3 +6,3 @@ /**

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

@@ -20,13 +20,10 @@ import { SinglyLinkedList } from '../linked-list';

*/
export class Queue<E = any> extends IterableElementBase<E> {
/**
* The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
* @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
* will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
* initialized as an empty array.
*/
constructor(elements: Iterable<E> = []) {
super();
export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E, R>> {
constructor(elements: Iterable<E> | Iterable<R> = [], options?: QueueOptions<E, R>) {
super(options);
if (elements) {
for (const el of elements) this.push(el);
for (const el of elements) {
if (this.toElementFn) this.push(this.toElementFn(el as R));
else this.push(el as E);
}
}

@@ -195,3 +192,3 @@ }

at(index: number): E | undefined {
return this.elements[index];
return this.elements[index + this._offset];
}

@@ -260,4 +257,4 @@

*/
clone(): Queue<E> {
return new Queue(this.elements.slice(this.offset));
clone(): Queue<E, R> {
return new Queue(this.elements.slice(this.offset), { toElementFn: this.toElementFn });
}

@@ -286,4 +283,4 @@

*/
filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Queue<E> {
const newDeque = new Queue<E>([]);
filter(predicate: ElementCallback<E, R, boolean, Queue<E, R>>, thisArg?: any): Queue<E, R> {
const newDeque = new Queue<E, R>([], { toElementFn: this.toElementFn });
let index = 0;

@@ -304,18 +301,8 @@ for (const el of this) {

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function takes a callback function and applies it to each element in the queue,
* returning a new queue with the results.
* @param callback - The callback parameter is a function that will be called for each element in the
* queue. It takes three arguments: the current element, the index of the current element, and the
* queue itself. The callback function should return a new value that will be added to the new queue.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new `Queue` object with the transformed elements.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): Queue<T> {
const newDeque = new Queue<T>([]);
map<EM, RM>(
callback: ElementCallback<E, R, EM, Queue<E, R>>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): Queue<EM, RM> {
const newDeque = new Queue<EM, RM>([], { toElementFn });
let index = 0;

@@ -341,3 +328,3 @@ for (const el of this) {

protected* _getIterator(): IterableIterator<E> {
for (const item of this.elements) {
for (const item of this.elements.slice(this.offset)) {
yield item;

@@ -354,3 +341,3 @@ }

*/
export class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
export class LinkedListQueue<E = any, R = any> extends SinglyLinkedList<E, R> {
/**

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

*/
override clone(): LinkedListQueue<E> {
return new LinkedListQueue<E>(this.values());
override clone(): LinkedListQueue<E, R> {
return new LinkedListQueue<E, R>(this, { toElementFn: this.toElementFn });
}
}

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

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

@@ -20,13 +20,13 @@

*/
export class Stack<E = any> extends IterableElementBase<E> {
/**
* The constructor initializes an array of elements, which can be provided as an optional parameter.
* @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
* of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
* is provided and is an array, it is assigned to the `_elements
*/
constructor(elements: Iterable<E> = []) {
super();
export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E, R>> {
constructor(elements: Iterable<E> | Iterable<R> = [], options?: StackOptions<E, R>) {
super(options);
if (elements) {
for (const el of elements) this.push(el);
for (const el of elements) {
if (this.toElementFn) {
this.push(this.toElementFn(el as R));
} else {
this.push(el as E);
}
}
}

@@ -197,4 +197,4 @@ }

*/
clone(): Stack<E> {
return new Stack(this.elements.slice());
clone(): Stack<E, R> {
return new Stack<E, R>(this, { toElementFn: this.toElementFn });
}

@@ -223,4 +223,4 @@

*/
filter(predicate: ElementCallback<E, boolean>, thisArg?: any): Stack<E> {
const newStack = new Stack<E>();
filter(predicate: ElementCallback<E, R, boolean, Stack<E, R>>, thisArg?: any): Stack<E, R> {
const newStack = new Stack<E, R>([], { toElementFn: this.toElementFn });
let index = 0;

@@ -242,16 +242,21 @@ for (const el of this) {

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
*
* The `map` function takes a callback function and applies it to each element in the stack,
* returning a new stack with the results.
* @param callback - The `callback` parameter is a function that will be called for each element in
* the stack. It takes three arguments:
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` method is returning a new `Stack` object.
* @param callback - The callback parameter is a function that will be called for each element in the
* stack. It takes three arguments: the current element, the index of the element, and the stack
* itself. It should return a new value that will be added to the new stack.
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* transform the raw element (`RM`) into a new element (`EM`) before pushing it into the new stack.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new Stack object with elements of type EM and raw elements of type RM.
*/
map<T>(callback: ElementCallback<E, T>, thisArg?: any): Stack<T> {
const newStack = new Stack<T>();
map<EM, RM>(
callback: ElementCallback<E, R, EM, Stack<E, R>>,
toElementFn?: (rawElement: RM) => EM,
thisArg?: any
): Stack<EM, RM> {
const newStack = new Stack<EM, RM>([], { toElementFn });
let index = 0;

@@ -258,0 +263,0 @@ for (const el of this) {

@@ -96,3 +96,3 @@ /**

*/
export class Trie extends IterableElementBase<string, Trie> {
export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
/**

@@ -104,4 +104,4 @@ * The constructor function for the Trie class.

*/
constructor(words: Iterable<string> = [], options?: TrieOptions) {
super();
constructor(words: Iterable<string> | Iterable<R> = [], options?: TrieOptions<R>) {
super(options);
if (options) {

@@ -112,3 +112,9 @@ const { caseSensitive } = options;

if (words) {
for (const word of words) this.add(word);
for (const word of words) {
if (this.toElementFn) {
this.add(this.toElementFn(word as R));
} else {
this.add(word as string);
}
}
}

@@ -476,4 +482,4 @@ }

*/
clone(): Trie {
return new Trie(this.values(), { caseSensitive: this.caseSensitive });
clone(): Trie<R> {
return new Trie<R>(this, { caseSensitive: this.caseSensitive, toElementFn: this.toElementFn });
}

@@ -500,4 +506,4 @@

*/
filter(predicate: ElementCallback<string, boolean>, thisArg?: any): Trie {
const results: Trie = new Trie();
filter(predicate: ElementCallback<string, R, boolean, Trie<R>>, thisArg?: any): Trie<R> {
const results = new Trie<R>([], { toElementFn: this.toElementFn, caseSensitive: this.caseSensitive });
let index = 0;

@@ -522,13 +528,22 @@ for (const word of this) {

*
* The `map` function creates a new Trie by applying a callback function to each element in the Trie.
* The `map` function creates a new Trie by applying a callback function to each element in the
* current Trie.
* @param callback - The callback parameter is a function that will be called for each element in the
* Trie. It takes three arguments: the current element in the Trie, the index of the current element,
* and the Trie itself. The callback function should return a new value for the element.
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
* passed as the `this` value to the `callback` function. If `thisArg` is
* @returns The `map` function is returning a new Trie object.
* Trie. It takes four arguments:
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
* convert the raw element (`RM`) into a string representation. This can be useful if the raw element
* is not already a string or if you want to customize how the element is converted into a string. If
* this parameter is
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
* specify the value of `this` within the callback function. It is used to set the context or scope
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
* value of
* @returns a new Trie object.
*/
map(callback: ElementCallback<string, string>, thisArg?: any): Trie {
const newTrie = new Trie();
map<RM>(
callback: ElementCallback<string, R, string, Trie<R>>,
toElementFn?: (rawElement: RM) => string,
thisArg?: any
): Trie<RM> {
const newTrie = new Trie<RM>([], { toElementFn, caseSensitive: this.caseSensitive });
let index = 0;

@@ -535,0 +550,0 @@ for (const word of this) {

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

BTNCallback,
Comparable,
KeyOrNodeOrEntry

@@ -14,3 +13,3 @@ } from '../types';

export interface IBinaryTree<
K extends Comparable,
K = any,
V = any,

@@ -17,0 +16,0 @@ R = [K, V],

import { IterableElementBase, IterableEntryBase } from '../../../data-structures';
export type EntryCallback<K, V, R> = (value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
export type ElementCallback<V, R> = (element: V, index: number, container: IterableElementBase<V>) => R;
export type ElementCallback<E, R, RT, C> = (element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
export type ReduceEntryCallback<K, V, R> = (

@@ -12,7 +12,15 @@ accumulator: R,

) => R;
export type ReduceElementCallback<V, R> = (
accumulator: R,
element: V,
export type ReduceElementCallback<E, R, RT, C> = (
accumulator: RT,
element: E,
index: number,
container: IterableElementBase<V>
) => R;
container: IterableElementBase<E, R, C>
) => RT;
// export type IterableEntryBaseOptions<K, V, R> = {
// toEntryFn?: (rawElement: R) => BTNEntry<K, V>;
// };
export type IterableElementBaseOptions<E, R> = {
toElementFn?: (rawElement: R) => E;
};
import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
import type { AVLTreeOptions } from './avl-tree';
import { Comparable } from "../../utils";
export type AVLTreeMultiMapNodeNested<K extends Comparable, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type AVLTreeMultiMapNested<K extends Comparable, V, R, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type AVLTreeMultiMapNested<K, V, R, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {}
import { AVLTree, AVLTreeNode } from '../../../data-structures';
import { BSTOptions } from './bst';
import { Comparable } from "../../utils";
export type AVLTreeNodeNested<K extends Comparable, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type AVLTreeNested<K extends Comparable, V, R, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type AVLTreeNested<K, V, R, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
import { BTNEntry, IterationType } from '../../common';
import { Comparable } from '../../utils';
export type BinaryTreeNodeNested<K extends Comparable, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type BinaryTreeNested<K extends Comparable, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type BinaryTreeOptions<K, V, R> = {
iterationType?: IterationType
iterationType?: IterationType;
toEntryFn?: (rawElement: R) => BTNEntry<K, V>;
}
import { BST, BSTNode } from '../../../data-structures';
import type { BinaryTreeOptions } from './binary-tree';
import { Comparator } from '../../common';
import { Comparable } from '../../utils';
export type BSTNodeNested<K extends Comparable, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type BSTNested<K extends Comparable, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type BSTNested<K, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

@@ -10,0 +9,0 @@ export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {

import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
import type { BSTOptions } from "./bst";
import { Comparable } from "../../utils";
export type RBTNColor = 'RED' | 'BLACK';
export type RedBlackTreeNodeNested<K extends Comparable, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type RedBlackTreeNested<K extends Comparable, V, R, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type RedBlackTreeNested<K, V, R, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type RBTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures';
import type { RBTreeOptions } from './rb-tree';
import { Comparable } from '../../utils';
export type TreeMultiMapNodeNested<K extends Comparable, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type 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 extends Comparable, V, R, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type TreeMultiMapNested<K, V, R, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type TreeMultiMapOptions<K, V, R> = RBTreeOptions<K, V, R> & {}
import { Comparator } from '../../common';
import { IterableElementBaseOptions } from '../base';
export type HeapOptions<T> = { comparator?: Comparator<T> };
export type HeapOptions<E, R> = IterableElementBaseOptions<E, R> & {
comparator?: Comparator<E>;
};

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

export {};
import { IterableElementBaseOptions } from '../base';
export type DoublyLinkedListOptions<E, R> = IterableElementBaseOptions<E, R> & {};

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

export {};
import { IterableElementBaseOptions } from '../base';
export type SinglyLinkedListOptions<E, R> = IterableElementBaseOptions<E, R> & {};
import { HeapOptions } from '../heap';
export type PriorityQueueOptions<T> = HeapOptions<T> & {};
export type PriorityQueueOptions<E, R> = HeapOptions<E, R> & {};

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

export type DequeOptions = { bucketSize?: number };
import { IterableElementBaseOptions } from '../base';
export type DequeOptions<E, R> = { bucketSize?: number } & IterableElementBaseOptions<E, R>;

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

export {};
import { IterableElementBaseOptions } from '../base';
export type QueueOptions<E, R> = IterableElementBaseOptions<E, R> & {};

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

export {};
import { IterableElementBaseOptions } from '../base';
export type StackOptions<E, R> = IterableElementBaseOptions<E, R> & {};

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

export type TrieOptions = { caseSensitive?: boolean };
import { IterableElementBaseOptions } from '../base';
export type TrieOptions<R> = { caseSensitive?: boolean } & IterableElementBaseOptions<string, R>;

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