Socket
Socket
Sign inDemoInstall

data-structure-typed

Package Overview
Dependencies
Maintainers
1
Versions
201
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-structure-typed - npm Package Compare versions

Comparing version 1.52.1 to 1.52.2

324

benchmark/report.json

@@ -6,11 +6,11 @@ {

"test name": "100,000 add",
"time taken (ms)": "6.09",
"executions per sec": "164.12",
"sample deviation": "1.35e-4"
"time taken (ms)": "8.07",
"executions per sec": "123.93",
"sample deviation": "0.00"
},
{
"test name": "100,000 add & poll",
"time taken (ms)": "34.55",
"executions per sec": "28.94",
"sample deviation": "6.43e-4"
"time taken (ms)": "45.32",
"executions per sec": "22.07",
"sample deviation": "0.01"
}

@@ -24,4 +24,4 @@ ],

"test name": "100,000 add",
"time taken (ms)": "76.73",
"executions per sec": "13.03",
"time taken (ms)": "77.03",
"executions per sec": "12.98",
"sample deviation": "0.00"

@@ -31,4 +31,4 @@ },

"test name": "100,000 add randomly",
"time taken (ms)": "80.67",
"executions per sec": "12.40",
"time taken (ms)": "83.26",
"executions per sec": "12.01",
"sample deviation": "0.00"

@@ -38,23 +38,23 @@ },

"test name": "100,000 get",
"time taken (ms)": "110.86",
"executions per sec": "9.02",
"sample deviation": "0.00"
"time taken (ms)": "120.25",
"executions per sec": "8.32",
"sample deviation": "0.01"
},
{
"test name": "100,000 iterator",
"time taken (ms)": "24.99",
"executions per sec": "40.02",
"sample deviation": "0.00"
"time taken (ms)": "26.32",
"executions per sec": "37.99",
"sample deviation": "0.01"
},
{
"test name": "100,000 add & delete orderly",
"time taken (ms)": "152.66",
"executions per sec": "6.55",
"sample deviation": "0.00"
"time taken (ms)": "161.68",
"executions per sec": "6.19",
"sample deviation": "0.01"
},
{
"test name": "100,000 add & delete randomly",
"time taken (ms)": "230.75",
"executions per sec": "4.33",
"sample deviation": "0.00"
"time taken (ms)": "268.63",
"executions per sec": "3.72",
"sample deviation": "0.03"
}

@@ -68,17 +68,17 @@ ],

"test name": "1,000,000 push",
"time taken (ms)": "39.27",
"executions per sec": "25.46",
"sample deviation": "0.01"
"time taken (ms)": "45.55",
"executions per sec": "21.96",
"sample deviation": "0.02"
},
{
"test name": "100,000 push & shift",
"time taken (ms)": "4.53",
"executions per sec": "220.81",
"sample deviation": "4.84e-4"
"time taken (ms)": "5.54",
"executions per sec": "180.36",
"sample deviation": "0.00"
},
{
"test name": "Native JS Array 100,000 push & shift",
"time taken (ms)": "1948.05",
"executions per sec": "0.51",
"sample deviation": "0.02"
"time taken (ms)": "2467.71",
"executions per sec": "0.41",
"sample deviation": "0.20"
}

@@ -92,4 +92,4 @@ ],

"test name": "1,000,000 push",
"time taken (ms)": "23.22",
"executions per sec": "43.06",
"time taken (ms)": "25.36",
"executions per sec": "39.43",
"sample deviation": "0.00"

@@ -99,4 +99,4 @@ },

"test name": "1,000,000 push & pop",
"time taken (ms)": "29.68",
"executions per sec": "33.69",
"time taken (ms)": "32.13",
"executions per sec": "31.12",
"sample deviation": "0.00"

@@ -106,4 +106,4 @@ },

"test name": "1,000,000 push & shift",
"time taken (ms)": "29.33",
"executions per sec": "34.09",
"time taken (ms)": "33.42",
"executions per sec": "29.92",
"sample deviation": "0.00"

@@ -113,23 +113,23 @@ },

"test name": "100,000 push & shift",
"time taken (ms)": "3.10",
"executions per sec": "323.01",
"sample deviation": "2.47e-4"
"time taken (ms)": "3.59",
"executions per sec": "278.92",
"sample deviation": "3.21e-4"
},
{
"test name": "Native JS Array 100,000 push & shift",
"time taken (ms)": "1942.12",
"executions per sec": "0.51",
"sample deviation": "0.02"
"time taken (ms)": "2427.03",
"executions per sec": "0.41",
"sample deviation": "0.21"
},
{
"test name": "100,000 unshift & shift",
"time taken (ms)": "2.77",
"executions per sec": "360.50",
"sample deviation": "2.43e-4"
"time taken (ms)": "3.56",
"executions per sec": "280.81",
"sample deviation": "3.81e-4"
},
{
"test name": "Native JS Array 100,000 unshift & shift",
"time taken (ms)": "3835.21",
"executions per sec": "0.26",
"sample deviation": "0.03"
"time taken (ms)": "4464.18",
"executions per sec": "0.22",
"sample deviation": "0.07"
}

@@ -143,53 +143,53 @@ ],

"test name": "1,000,000 set",
"time taken (ms)": "112.38",
"executions per sec": "8.90",
"sample deviation": "0.02"
"time taken (ms)": "313.05",
"executions per sec": "3.19",
"sample deviation": "0.07"
},
{
"test name": "Native JS Map 1,000,000 set",
"time taken (ms)": "199.97",
"executions per sec": "5.00",
"sample deviation": "0.01"
"time taken (ms)": "224.48",
"executions per sec": "4.45",
"sample deviation": "0.05"
},
{
"test name": "Native JS Set 1,000,000 add",
"time taken (ms)": "163.34",
"executions per sec": "6.12",
"sample deviation": "0.01"
"time taken (ms)": "203.46",
"executions per sec": "4.91",
"sample deviation": "0.05"
},
{
"test name": "1,000,000 set & get",
"time taken (ms)": "109.86",
"executions per sec": "9.10",
"sample deviation": "0.02"
"time taken (ms)": "281.79",
"executions per sec": "3.55",
"sample deviation": "0.07"
},
{
"test name": "Native JS Map 1,000,000 set & get",
"time taken (ms)": "255.33",
"executions per sec": "3.92",
"sample deviation": "0.00"
"time taken (ms)": "289.57",
"executions per sec": "3.45",
"sample deviation": "0.03"
},
{
"test name": "Native JS Set 1,000,000 add & has",
"time taken (ms)": "163.91",
"executions per sec": "6.10",
"sample deviation": "0.00"
"time taken (ms)": "195.73",
"executions per sec": "5.11",
"sample deviation": "0.02"
},
{
"test name": "1,000,000 ObjKey set & get",
"time taken (ms)": "317.89",
"executions per sec": "3.15",
"sample deviation": "0.04"
"time taken (ms)": "348.39",
"executions per sec": "2.87",
"sample deviation": "0.03"
},
{
"test name": "Native JS Map 1,000,000 ObjKey set & get",
"time taken (ms)": "282.99",
"executions per sec": "3.53",
"sample deviation": "0.03"
"time taken (ms)": "315.23",
"executions per sec": "3.17",
"sample deviation": "0.04"
},
{
"test name": "Native JS Set 1,000,000 ObjKey add & has",
"time taken (ms)": "253.93",
"executions per sec": "3.94",
"sample deviation": "0.03"
"time taken (ms)": "335.83",
"executions per sec": "2.98",
"sample deviation": "0.06"
}

@@ -203,11 +203,11 @@ ],

"test name": "100,000 push",
"time taken (ms)": "43.71",
"executions per sec": "22.88",
"sample deviation": "7.33e-4"
"time taken (ms)": "48.09",
"executions per sec": "20.79",
"sample deviation": "0.00"
},
{
"test name": "100,000 getWords",
"time taken (ms)": "83.63",
"executions per sec": "11.96",
"sample deviation": "0.00"
"time taken (ms)": "93.17",
"executions per sec": "10.73",
"sample deviation": "0.01"
}

@@ -221,4 +221,4 @@ ],

"test name": "100,000 add",
"time taken (ms)": "271.93",
"executions per sec": "3.68",
"time taken (ms)": "278.91",
"executions per sec": "3.59",
"sample deviation": "0.01"

@@ -228,29 +228,29 @@ },

"test name": "100,000 add randomly",
"time taken (ms)": "318.27",
"executions per sec": "3.14",
"sample deviation": "0.00"
"time taken (ms)": "350.65",
"executions per sec": "2.85",
"sample deviation": "0.02"
},
{
"test name": "100,000 get",
"time taken (ms)": "128.85",
"executions per sec": "7.76",
"sample deviation": "0.00"
"time taken (ms)": "154.97",
"executions per sec": "6.45",
"sample deviation": "0.03"
},
{
"test name": "100,000 iterator",
"time taken (ms)": "29.09",
"executions per sec": "34.38",
"sample deviation": "0.00"
"time taken (ms)": "34.78",
"executions per sec": "28.75",
"sample deviation": "0.02"
},
{
"test name": "100,000 add & delete orderly",
"time taken (ms)": "435.48",
"executions per sec": "2.30",
"sample deviation": "7.44e-4"
"time taken (ms)": "445.45",
"executions per sec": "2.24",
"sample deviation": "0.00"
},
{
"test name": "100,000 add & delete randomly",
"time taken (ms)": "578.70",
"executions per sec": "1.73",
"sample deviation": "0.00"
"time taken (ms)": "616.61",
"executions per sec": "1.62",
"sample deviation": "0.03"
}

@@ -264,28 +264,28 @@ ],

"test name": "10,000 RBTree add randomly",
"time taken (ms)": "6.69",
"executions per sec": "149.54",
"sample deviation": "1.06e-4"
"time taken (ms)": "7.07",
"executions per sec": "141.45",
"sample deviation": "7.19e-4"
},
{
"test name": "10,000 RBTree get randomly",
"time taken (ms)": "9.19",
"executions per sec": "108.82",
"sample deviation": "1.43e-4"
"time taken (ms)": "9.33",
"executions per sec": "107.21",
"sample deviation": "1.48e-4"
},
{
"test name": "10,000 RBTree add & delete randomly",
"time taken (ms)": "18.54",
"executions per sec": "53.94",
"sample deviation": "1.73e-4"
"time taken (ms)": "18.60",
"executions per sec": "53.77",
"sample deviation": "3.93e-4"
},
{
"test name": "10,000 AVLTree add randomly",
"time taken (ms)": "23.70",
"executions per sec": "42.20",
"sample deviation": "1.88e-4"
"time taken (ms)": "30.39",
"executions per sec": "32.91",
"sample deviation": "0.01"
},
{
"test name": "10,000 AVLTree get randomly",
"time taken (ms)": "9.89",
"executions per sec": "101.11",
"time taken (ms)": "10.70",
"executions per sec": "93.49",
"sample deviation": "0.00"

@@ -295,5 +295,5 @@ },

"test name": "10,000 AVLTree add & delete randomly",
"time taken (ms)": "44.44",
"executions per sec": "22.50",
"sample deviation": "4.30e-4"
"time taken (ms)": "46.04",
"executions per sec": "21.72",
"sample deviation": "0.00"
}

@@ -307,11 +307,11 @@ ],

"test name": "1,000 addVertex",
"time taken (ms)": "0.10",
"executions per sec": "9766.65",
"sample deviation": "9.83e-7"
"time taken (ms)": "0.13",
"executions per sec": "7502.53",
"sample deviation": "6.69e-5"
},
{
"test name": "1,000 addEdge",
"time taken (ms)": "6.15",
"executions per sec": "162.57",
"sample deviation": "7.99e-4"
"time taken (ms)": "7.93",
"executions per sec": "126.13",
"sample deviation": "0.00"
},

@@ -321,9 +321,9 @@ {

"time taken (ms)": "0.05",
"executions per sec": "2.18e+4",
"sample deviation": "4.52e-7"
"executions per sec": "2.19e+4",
"sample deviation": "1.17e-5"
},
{
"test name": "1,000 getEdge",
"time taken (ms)": "22.70",
"executions per sec": "44.06",
"time taken (ms)": "18.65",
"executions per sec": "53.61",
"sample deviation": "0.00"

@@ -333,4 +333,4 @@ },

"test name": "tarjan",
"time taken (ms)": "203.00",
"executions per sec": "4.93",
"time taken (ms)": "158.86",
"executions per sec": "6.30",
"sample deviation": "0.01"

@@ -340,5 +340,5 @@ },

"test name": "topologicalSort",
"time taken (ms)": "176.40",
"executions per sec": "5.67",
"sample deviation": "0.00"
"time taken (ms)": "141.91",
"executions per sec": "7.05",
"sample deviation": "0.01"
}

@@ -352,23 +352,23 @@ ],

"test name": "1,000,000 push",
"time taken (ms)": "222.02",
"executions per sec": "4.50",
"sample deviation": "0.07"
"time taken (ms)": "211.26",
"executions per sec": "4.73",
"sample deviation": "0.03"
},
{
"test name": "1,000,000 unshift",
"time taken (ms)": "220.41",
"executions per sec": "4.54",
"sample deviation": "0.05"
"time taken (ms)": "216.90",
"executions per sec": "4.61",
"sample deviation": "0.07"
},
{
"test name": "1,000,000 unshift & shift",
"time taken (ms)": "185.31",
"executions per sec": "5.40",
"sample deviation": "0.01"
"time taken (ms)": "208.45",
"executions per sec": "4.80",
"sample deviation": "0.05"
},
{
"test name": "1,000,000 addBefore",
"time taken (ms)": "317.20",
"executions per sec": "3.15",
"sample deviation": "0.07"
"time taken (ms)": "316.55",
"executions per sec": "3.16",
"sample deviation": "0.06"
}

@@ -382,16 +382,16 @@ ],

"test name": "1,000,000 push & shift",
"time taken (ms)": "204.82",
"executions per sec": "4.88",
"sample deviation": "0.09"
"time taken (ms)": "222.81",
"executions per sec": "4.49",
"sample deviation": "0.08"
},
{
"test name": "10,000 push & pop",
"time taken (ms)": "221.88",
"executions per sec": "4.51",
"sample deviation": "0.03"
"time taken (ms)": "235.91",
"executions per sec": "4.24",
"sample deviation": "0.01"
},
{
"test name": "10,000 addBefore",
"time taken (ms)": "247.28",
"executions per sec": "4.04",
"time taken (ms)": "250.57",
"executions per sec": "3.99",
"sample deviation": "0.01"

@@ -406,11 +406,11 @@ }

"test name": "100,000 add",
"time taken (ms)": "26.97",
"executions per sec": "37.08",
"sample deviation": "7.97e-4"
"time taken (ms)": "27.64",
"executions per sec": "36.17",
"sample deviation": "8.81e-4"
},
{
"test name": "100,000 add & poll",
"time taken (ms)": "74.55",
"executions per sec": "13.41",
"sample deviation": "5.19e-4"
"time taken (ms)": "75.52",
"executions per sec": "13.24",
"sample deviation": "9.91e-4"
}

@@ -424,10 +424,10 @@ ],

"test name": "1,000,000 push",
"time taken (ms)": "35.54",
"executions per sec": "28.14",
"sample deviation": "0.00"
"time taken (ms)": "40.47",
"executions per sec": "24.71",
"sample deviation": "0.01"
},
{
"test name": "1,000,000 push & pop",
"time taken (ms)": "44.89",
"executions per sec": "22.27",
"time taken (ms)": "47.47",
"executions per sec": "21.07",
"sample deviation": "0.01"

@@ -434,0 +434,0 @@ }

@@ -11,3 +11,3 @@ # Changelog

## [v1.52.1](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)
## [v1.52.2](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)

@@ -14,0 +14,0 @@ ## [v1.51.5](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...v1.51.5) (18 January 2024)

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

if (node) {
const left = node.left ? (_a = depths.get(node.left)) !== null && _a !== void 0 ? _a : -1 : -1;
const right = node.right ? (_b = depths.get(node.right)) !== null && _b !== void 0 ? _b : -1 : -1;
const left = node.left ? ((_a = depths.get(node.left)) !== null && _a !== void 0 ? _a : -1) : -1;
const right = node.right ? ((_b = depths.get(node.right)) !== null && _b !== void 0 ? _b : -1) : -1;
if (Math.abs(left - right) > 1)

@@ -690,0 +690,0 @@ return false;

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

get last(): E | undefined;
_autoCompactRatio: number;
/**
* This function returns the value of the autoCompactRatio property.
* @returns The `autoCompactRatio` property of the object, which is a number.
*/
get autoCompactRatio(): number;
/**
* The above function sets the autoCompactRatio property to a specified number in TypeScript.
* @param {number} v - The parameter `v` represents the value that will be assigned to the
* `_autoCompactRatio` property.
*/
set autoCompactRatio(v: number);
/**
* Time Complexity: O(n)

@@ -164,2 +176,8 @@ * Space Complexity: O(n)

/**
* The `compact` function in TypeScript slices the elements array based on the offset and resets the
* offset to zero.
* @returns The `compact()` method is returning a boolean value of `true`.
*/
compact(): boolean;
/**
* Time Complexity: O(n)

@@ -166,0 +184,0 @@ * Space Complexity: O(n)

@@ -20,2 +20,7 @@ "use strict";

this._offset = 0;
this._autoCompactRatio = 0.5;
if (options) {
const { autoCompactRatio = 0.5 } = options;
this._autoCompactRatio = autoCompactRatio;
}
if (elements) {

@@ -82,2 +87,17 @@ for (const el of elements) {

/**
* This function returns the value of the autoCompactRatio property.
* @returns The `autoCompactRatio` property of the object, which is a number.
*/
get autoCompactRatio() {
return this._autoCompactRatio;
}
/**
* The above function sets the autoCompactRatio property to a specified number in TypeScript.
* @param {number} v - The parameter `v` represents the value that will be assigned to the
* `_autoCompactRatio` property.
*/
set autoCompactRatio(v) {
this._autoCompactRatio = v;
}
/**
* Time Complexity: O(n)

@@ -132,8 +152,4 @@ * Space Complexity: O(n)

this._offset += 1;
if (this.offset * 2 < this.elements.length)
return first;
// only delete dequeued elements when reaching half size
// to decrease latency of shifting elements.
this._elements = this.elements.slice(this.offset);
this._offset = 0;
if (this.offset / this.elements.length > this.autoCompactRatio)
this.compact();
return first;

@@ -215,2 +231,12 @@ }

/**
* The `compact` function in TypeScript slices the elements array based on the offset and resets the
* offset to zero.
* @returns The `compact()` method is returning a boolean value of `true`.
*/
compact() {
this._elements = this.elements.slice(this.offset);
this._offset = 0;
return true;
}
/**
* Time Complexity: O(n)

@@ -217,0 +243,0 @@ * Space Complexity: O(n)

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

@@ -674,4 +674,4 @@ import { BinaryTree, BinaryTreeNode } from './binary-tree';

if (node) {
const left = node.left ? depths.get(node.left) ?? -1 : -1;
const right = node.right ? depths.get(node.right) ?? -1 : -1;
const left = node.left ? (depths.get(node.left) ?? -1) : -1;
const right = node.right ? (depths.get(node.right) ?? -1) : -1;
if (Math.abs(left - right) > 1)

@@ -678,0 +678,0 @@ return false;

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

get last(): E | undefined;
_autoCompactRatio: number;
/**
* This function returns the value of the autoCompactRatio property.
* @returns The `autoCompactRatio` property of the object, which is a number.
*/
get autoCompactRatio(): number;
/**
* The above function sets the autoCompactRatio property to a specified number in TypeScript.
* @param {number} v - The parameter `v` represents the value that will be assigned to the
* `_autoCompactRatio` property.
*/
set autoCompactRatio(v: number);
/**
* Time Complexity: O(n)

@@ -164,2 +176,8 @@ * Space Complexity: O(n)

/**
* The `compact` function in TypeScript slices the elements array based on the offset and resets the
* offset to zero.
* @returns The `compact()` method is returning a boolean value of `true`.
*/
compact(): boolean;
/**
* Time Complexity: O(n)

@@ -166,0 +184,0 @@ * Space Complexity: O(n)

@@ -15,2 +15,6 @@ import { IterableElementBase } from '../base';

super(options);
if (options) {
const { autoCompactRatio = 0.5 } = options;
this._autoCompactRatio = autoCompactRatio;
}
if (elements) {

@@ -78,3 +82,19 @@ for (const el of elements) {

}
_autoCompactRatio = 0.5;
/**
* This function returns the value of the autoCompactRatio property.
* @returns The `autoCompactRatio` property of the object, which is a number.
*/
get autoCompactRatio() {
return this._autoCompactRatio;
}
/**
* The above function sets the autoCompactRatio property to a specified number in TypeScript.
* @param {number} v - The parameter `v` represents the value that will be assigned to the
* `_autoCompactRatio` property.
*/
set autoCompactRatio(v) {
this._autoCompactRatio = v;
}
/**
* Time Complexity: O(n)

@@ -129,8 +149,4 @@ * Space Complexity: O(n)

this._offset += 1;
if (this.offset * 2 < this.elements.length)
return first;
// only delete dequeued elements when reaching half size
// to decrease latency of shifting elements.
this._elements = this.elements.slice(this.offset);
this._offset = 0;
if (this.offset / this.elements.length > this.autoCompactRatio)
this.compact();
return first;

@@ -212,2 +228,12 @@ }

/**
* The `compact` function in TypeScript slices the elements array based on the offset and resets the
* offset to zero.
* @returns The `compact()` method is returning a boolean value of `true`.
*/
compact() {
this._elements = this.elements.slice(this.offset);
this._offset = 0;
return true;
}
/**
* Time Complexity: O(n)

@@ -214,0 +240,0 @@ * Space Complexity: O(n)

import { IterableElementBaseOptions } from '../base';
export type QueueOptions<E, R> = IterableElementBaseOptions<E, R> & {};
export type QueueOptions<E, R> = IterableElementBaseOptions<E, R> & {
autoCompactRatio?: number;
};
{
"name": "data-structure-typed",
"version": "1.52.1",
"version": "1.52.2",
"description": "Javascript Data Structure. Heap, Binary Tree, Red Black Tree, Linked List, Deque, Trie, HashMap, Directed Graph, Undirected Graph, Binary Search Tree(BST), AVL Tree, Priority Queue, Graph, Queue, Tree Multiset, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue, Stack. Benchmark compared with C++ STL. API aligned with ES6 and Java.util. Usability is comparable to Python",

@@ -69,7 +69,7 @@ "main": "dist/cjs/index.js",

"auto-changelog": "^2.4.0",
"avl-tree-typed": "^1.52.0",
"avl-tree-typed": "^1.52.1",
"benchmark": "^2.1.4",
"binary-tree-typed": "^1.52.0",
"bst-typed": "^1.52.0",
"data-structure-typed": "^1.52.0",
"binary-tree-typed": "^1.52.1",
"bst-typed": "^1.52.1",
"data-structure-typed": "^1.52.1",
"dependency-cruiser": "^14.1.0",

@@ -83,7 +83,7 @@ "doctoc": "^2.2.1",

"fast-glob": "^3.3.1",
"heap-typed": "^1.52.0",
"heap-typed": "^1.52.1",
"istanbul-badges-readme": "^1.8.5",
"jest": "^29.7.0",
"js-sdsl": "^4.4.2",
"prettier": "^3.0.3",
"prettier": "^3.3.3",
"ts-jest": "^29.1.1",

@@ -90,0 +90,0 @@ "ts-loader": "^9.4.4",

@@ -826,39 +826,39 @@ # data-structure-typed

<div class='collapsible level0' ><span class='json-to-html-label'>heap</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>6.09</td><td>164.12</td><td>1.35e-4</td></tr><tr><td>100,000 add & poll</td><td>34.55</td><td>28.94</td><td>6.43e-4</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>8.07</td><td>123.93</td><td>0.00</td></tr><tr><td>100,000 add & poll</td><td>45.32</td><td>22.07</td><td>0.01</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>rb-tree</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>76.73</td><td>13.03</td><td>0.00</td></tr><tr><td>100,000 add randomly</td><td>80.67</td><td>12.40</td><td>0.00</td></tr><tr><td>100,000 get</td><td>110.86</td><td>9.02</td><td>0.00</td></tr><tr><td>100,000 iterator</td><td>24.99</td><td>40.02</td><td>0.00</td></tr><tr><td>100,000 add & delete orderly</td><td>152.66</td><td>6.55</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>230.75</td><td>4.33</td><td>0.00</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>77.03</td><td>12.98</td><td>0.00</td></tr><tr><td>100,000 add randomly</td><td>83.26</td><td>12.01</td><td>0.00</td></tr><tr><td>100,000 get</td><td>120.25</td><td>8.32</td><td>0.01</td></tr><tr><td>100,000 iterator</td><td>26.32</td><td>37.99</td><td>0.01</td></tr><tr><td>100,000 add & delete orderly</td><td>161.68</td><td>6.19</td><td>0.01</td></tr><tr><td>100,000 add & delete randomly</td><td>268.63</td><td>3.72</td><td>0.03</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>queue</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>39.27</td><td>25.46</td><td>0.01</td></tr><tr><td>100,000 push & shift</td><td>4.53</td><td>220.81</td><td>4.84e-4</td></tr><tr><td>Native JS Array 100,000 push & shift</td><td>1948.05</td><td>0.51</td><td>0.02</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>45.55</td><td>21.96</td><td>0.02</td></tr><tr><td>100,000 push & shift</td><td>5.54</td><td>180.36</td><td>0.00</td></tr><tr><td>Native JS Array 100,000 push & shift</td><td>2467.71</td><td>0.41</td><td>0.20</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>deque</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>23.22</td><td>43.06</td><td>0.00</td></tr><tr><td>1,000,000 push & pop</td><td>29.68</td><td>33.69</td><td>0.00</td></tr><tr><td>1,000,000 push & shift</td><td>29.33</td><td>34.09</td><td>0.00</td></tr><tr><td>100,000 push & shift</td><td>3.10</td><td>323.01</td><td>2.47e-4</td></tr><tr><td>Native JS Array 100,000 push & shift</td><td>1942.12</td><td>0.51</td><td>0.02</td></tr><tr><td>100,000 unshift & shift</td><td>2.77</td><td>360.50</td><td>2.43e-4</td></tr><tr><td>Native JS Array 100,000 unshift & shift</td><td>3835.21</td><td>0.26</td><td>0.03</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>25.36</td><td>39.43</td><td>0.00</td></tr><tr><td>1,000,000 push & pop</td><td>32.13</td><td>31.12</td><td>0.00</td></tr><tr><td>1,000,000 push & shift</td><td>33.42</td><td>29.92</td><td>0.00</td></tr><tr><td>100,000 push & shift</td><td>3.59</td><td>278.92</td><td>3.21e-4</td></tr><tr><td>Native JS Array 100,000 push & shift</td><td>2427.03</td><td>0.41</td><td>0.21</td></tr><tr><td>100,000 unshift & shift</td><td>3.56</td><td>280.81</td><td>3.81e-4</td></tr><tr><td>Native JS Array 100,000 unshift & shift</td><td>4464.18</td><td>0.22</td><td>0.07</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>112.38</td><td>8.90</td><td>0.02</td></tr><tr><td>Native JS Map 1,000,000 set</td><td>199.97</td><td>5.00</td><td>0.01</td></tr><tr><td>Native JS Set 1,000,000 add</td><td>163.34</td><td>6.12</td><td>0.01</td></tr><tr><td>1,000,000 set & get</td><td>109.86</td><td>9.10</td><td>0.02</td></tr><tr><td>Native JS Map 1,000,000 set & get</td><td>255.33</td><td>3.92</td><td>0.00</td></tr><tr><td>Native JS Set 1,000,000 add & has</td><td>163.91</td><td>6.10</td><td>0.00</td></tr><tr><td>1,000,000 ObjKey set & get</td><td>317.89</td><td>3.15</td><td>0.04</td></tr><tr><td>Native JS Map 1,000,000 ObjKey set & get</td><td>282.99</td><td>3.53</td><td>0.03</td></tr><tr><td>Native JS Set 1,000,000 ObjKey add & has</td><td>253.93</td><td>3.94</td><td>0.03</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>313.05</td><td>3.19</td><td>0.07</td></tr><tr><td>Native JS Map 1,000,000 set</td><td>224.48</td><td>4.45</td><td>0.05</td></tr><tr><td>Native JS Set 1,000,000 add</td><td>203.46</td><td>4.91</td><td>0.05</td></tr><tr><td>1,000,000 set & get</td><td>281.79</td><td>3.55</td><td>0.07</td></tr><tr><td>Native JS Map 1,000,000 set & get</td><td>289.57</td><td>3.45</td><td>0.03</td></tr><tr><td>Native JS Set 1,000,000 add & has</td><td>195.73</td><td>5.11</td><td>0.02</td></tr><tr><td>1,000,000 ObjKey set & get</td><td>348.39</td><td>2.87</td><td>0.03</td></tr><tr><td>Native JS Map 1,000,000 ObjKey set & get</td><td>315.23</td><td>3.17</td><td>0.04</td></tr><tr><td>Native JS Set 1,000,000 ObjKey add & has</td><td>335.83</td><td>2.98</td><td>0.06</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>trie</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 push</td><td>43.71</td><td>22.88</td><td>7.33e-4</td></tr><tr><td>100,000 getWords</td><td>83.63</td><td>11.96</td><td>0.00</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 push</td><td>48.09</td><td>20.79</td><td>0.00</td></tr><tr><td>100,000 getWords</td><td>93.17</td><td>10.73</td><td>0.01</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>avl-tree</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>271.93</td><td>3.68</td><td>0.01</td></tr><tr><td>100,000 add randomly</td><td>318.27</td><td>3.14</td><td>0.00</td></tr><tr><td>100,000 get</td><td>128.85</td><td>7.76</td><td>0.00</td></tr><tr><td>100,000 iterator</td><td>29.09</td><td>34.38</td><td>0.00</td></tr><tr><td>100,000 add & delete orderly</td><td>435.48</td><td>2.30</td><td>7.44e-4</td></tr><tr><td>100,000 add & delete randomly</td><td>578.70</td><td>1.73</td><td>0.00</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>278.91</td><td>3.59</td><td>0.01</td></tr><tr><td>100,000 add randomly</td><td>350.65</td><td>2.85</td><td>0.02</td></tr><tr><td>100,000 get</td><td>154.97</td><td>6.45</td><td>0.03</td></tr><tr><td>100,000 iterator</td><td>34.78</td><td>28.75</td><td>0.02</td></tr><tr><td>100,000 add & delete orderly</td><td>445.45</td><td>2.24</td><td>0.00</td></tr><tr><td>100,000 add & delete randomly</td><td>616.61</td><td>1.62</td><td>0.03</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>binary-tree-overall</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 RBTree add randomly</td><td>6.69</td><td>149.54</td><td>1.06e-4</td></tr><tr><td>10,000 RBTree get randomly</td><td>9.19</td><td>108.82</td><td>1.43e-4</td></tr><tr><td>10,000 RBTree add & delete randomly</td><td>18.54</td><td>53.94</td><td>1.73e-4</td></tr><tr><td>10,000 AVLTree add randomly</td><td>23.70</td><td>42.20</td><td>1.88e-4</td></tr><tr><td>10,000 AVLTree get randomly</td><td>9.89</td><td>101.11</td><td>0.00</td></tr><tr><td>10,000 AVLTree add & delete randomly</td><td>44.44</td><td>22.50</td><td>4.30e-4</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>10,000 RBTree add randomly</td><td>7.07</td><td>141.45</td><td>7.19e-4</td></tr><tr><td>10,000 RBTree get randomly</td><td>9.33</td><td>107.21</td><td>1.48e-4</td></tr><tr><td>10,000 RBTree add & delete randomly</td><td>18.60</td><td>53.77</td><td>3.93e-4</td></tr><tr><td>10,000 AVLTree add randomly</td><td>30.39</td><td>32.91</td><td>0.01</td></tr><tr><td>10,000 AVLTree get randomly</td><td>10.70</td><td>93.49</td><td>0.00</td></tr><tr><td>10,000 AVLTree add & delete randomly</td><td>46.04</td><td>21.72</td><td>0.00</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>directed-graph</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.10</td><td>9766.65</td><td>9.83e-7</td></tr><tr><td>1,000 addEdge</td><td>6.15</td><td>162.57</td><td>7.99e-4</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.18e+4</td><td>4.52e-7</td></tr><tr><td>1,000 getEdge</td><td>22.70</td><td>44.06</td><td>0.00</td></tr><tr><td>tarjan</td><td>203.00</td><td>4.93</td><td>0.01</td></tr><tr><td>topologicalSort</td><td>176.40</td><td>5.67</td><td>0.00</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000 addVertex</td><td>0.13</td><td>7502.53</td><td>6.69e-5</td></tr><tr><td>1,000 addEdge</td><td>7.93</td><td>126.13</td><td>0.00</td></tr><tr><td>1,000 getVertex</td><td>0.05</td><td>2.19e+4</td><td>1.17e-5</td></tr><tr><td>1,000 getEdge</td><td>18.65</td><td>53.61</td><td>0.00</td></tr><tr><td>tarjan</td><td>158.86</td><td>6.30</td><td>0.01</td></tr><tr><td>topologicalSort</td><td>141.91</td><td>7.05</td><td>0.01</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>doubly-linked-list</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>222.02</td><td>4.50</td><td>0.07</td></tr><tr><td>1,000,000 unshift</td><td>220.41</td><td>4.54</td><td>0.05</td></tr><tr><td>1,000,000 unshift & shift</td><td>185.31</td><td>5.40</td><td>0.01</td></tr><tr><td>1,000,000 addBefore</td><td>317.20</td><td>3.15</td><td>0.07</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>211.26</td><td>4.73</td><td>0.03</td></tr><tr><td>1,000,000 unshift</td><td>216.90</td><td>4.61</td><td>0.07</td></tr><tr><td>1,000,000 unshift & shift</td><td>208.45</td><td>4.80</td><td>0.05</td></tr><tr><td>1,000,000 addBefore</td><td>316.55</td><td>3.16</td><td>0.06</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>singly-linked-list</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push & shift</td><td>204.82</td><td>4.88</td><td>0.09</td></tr><tr><td>10,000 push & pop</td><td>221.88</td><td>4.51</td><td>0.03</td></tr><tr><td>10,000 addBefore</td><td>247.28</td><td>4.04</td><td>0.01</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push & shift</td><td>222.81</td><td>4.49</td><td>0.08</td></tr><tr><td>10,000 push & pop</td><td>235.91</td><td>4.24</td><td>0.01</td></tr><tr><td>10,000 addBefore</td><td>250.57</td><td>3.99</td><td>0.01</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>priority-queue</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>26.97</td><td>37.08</td><td>7.97e-4</td></tr><tr><td>100,000 add & poll</td><td>74.55</td><td>13.41</td><td>5.19e-4</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>100,000 add</td><td>27.64</td><td>36.17</td><td>8.81e-4</td></tr><tr><td>100,000 add & poll</td><td>75.52</td><td>13.24</td><td>9.91e-4</td></tr></table></div>
</div><div class="json-to-html-collapse clearfix 0">
<div class='collapsible level0' ><span class='json-to-html-label'>stack</span></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>35.54</td><td>28.14</td><td>0.00</td></tr><tr><td>1,000,000 push & pop</td><td>44.89</td><td>22.27</td><td>0.01</td></tr></table></div>
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 push</td><td>40.47</td><td>24.71</td><td>0.01</td></tr><tr><td>1,000,000 push & pop</td><td>47.47</td><td>21.07</td><td>0.01</td></tr></table></div>
</div>

@@ -865,0 +865,0 @@

@@ -45,3 +45,3 @@ import { ElementCallback, IterableElementBaseOptions, ReduceElementCallback } from '../../types';

*/
* [Symbol.iterator](...args: any[]): IterableIterator<E> {
*[Symbol.iterator](...args: any[]): IterableIterator<E> {
yield* this._getIterator(...args);

@@ -60,3 +60,3 @@ }

*/
* values(): IterableIterator<E> {
*values(): IterableIterator<E> {
for (const item of this) {

@@ -63,0 +63,0 @@ yield item;

@@ -38,3 +38,3 @@ import { EntryCallback, ReduceEntryCallback } from '../../types';

*/
* [Symbol.iterator](...args: any[]): IterableIterator<[K, V]> {
*[Symbol.iterator](...args: any[]): IterableIterator<[K, V]> {
yield* this._getIterator(...args);

@@ -54,3 +54,3 @@ }

*/
* entries(): IterableIterator<[K, V | undefined]> {
*entries(): IterableIterator<[K, V | undefined]> {
for (const item of this) {

@@ -71,3 +71,3 @@ yield item;

*/
* keys(): IterableIterator<K> {
*keys(): IterableIterator<K> {
for (const item of this) {

@@ -88,3 +88,3 @@ yield item[0];

*/
* values(): IterableIterator<V> {
*values(): IterableIterator<V> {
for (const item of this) {

@@ -91,0 +91,0 @@ yield item[1];

@@ -66,16 +66,17 @@ /**

export 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>
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> {
implements IBinaryTree<K, V, R, NODE, TREE>
{
/**

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

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

export 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>>
>
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> {
implements IBinaryTree<K, V, R, NODE, TREE>
{
/**

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

this._balanceFactor(A) // second O(1)
) {
) {
case -2:

@@ -510,0 +511,0 @@ if (A && A.left) {

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

export 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>>
>
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> {
implements IBinaryTree<K, V, R, NODE, TREE>
{
/**

@@ -790,4 +791,4 @@ * This is the constructor function for a Binary Search Tree class in TypeScript.

if (node) {
const left = node.left ? depths.get(node.left) ?? -1 : -1;
const right = node.right ? depths.get(node.right) ?? -1 : -1;
const left = node.left ? (depths.get(node.left) ?? -1) : -1;
const right = node.right ? (depths.get(node.right) ?? -1) : -1;
if (Math.abs(left - right) > 1) return false;

@@ -794,0 +795,0 @@ depths.set(node, 1 + Math.max(left, right));

@@ -56,10 +56,11 @@ import type {

export 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>>
>
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> {
implements IBinaryTree<K, V, R, NODE, TREE>
{
/**

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

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

export 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>>
>
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> {
implements IBinaryTree<K, V, R, NODE, TREE>
{
/**

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

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

export abstract class AbstractGraph<
V = any,
E = any,
VO extends AbstractVertex<V> = AbstractVertex<V>,
EO extends AbstractEdge<E> = AbstractEdge<E>
>
V = any,
E = any,
VO extends AbstractVertex<V> = AbstractVertex<V>,
EO extends AbstractEdge<E> = AbstractEdge<E>
>
extends IterableEntryBase<VertexKey, V | undefined>
implements IGraph<V, E, VO, EO> {
implements IGraph<V, E, VO, EO>
{
constructor() {

@@ -622,10 +623,10 @@ super();

getMinDist &&
distMap.forEach((d, v) => {
if (v !== srcVertex) {
if (d < minDist) {
minDist = d;
if (genPaths) minDest = v;
distMap.forEach((d, v) => {
if (v !== srcVertex) {
if (d < minDist) {
minDist = d;
if (genPaths) minDest = v;
}
}
}
});
});

@@ -1074,3 +1075,3 @@ genPaths && getPaths(minDest);

protected* _getIterator(): IterableIterator<[VertexKey, V | undefined]> {
protected *_getIterator(): IterableIterator<[VertexKey, V | undefined]> {
for (const vertex of this._vertexMap.values()) {

@@ -1077,0 +1078,0 @@ yield [vertex.key, vertex.value];

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

export class DirectedGraph<
V = any,
E = any,
VO extends DirectedVertex<V> = DirectedVertex<V>,
EO extends DirectedEdge<E> = DirectedEdge<E>
>
V = any,
E = any,
VO extends DirectedVertex<V> = DirectedVertex<V>,
EO extends DirectedEdge<E> = DirectedEdge<E>
>
extends AbstractGraph<V, E, VO, EO>
implements IGraph<V, E, VO, EO> {
implements IGraph<V, E, VO, EO>
{
/**

@@ -58,0 +59,0 @@ * The constructor function initializes an instance of a class.

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

export class UndirectedGraph<
V = any,
E = any,
VO extends UndirectedVertex<V> = UndirectedVertex<V>,
EO extends UndirectedEdge<E> = UndirectedEdge<E>
>
V = any,
E = any,
VO extends UndirectedVertex<V> = UndirectedVertex<V>,
EO extends UndirectedEdge<E> = UndirectedEdge<E>
>
extends AbstractGraph<V, E, VO, EO>
implements IGraph<V, E, VO, EO> {
implements IGraph<V, E, VO, EO>
{
/**

@@ -55,0 +56,0 @@ * The constructor initializes a new Map object to store edgeMap.

@@ -325,3 +325,3 @@ /**

*/
protected* _getIterator(): IterableIterator<[K, V]> {
protected *_getIterator(): IterableIterator<[K, V]> {
for (const node of Object.values(this.store)) {

@@ -541,3 +541,3 @@ yield [node.key, node.value] as [K, V];

*/
* begin() {
*begin() {
let node = this.head;

@@ -554,3 +554,3 @@ while (node !== this._sentinel) {

*/
* reverseBegin() {
*reverseBegin() {
let node = this.tail;

@@ -948,3 +948,3 @@ while (node !== this._sentinel) {

*/
protected* _getIterator() {
protected *_getIterator() {
let node = this.head;

@@ -951,0 +951,0 @@ while (node !== this._sentinel) {

@@ -370,3 +370,3 @@ /**

*/
protected* _getIterator(): IterableIterator<E> {
protected *_getIterator(): IterableIterator<E> {
for (const element of this.elements) {

@@ -373,0 +373,0 @@ yield element;

@@ -806,3 +806,3 @@ /**

*/
protected* _getIterator(): IterableIterator<E> {
protected *_getIterator(): IterableIterator<E> {
let current = this.head;

@@ -809,0 +809,0 @@

@@ -754,3 +754,3 @@ /**

*/
protected* _getIterator(): IterableIterator<E> {
protected *_getIterator(): IterableIterator<E> {
let current = this.head;

@@ -757,0 +757,0 @@

@@ -347,3 +347,3 @@ /**

*/
* begin(): Generator<E> {
*begin(): Generator<E> {
let index = 0;

@@ -360,3 +360,3 @@ while (index < this.size) {

*/
* reverseBegin(): Generator<E> {
*reverseBegin(): Generator<E> {
let index = this.size - 1;

@@ -853,3 +853,3 @@ while (index >= 0) {

*/
protected* _getIterator(): IterableIterator<E> {
protected *_getIterator(): IterableIterator<E> {
for (let i = 0; i < this.size; ++i) {

@@ -856,0 +856,0 @@ yield this.at(i);

@@ -22,2 +22,8 @@ /**

super(options);
if (options) {
const { autoCompactRatio = 0.5 } = options;
this._autoCompactRatio = autoCompactRatio;
}
if (elements) {

@@ -93,3 +99,22 @@ for (const el of elements) {

_autoCompactRatio: number = 0.5;
/**
* This function returns the value of the autoCompactRatio property.
* @returns The `autoCompactRatio` property of the object, which is a number.
*/
get autoCompactRatio(): number {
return this._autoCompactRatio;
}
/**
* The above function sets the autoCompactRatio property to a specified number in TypeScript.
* @param {number} v - The parameter `v` represents the value that will be assigned to the
* `_autoCompactRatio` property.
*/
set autoCompactRatio(v: number) {
this._autoCompactRatio = v;
}
/**
* Time Complexity: O(n)

@@ -150,8 +175,3 @@ * Space Complexity: O(n)

if (this.offset * 2 < this.elements.length) return first;
// only delete dequeued elements when reaching half size
// to decrease latency of shifting elements.
this._elements = this.elements.slice(this.offset);
this._offset = 0;
if (this.offset / this.elements.length > this.autoCompactRatio) this.compact();
return first;

@@ -244,2 +264,13 @@ }

/**
* The `compact` function in TypeScript slices the elements array based on the offset and resets the
* offset to zero.
* @returns The `compact()` method is returning a boolean value of `true`.
*/
compact(): boolean {
this._elements = this.elements.slice(this.offset);
this._offset = 0;
return true;
}
/**
* Time Complexity: O(n)

@@ -324,3 +355,3 @@ * Space Complexity: O(n)

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

@@ -327,0 +358,0 @@ yield item;

@@ -277,3 +277,3 @@ /**

*/
protected* _getIterator(): IterableIterator<E> {
protected *_getIterator(): IterableIterator<E> {
for (let i = 0; i < this.elements.length; i++) {

@@ -280,0 +280,0 @@ yield this.elements[i];

@@ -563,3 +563,3 @@ /**

*/
protected* _getIterator(): IterableIterator<string> {
protected *_getIterator(): IterableIterator<string> {
function* _dfs(node: TrieNode, path: string): IterableIterator<string> {

@@ -566,0 +566,0 @@ if (node.isEnd) {

@@ -5,10 +5,10 @@ export type VertexKey = string | number;

| {
distMap: Map<V, number>;
distPaths?: Map<V, V[]>;
preMap: Map<V, V | undefined>;
seen: Set<V>;
paths: V[][];
minDist: number;
minPath: V[];
}
distMap: Map<V, number>;
distPaths?: Map<V, V[]>;
preMap: Map<V, V | undefined>;
seen: Set<V>;
paths: V[][];
minDist: number;
minPath: V[];
}
| undefined;
import { IterableElementBaseOptions } from '../base';
export type DequeOptions<E, R> = {
bucketSize?: number,
maxLen?: number
bucketSize?: number;
maxLen?: number;
} & IterableElementBaseOptions<E, R>;
import { IterableElementBaseOptions } from '../base';
export type QueueOptions<E, R> = IterableElementBaseOptions<E, R> & {};
export type QueueOptions<E, R> = IterableElementBaseOptions<E, R> & {
autoCompactRatio?: number;
};

@@ -16,7 +16,7 @@ export type ToThunkFn = () => ReturnType<TrlFn>;

| ({ [key in string]: any } & {
valueOf(): Comparable;
})
valueOf(): Comparable;
})
| ({ [key in string]: any } & {
toString(): Comparable;
})
toString(): Comparable;
})
| (() => Comparable);

@@ -229,3 +229,6 @@ import { BST, BSTNode } from 'bst-typed';

const node15 = objBST.getNode(15);
expect(node15?.value).toEqual({ key: 15, keyA: 15 });
expect(node15?.value).toEqual({
key: 15,
keyA: 15
});
const minNodeBySpecificNode = node15 && objBST.getLeftMost(node15);

@@ -232,0 +235,0 @@ expect(minNodeBySpecificNode?.key).toBe(12);

@@ -33,3 +33,5 @@ import { PriorityQueue as MJSPriorityQueue } from '../../../../dist/cjs';

.add(`MJS PQ ${TEN_THOUSAND.toLocaleString()} add`, () => {
const pq = new MJSPriorityQueue<number>([], { comparator: (a, b) => b - a });
const pq = new MJSPriorityQueue<number>([], {
comparator: (a, b) => b - a
});
for (let i = 0; i < TEN_THOUSAND; i++) pq.add(i);

@@ -47,3 +49,5 @@ });

.add(`SRC PQ ${TEN_THOUSAND.toLocaleString()} add & poll`, () => {
const pq = new SRCPriorityQueue<number>([], { comparator: (a, b) => b - a });
const pq = new SRCPriorityQueue<number>([], {
comparator: (a, b) => b - a
});

@@ -54,3 +58,5 @@ for (let i = 0; i < TEN_THOUSAND; i++) pq.add(i);

.add(`CJS PQ ${TEN_THOUSAND.toLocaleString()} add & poll`, () => {
const pq = new CJSPriorityQueue<number>([], { comparator: (a, b) => b - a });
const pq = new CJSPriorityQueue<number>([], {
comparator: (a, b) => b - a
});

@@ -61,3 +67,5 @@ for (let i = 0; i < TEN_THOUSAND; i++) pq.add(i);

.add(`MJS PQ ${TEN_THOUSAND.toLocaleString()} add & poll`, () => {
const pq = new MJSPriorityQueue<number>([], { comparator: (a, b) => b - a });
const pq = new MJSPriorityQueue<number>([], {
comparator: (a, b) => b - a
});

@@ -64,0 +72,0 @@ for (let i = 0; i < TEN_THOUSAND; i++) pq.add(i);

@@ -12,7 +12,11 @@ import { PriorityQueue } from '../../../../src';

.add(`${HUNDRED_THOUSAND.toLocaleString()} add`, () => {
const heap = new PriorityQueue<number>([], { comparator: (a, b) => b - a });
const heap = new PriorityQueue<number>([], {
comparator: (a, b) => b - a
});
for (let i = 0; i < HUNDRED_THOUSAND; i++) heap.add(i);
})
.add(`${HUNDRED_THOUSAND.toLocaleString()} add & poll`, () => {
const heap = new PriorityQueue<number>([], { comparator: (a, b) => b - a });
const heap = new PriorityQueue<number>([], {
comparator: (a, b) => b - a
});

@@ -19,0 +23,0 @@ for (let i = 0; i < HUNDRED_THOUSAND; i++) heap.add(i);

@@ -54,7 +54,15 @@ import * as Benchmark from 'benchmark';

const { suite } = testFunction;
if (suite) performanceTests.push({ testName, suite, file });
if (suite)
performanceTests.push({
testName,
suite,
file
});
});
const composeReport = () => {
if (!fs.existsSync(reportDistPath)) fs.mkdirSync(reportDistPath, { recursive: true });
if (!fs.existsSync(reportDistPath))
fs.mkdirSync(reportDistPath, {
recursive: true
});

@@ -118,5 +126,14 @@ const filePath = path.join(reportDistPath, 'report.json');

html: [
{ '<>': 'td', html: '${name}' },
{ '<>': 'td', html: '${periodMS}' },
{ '<>': 'td', html: '${mean}' }
{
'<>': 'td',
html: '${name}'
},
{
'<>': 'td',
html: '${periodMS}'
},
{
'<>': 'td',
html: '${mean}'
}
]

@@ -247,5 +264,3 @@ }

// `Suites: ${GREEN}${performanceTests.length}${END} `,
`Suites Progress: ${isDone ? GREEN : YELLOW}${completedCount}${END}/${isDone ? GREEN : YELLOW}${
performanceTests.length
}${END}`,
`Suites Progress: ${isDone ? GREEN : YELLOW}${completedCount}${END}/${isDone ? GREEN : YELLOW}${performanceTests.length}${END}`,
`Time: ${isTimeWarn ? YELLOW : GREEN}${runTime}s${END}`

@@ -252,0 +267,0 @@ );

import * as Benchmark from 'benchmark';
export type PerformanceTest = { testName: string; suite: Benchmark.Suite; file: string };
export type PerformanceTest = {
testName: string;
suite: Benchmark.Suite;
file: string;
};

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

export type Json2htmlOptions = { plainHtml?: boolean } & Partial<{ [key: string]: any }>;
export type Json2htmlOptions = {
plainHtml?: boolean;
} & Partial<{
[key: string]: any;
}>;

@@ -294,3 +294,5 @@ import { AVLTreeMultiMap, AVLTreeMultiMapNode, AVLTreeNode, BinaryTreeNode, BSTNode } from '../../../../src';

it('should perform various operations on a Binary Search Tree with numeric values1', () => {
const treeMultimap = new AVLTreeMultiMap<number>([], { iterationType: 'RECURSIVE' });
const treeMultimap = new AVLTreeMultiMap<number>([], {
iterationType: 'RECURSIVE'
});

@@ -745,3 +747,5 @@ expect(treeMultimap instanceof AVLTreeMultiMap);

[{ obj: { id: 1 } }, { obj: { id: 2 } }, { obj: { id: 3 } }, { obj: { id: 4 } }, { obj: { id: 5 } }],
{ comparator: (a, b) => a.obj.id - b.obj.id }
{
comparator: (a, b) => a.obj.id - b.obj.id
}
);

@@ -748,0 +752,0 @@

@@ -231,3 +231,6 @@ import { AVLTree, AVLTreeNode, BinaryTreeNode, BSTNode } from '../../../../src';

avl.add(node2);
const node3 = new AVLTreeNode(3, { id: 3, text: 'text3' });
const node3 = new AVLTreeNode(3, {
id: 3,
text: 'text3'
});
avl.add(node3);

@@ -318,3 +321,6 @@ avl.add([3, { id: 3, text: 'text33' }]);

avl.add(node2);
const node3 = new AVLTreeNode(3, { id: 3, text: 'text3' });
const node3 = new AVLTreeNode(3, {
id: 3,
text: 'text3'
});
avl.add(node3);

@@ -321,0 +327,0 @@ avl.add([3, { id: 3, text: 'text33' }]);

@@ -11,3 +11,6 @@ import { BinaryIndexedTree } from '../../../../src';

//Create a new BinaryIndexedTree instance before each test case
bit = new BinaryIndexedTree({ frequency: 0, max: 10 }); // Modify the value of max as needed
bit = new BinaryIndexedTree({
frequency: 0,
max: 10
}); // Modify the value of max as needed
});

@@ -18,3 +21,5 @@

expect(bit.max).toBe(10);
expect(bit.freqMap).toEqual({ 0: 0 }); // Modify the initialized record value according to the actual situation
expect(bit.freqMap).toEqual({
0: 0
}); // Modify the initialized record value according to the actual situation
// More initialization checks can be added

@@ -59,3 +64,6 @@ });

beforeEach(function () {
bit = new BinaryIndexedTree({ frequency, max });
bit = new BinaryIndexedTree({
frequency,
max
});
});

@@ -79,3 +87,6 @@ it('should validate the index', function () {

const max = 1000;
const bit = new BinaryIndexedTree({ frequency, max });
const bit = new BinaryIndexedTree({
frequency,
max
});

@@ -130,3 +141,5 @@ expect(bit.freq).toBe(frequency);

beforeEach(function () {
bit = new BinaryIndexedTree({ max: array.length });
bit = new BinaryIndexedTree({
max: array.length
});
array.forEach((value, i) => bit.writeSingle(i, value));

@@ -190,3 +203,5 @@ });

beforeEach(function () {
bit = new BinaryIndexedTree({ max: array.length });
bit = new BinaryIndexedTree({
max: array.length
});
array.forEach((value, i) => bit.writeSingle(i, value));

@@ -228,3 +243,5 @@ });

it('should handle read method correctly', () => {
const bit = new BinaryIndexedTree({ max: 10 });
const bit = new BinaryIndexedTree({
max: 10
});
bit.writeSingle(2, 10);

@@ -237,3 +254,5 @@ bit.writeSingle(5, 20);

it('should handle consecutive operations', () => {
const bit = new BinaryIndexedTree({ max: 10 });
const bit = new BinaryIndexedTree({
max: 10
});
bit.writeSingle(2, 10);

@@ -248,3 +267,5 @@ bit.update(2, 5);

it('should handle frequent increment updates', () => {
const bit = new BinaryIndexedTree({ max: 10 });
const bit = new BinaryIndexedTree({
max: 10
});
for (let i = 0; i < 10; i++) {

@@ -257,3 +278,5 @@ bit.update(2, 5);

it('should handle edge cases', () => {
const bit = new BinaryIndexedTree({ max: 10 });
const bit = new BinaryIndexedTree({
max: 10
});
bit.writeSingle(9, 100);

@@ -304,3 +327,5 @@ expect(bit.readSingle(9)).toBe(100);

this._nums = nums;
this._tree = new BinaryIndexedTree({ max: nums.length + 1 });
this._tree = new BinaryIndexedTree({
max: nums.length + 1
});
for (let i = 0; i < nums.length; i++) {

@@ -307,0 +332,0 @@ this._tree.update(i + 1, nums[i]);

@@ -573,3 +573,5 @@ import { BinaryTree, BinaryTreeNode } from '../../../../src';

beforeEach(() => {
tree = new BinaryTree<number, string>([], { iterationType: 'RECURSIVE' });
tree = new BinaryTree<number, string>([], {
iterationType: 'RECURSIVE'
});
});

@@ -576,0 +578,0 @@

@@ -255,3 +255,6 @@ import { BinaryTreeNode, BST, BSTNode } from '../../../../src';

const node15 = objBST.getNode(15);
expect(node15?.value).toEqual({ name: 'Alice', age: 15 });
expect(node15?.value).toEqual({
name: 'Alice',
age: 15
});
const minNodeBySpecificNode = node15 && objBST.getLeftMost(node15);

@@ -415,3 +418,5 @@ expect(minNodeBySpecificNode?.key).toBe(12);

it('should perform various operations on a Binary Search Tree with numeric values', () => {
const bst = new BST<number>([], { iterationType: 'RECURSIVE' });
const bst = new BST<number>([], {
iterationType: 'RECURSIVE'
});
expect(bst).toBeInstanceOf(BST);

@@ -631,3 +636,6 @@ bst.add([11, 11]);

const node6 = objBST.getNode(6);
expect(objBST.get(6)).toEqual({ key: 6, keyA: 6 });
expect(objBST.get(6)).toEqual({
key: 6,
keyA: 6
});
expect(node6 && objBST.getHeight(node6)).toBe(2);

@@ -646,3 +654,6 @@ expect(node6 && objBST.getDepth(node6)).toBe(3);

const node15 = objBST.getNode(15);
expect(node15?.value).toEqual({ key: 15, keyA: 15 });
expect(node15?.value).toEqual({
key: 15,
keyA: 15
});
const minNodeBySpecificNode = node15 && objBST.getLeftMost(node15);

@@ -876,3 +887,5 @@ expect(minNodeBySpecificNode?.key).toBe(12);

test('isBST when variant is Max', () => {
const bst = new BST<number, number>([1, 2, 3, 9, 8, 5, 6, 7, 4], { comparator: (a, b) => b - a });
const bst = new BST<number, number>([1, 2, 3, 9, 8, 5, 6, 7, 4], {
comparator: (a, b) => b - a
});
bst.addMany([1, 2, 3, 9, 8, 5, 6, 7, 4]);

@@ -879,0 +892,0 @@ expect(bst.isBST()).toBe(true);

@@ -353,3 +353,5 @@ import { BinaryTreeNode, BSTNode, RedBlackTreeNode, TreeMultiMap, TreeMultiMapNode } from '../../../../src';

it('should perform various operations on a Binary Search Tree with numeric values1', () => {
const tmm = new TreeMultiMap<number>([], { iterationType: 'RECURSIVE' });
const tmm = new TreeMultiMap<number>([], {
iterationType: 'RECURSIVE'
});

@@ -356,0 +358,0 @@ expect(tmm instanceof TreeMultiMap);

@@ -84,4 +84,3 @@ import { AbstractEdge, AbstractGraph, AbstractVertex, VertexKey } from '../../../../src';

clear(): void {
}
clear(): void {}

@@ -100,4 +99,3 @@ clone(): any {

beforeEach(() => {
});
beforeEach(() => {});
it('should edge cases', function () {

@@ -104,0 +102,0 @@ myGraph.addVertex('A', 1);

@@ -1001,3 +1001,2 @@ import { DirectedEdge, DirectedGraph, DirectedVertex, VertexKey } from '../../../../src';

it(`deleteVertex deletes all of it's neighbors from the inEdge Map`, () => {
const graph = new DirectedGraph();

@@ -1012,3 +1011,3 @@ graph.addVertex('A');

// 'Incoming to A should contain ['B','C']
expect(graph.incomingEdgesOf('A').map((e) => e.src)).toEqual(['B','C']); // ['B','C']
expect(graph.incomingEdgesOf('A').map(e => e.src)).toEqual(['B', 'C']); // ['B','C']

@@ -1019,3 +1018,3 @@ // Now delete B, which has no direct link to C, only that C -> A.

// Now if we do the same call to incoming edges for we should get only ['C']
expect(graph.incomingEdgesOf('A').map((e) => e.src)).toEqual(['C']); // [];
expect(graph.incomingEdgesOf('A').map(e => e.src)).toEqual(['C']); // [];

@@ -1026,4 +1025,4 @@ // but it only shows an empty array, since we deleted all of `A's edges, not just the one to `B`.

// even though A no longer has any knowledge of C linking to it.
expect(graph.outgoingEdgesOf('C').map((e) => e.dest)).toEqual(['A']);
expect(graph.outgoingEdgesOf('C').map(e => e.dest)).toEqual(['A']);
});
})
});

@@ -150,3 +150,5 @@ import { HashMap, LinkedHashMap } from '../../../../src';

const eHM = new ExtendedHashMap<string, number>([], { someOtherParam: 'someOtherParam' });
const eHM = new ExtendedHashMap<string, number>([], {
someOtherParam: 'someOtherParam'
});
eHM.set('one', 1);

@@ -361,3 +363,5 @@ expect(eHM.get('one')).toBe(1);

hashMap.set(999, { a: '999Value' });
expect(hashMap.get(999)).toEqual({ a: '999Value' });
expect(hashMap.get(999)).toEqual({
a: '999Value'
});
});

@@ -364,0 +368,0 @@

@@ -5,3 +5,2 @@ import { FibonacciHeap, Heap, MaxHeap, MinHeap } from '../../../../src';

describe('Heap Operation Test', () => {
it('should heap add and delete work well', function () {

@@ -51,3 +50,5 @@ const hp = new MinHeap<number>();

it('should clone', function () {
const minNumHeap = new Heap<string>([], { comparator: (a, b) => Number(a) - Number(b) });
const minNumHeap = new Heap<string>([], {
comparator: (a, b) => Number(a) - Number(b)
});
minNumHeap.add('1');

@@ -69,3 +70,8 @@ minNumHeap.add('6');

it('should object heap work well', function () {
const minHeap = new MinHeap<{ a: string; key: number }>([], { comparator: (a, b) => a.key - b.key });
const minHeap = new MinHeap<{
a: string;
key: number;
}>([], {
comparator: (a, b) => a.key - b.key
});
minHeap.add({ key: 1, a: 'a1' });

@@ -76,3 +82,6 @@ minHeap.add({ key: 6, a: 'a6' });

expect(minHeap.peek()).toEqual({ a: 'a0', key: 0 });
expect(minHeap.peek()).toEqual({
a: 'a0',
key: 0
});
expect(minHeap.toArray().map(item => ({ a: item.a }))).toEqual([

@@ -87,7 +96,14 @@ { a: 'a0' },

while (minHeap.size > 0) {
expect({ a: minHeap.poll()?.a }).toEqual(expectPolled[i]);
expect({
a: minHeap.poll()?.a
}).toEqual(expectPolled[i]);
i++;
}
const maxHeap = new MaxHeap<{ key: number; a: string }>([], { comparator: (a, b) => b.key - a.key });
const maxHeap = new MaxHeap<{
key: number;
a: string;
}>([], {
comparator: (a, b) => b.key - a.key
});
maxHeap.add({ key: 1, a: 'a1' });

@@ -99,3 +115,6 @@ maxHeap.add({ key: 6, a: 'a6' });

maxHeap.add({ key: 9, a: 'a9' });
expect(maxHeap.peek()).toEqual({ a: 'a9', key: 9 });
expect(maxHeap.peek()).toEqual({
a: 'a9',
key: 9
});
expect(maxHeap.toArray().map(item => ({ a: item.a }))).toEqual([

@@ -112,3 +131,5 @@ { a: 'a9' },

while (maxHeap.size > 0) {
expect({ a: maxHeap.poll()?.a }).toEqual(maxExpectPolled[maxI]);
expect({
a: maxHeap.poll()?.a
}).toEqual(maxExpectPolled[maxI]);
maxI++;

@@ -119,3 +140,6 @@ }

it('should object heap map & filter', function () {
const minHeap = new MinHeap<{ a: string; key: number }>(
const minHeap = new MinHeap<{
a: string;
key: number;
}>(
[

@@ -130,3 +154,5 @@ { key: 1, a: 'a1' },

],
{ comparator: (a, b) => a.key - b.key }
{
comparator: (a, b) => a.key - b.key
}
);

@@ -159,3 +185,5 @@

it('should object heap', () => {
const heap = new Heap<{ rawItem: { id: number } }>(
const heap = new Heap<{
rawItem: { id: number };
}>(
[

@@ -170,3 +198,5 @@ { rawItem: { id: 4 } },

],
{ comparator: (a, b) => a.rawItem.id - b.rawItem.id }
{
comparator: (a, b) => a.rawItem.id - b.rawItem.id
}
);

@@ -196,3 +226,5 @@

],
{ toElementFn: rawElement => rawElement.rawItem.id }
{
toElementFn: rawElement => rawElement.rawItem.id
}
);

@@ -199,0 +231,0 @@

@@ -8,3 +8,5 @@ import { Comparator, MaxHeap } from '../../../../src';

beforeEach(() => {
maxHeap = new MaxHeap<number>([], { comparator: numberComparator });
maxHeap = new MaxHeap<number>([], {
comparator: numberComparator
});
});

@@ -55,3 +57,6 @@

it('should object heap map & filter', function () {
const maxHeap = new MaxHeap<{ a: string; key: number }>(
const maxHeap = new MaxHeap<{
a: string;
key: number;
}>(
[

@@ -66,3 +71,5 @@ { key: 1, a: 'a1' },

],
{ comparator: (a, b) => b.key - a.key }
{
comparator: (a, b) => b.key - a.key
}
);

@@ -69,0 +76,0 @@

@@ -8,3 +8,5 @@ import { Comparator, MinHeap } from '../../../../src';

beforeEach(() => {
minHeap = new MinHeap<number>([], { comparator: numberComparator });
minHeap = new MinHeap<number>([], {
comparator: numberComparator
});
});

@@ -11,0 +13,0 @@

@@ -82,3 +82,5 @@ import { DoublyLinkedList, DoublyLinkedListNode } from '../../../../src';

let list: DoublyLinkedList<number>;
let objectList: DoublyLinkedList<{ keyA: number }>;
let objectList: DoublyLinkedList<{
keyA: number;
}>;

@@ -85,0 +87,0 @@ beforeEach(() => {

@@ -14,6 +14,10 @@ import { SinglyLinkedList, SinglyLinkedListNode } from '../../../../src';

let list: SinglyLinkedList<number>;
let objectList: SinglyLinkedList<{ keyA: number }>;
let objectList: SinglyLinkedList<{
keyA: number;
}>;
beforeEach(() => {
list = new SinglyLinkedList<number>();
objectList = new SinglyLinkedList<{ keyA: number }>();
objectList = new SinglyLinkedList<{
keyA: number;
}>();
});

@@ -20,0 +24,0 @@

@@ -19,3 +19,7 @@ import { MaxPriorityQueue } from '../../../../src';

it('should add elements and maintain heap property in a object MaxPriorityQueue', () => {
const priorityQueue = new MaxPriorityQueue<{ keyA: number }>([], { comparator: (a, b) => b.keyA - a.keyA });
const priorityQueue = new MaxPriorityQueue<{
keyA: number;
}>([], {
comparator: (a, b) => b.keyA - a.keyA
});
priorityQueue.refill([{ keyA: 5 }, { keyA: 3 }, { keyA: 1 }]);

@@ -56,3 +60,5 @@ priorityQueue.add({ keyA: 7 });

const array = [5, 3, 7, 1];
const heap = MaxPriorityQueue.heapify<number>(array, { comparator: (a, b) => b - a });
const heap = MaxPriorityQueue.heapify<number>(array, {
comparator: (a, b) => b - a
});
heap.refill(array);

@@ -69,3 +75,7 @@

debugger;
const maxPQ = MaxPriorityQueue.heapify<{ keyA: number }>(elements, { comparator: (a, b) => b.keyA - a.keyA });
const maxPQ = MaxPriorityQueue.heapify<{
keyA: number;
}>(elements, {
comparator: (a, b) => b.keyA - a.keyA
});

@@ -79,3 +89,5 @@ expect(maxPQ.poll()?.keyA).toBe(7);

it('should object priority queue', () => {
const maxPQ = new MaxPriorityQueue<{ rawItem: { id: number } }>(
const maxPQ = new MaxPriorityQueue<{
rawItem: { id: number };
}>(
[

@@ -90,3 +102,5 @@ { rawItem: { id: 4 } },

],
{ comparator: (a, b) => b.rawItem.id - a.rawItem.id }
{
comparator: (a, b) => b.rawItem.id - a.rawItem.id
}
);

@@ -116,3 +130,5 @@

],
{ toElementFn: rawElement => rawElement.rawItem.id }
{
toElementFn: rawElement => rawElement.rawItem.id
}
);

@@ -119,0 +135,0 @@

@@ -8,3 +8,5 @@ import { PriorityQueue } from '../../../../src';

it('should PriorityQueue poll, pee, heapify, toArray work well', function () {
const minPQ = new PriorityQueue<number>([], { comparator: (a, b) => a - b });
const minPQ = new PriorityQueue<number>([], {
comparator: (a, b) => a - b
});
minPQ.refill([5, 2, 3, 4, 6, 1]);

@@ -25,3 +27,5 @@ expect(minPQ.toArray()).toEqual([1, 2, 3, 4, 6, 5]);

it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () {
const maxPriorityQueue = new PriorityQueue<number>([], { comparator: (a, b) => b - a });
const maxPriorityQueue = new PriorityQueue<number>([], {
comparator: (a, b) => b - a
});
maxPriorityQueue.refill([5, 2, 3, 4, 6, 1]);

@@ -42,3 +46,5 @@ expect(maxPriorityQueue.toArray()).toEqual([6, 5, 3, 4, 2, 1]);

it('should PriorityQueue clone, sort, getNodes, dfs work well', function () {
const minPQ1 = new PriorityQueue<number>([], { comparator: (a, b) => a - b });
const minPQ1 = new PriorityQueue<number>([], {
comparator: (a, b) => a - b
});
minPQ1.refill([2, 5, 8, 3, 1, 6, 7, 4]);

@@ -56,3 +62,5 @@ const clonedPriorityQueue = minPQ1.clone();

it('should numeric heap work well', function () {
const pq = new PriorityQueue<number>([], { comparator: (a, b) => b - a });
const pq = new PriorityQueue<number>([], {
comparator: (a, b) => b - a
});

@@ -59,0 +67,0 @@ const tS = performance.now();

@@ -207,4 +207,3 @@ import { Deque } from '../../../../src';

test('shrinkToFit should reduce the memory footprint', () => {
});
test('shrinkToFit should reduce the memory footprint', () => {});
});

@@ -268,3 +267,3 @@ describe('Deque - Utility Operations', () => {

expect(dequeMaxLen.size).toBe(3);
expect(dequeMaxLen.toArray()).toEqual([5, 6 ,7]);
expect(dequeMaxLen.toArray()).toEqual([5, 6, 7]);
dequeMaxLen.unshift(4);

@@ -282,3 +281,2 @@ dequeMaxLen.unshift(3);

expect(dequeNoMaxLen.toArray()).toEqual([3, 4, 3, 4, 5, 6, 7]);
});

@@ -350,3 +348,5 @@ });

beforeEach(() => {
deque = new Deque<number>([], { bucketSize });
deque = new Deque<number>([], {
bucketSize
});
});

@@ -393,3 +393,5 @@

beforeEach(() => {
deque = new Deque<number>([], { bucketSize });
deque = new Deque<number>([], {
bucketSize
});
});

@@ -425,3 +427,5 @@

beforeEach(() => {
deque = new Deque<number>([], { bucketSize });
deque = new Deque<number>([], {
bucketSize
});
});

@@ -458,3 +462,5 @@

beforeEach(() => {
deque = new Deque<number>([], { bucketSize });
deque = new Deque<number>([], {
bucketSize
});
});

@@ -461,0 +467,0 @@

@@ -93,2 +93,12 @@ import { LinkedListQueue, Queue } from '../../../../src';

test('compact method should work well', () => {
for (let i = 0; i < 1000; i++) queue.push(i);
for (let i = 0; i < 499; i++) queue.shift();
expect(queue.elements.length).toBe(1000);
queue.compact();
expect(queue.elements.length).toBe(501);
});
test('should at after shifting', () => {

@@ -120,3 +130,6 @@ for (let i = 0; i < 100; i++) {

it('should object queue map & filter', function () {
const queue = new Queue<{ a: string; key: number }>([
const queue = new Queue<{
a: string;
key: number;
}>([
{ key: 1, a: 'a1' },

@@ -123,0 +136,0 @@ { key: 6, a: 'a6' },

@@ -798,3 +798,5 @@ import { Trie, TrieNode } from '../../../../src';

it('Case Sensitivity', () => {
const caseInsensitiveTrie = new Trie(['apple', 'Banana'], { caseSensitive: false });
const caseInsensitiveTrie = new Trie(['apple', 'Banana'], {
caseSensitive: false
});
expect(caseInsensitiveTrie.has('APPLE')).toBe(true);

@@ -801,0 +803,0 @@ expect(caseInsensitiveTrie.has('banana')).toBe(true);

@@ -248,3 +248,5 @@ import {

isDebug && trie.print();
const heap = new Heap<string>(trie, { comparator: (a, b) => Number(a) - Number(b) });
const heap = new Heap<string>(trie, {
comparator: (a, b) => Number(a) - Number(b)
});
expect(heap.size).toBe(10);

@@ -251,0 +253,0 @@ isDebug && heap.print();

@@ -35,3 +35,5 @@ import { AnyFunction } from '../types';

let longestArray: any[] = [];
let mostProperties: { [key: string]: any } = {};
let mostProperties: {
[key: string]: any;
} = {};

@@ -38,0 +40,0 @@ function recurse(obj: any) {

@@ -17,9 +17,5 @@ import * as _ from './is';

if (datatype === 'array') {
return `<div class='collapsible level${level}' ${toggleJS(
options
)}><span class='json-to-html-label'>${keyName}</span></div>`;
return `<div class='collapsible level${level}' ${toggleJS(options)}><span class='json-to-html-label'>${keyName}</span></div>`;
} else if (datatype === 'object') {
return `<div class='attribute collapsible level${level}' ${toggleJS(
options
)}><span class='json-to-html-label'>${keyName}:</span></div>`;
return `<div class='attribute collapsible level${level}' ${toggleJS(options)}><span class='json-to-html-label'>${keyName}:</span></div>`;
} else {

@@ -26,0 +22,0 @@ return `<div class='leaf level${level}'><span class='json-to-html-label'>${keyName}:</span></div>`;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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

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

Sorry, the diff of this file is not supported yet

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