mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 04:44:04 +00:00
chore: Add source map support for ESModule. Add a 'browser' field to package.json. Performance optimization of getRandomIntArray method
This commit is contained in:
parent
5adf75f99c
commit
476395ef72
|
@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
|
|||
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
|
||||
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)
|
||||
|
||||
## [v1.53.0](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)
|
||||
## [v1.53.1](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)
|
||||
|
||||
### Changes
|
||||
|
||||
|
|
52
package-lock.json
generated
52
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "data-structure-typed",
|
||||
"version": "1.53.0",
|
||||
"version": "1.53.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "data-structure-typed",
|
||||
"version": "1.53.0",
|
||||
"version": "1.53.1",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.2.2",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"@typescript-eslint/eslint-plugin": "^8.12.1",
|
||||
"@typescript-eslint/parser": "^8.12.1",
|
||||
"auto-changelog": "^2.5.0",
|
||||
"avl-tree-typed": "^1.52.9",
|
||||
"avl-tree-typed": "^1.53.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"binary-tree-typed": "^1.52.9",
|
||||
"bst-typed": "^1.52.9",
|
||||
"data-structure-typed": "^1.52.9",
|
||||
"binary-tree-typed": "^1.53.0",
|
||||
"bst-typed": "^1.53.0",
|
||||
"data-structure-typed": "^1.53.0",
|
||||
"dependency-cruiser": "^16.5.0",
|
||||
"doctoc": "^2.2.1",
|
||||
"eslint": "^9.13.0",
|
||||
|
@ -32,7 +32,7 @@
|
|||
"eslint-import-resolver-typescript": "^3.6.3",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"fast-glob": "^3.3.2",
|
||||
"heap-typed": "^1.52.9",
|
||||
"heap-typed": "^1.53.0",
|
||||
"istanbul-badges-readme": "^1.9.0",
|
||||
"jest": "^29.7.0",
|
||||
"js-sdsl": "^4.4.2",
|
||||
|
@ -3437,13 +3437,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/avl-tree-typed": {
|
||||
"version": "1.52.9",
|
||||
"resolved": "https://registry.npmjs.org/avl-tree-typed/-/avl-tree-typed-1.52.9.tgz",
|
||||
"integrity": "sha512-TfapTNrlIquhf1iwrzhc5pEejEhE0CogxiNlaI0nqkv2Qz2OkhvfmAtJOG5ndiFBp4btNZYFGHb+S/zXkEX82A==",
|
||||
"version": "1.53.0",
|
||||
"resolved": "https://registry.npmjs.org/avl-tree-typed/-/avl-tree-typed-1.53.0.tgz",
|
||||
"integrity": "sha512-SVk6zEvzrB2GhHVFOhVO2yaB7p9iLGy2aml0j7UW1rWp+VACw4SZQhKuldl2qC7ECb9AOIbajD7Y9ott8Qfy8Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"data-structure-typed": "^1.52.9"
|
||||
"data-structure-typed": "^1.53.0"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-jest": {
|
||||
|
@ -3602,13 +3602,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/binary-tree-typed": {
|
||||
"version": "1.52.9",
|
||||
"resolved": "https://registry.npmjs.org/binary-tree-typed/-/binary-tree-typed-1.52.9.tgz",
|
||||
"integrity": "sha512-/q5l3wftn485Px+L40NKjKBPukL1XjotSQVCYB+wmz1S3P4H8FobBlEFo5j0UqaW9+TgzhSwecoBbIPsvshXAQ==",
|
||||
"version": "1.53.0",
|
||||
"resolved": "https://registry.npmjs.org/binary-tree-typed/-/binary-tree-typed-1.53.0.tgz",
|
||||
"integrity": "sha512-5EmlwbR4Kaphual+wF2rJwpZFhhK2u6zOFiA+yagWDbH6tzBCojT5o2DN+1tmW1Pj6bGJxz7PHcDBIdBkQruMw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"data-structure-typed": "^1.52.9"
|
||||
"data-structure-typed": "^1.53.0"
|
||||
}
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
|
@ -3691,13 +3691,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/bst-typed": {
|
||||
"version": "1.52.9",
|
||||
"resolved": "https://registry.npmjs.org/bst-typed/-/bst-typed-1.52.9.tgz",
|
||||
"integrity": "sha512-7jgOhrYST+HBZRGvmKx3UZRt6ddBr9Ib807gfJ9+jRVuXQIK9m3hW1MSwXMovWs8tKpF0JZMCqj+uk+S8B85qg==",
|
||||
"version": "1.53.0",
|
||||
"resolved": "https://registry.npmjs.org/bst-typed/-/bst-typed-1.53.0.tgz",
|
||||
"integrity": "sha512-f1f+RlbIA6J2reFO/DwLRLaZVBmMNNyKCi5eWd+r5ojV9bDC/IZ34nzID0zSJUwVqtAtIpaK9x63XAo42+5SoQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"data-structure-typed": "^1.52.9"
|
||||
"data-structure-typed": "^1.53.0"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer-from": {
|
||||
|
@ -4069,9 +4069,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/data-structure-typed": {
|
||||
"version": "1.52.9",
|
||||
"resolved": "https://registry.npmjs.org/data-structure-typed/-/data-structure-typed-1.52.9.tgz",
|
||||
"integrity": "sha512-tIAf4CqOdDz5XJZBtTjWwhOgLOwiMS+1kH9dN44x12klBcKavpUDUjncvrcAqLsVP5xTZSeehJ5teNa6YNgWQQ==",
|
||||
"version": "1.53.0",
|
||||
"resolved": "https://registry.npmjs.org/data-structure-typed/-/data-structure-typed-1.53.0.tgz",
|
||||
"integrity": "sha512-bukacSwbWyypNTdQCt51rwNcqM1hacHG6mMJ2RDBqsz8jJ5N4oMOgQhDyA1GkvMvdq83mcj9ilCFZ6lDcwShqA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
|
@ -5946,13 +5946,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/heap-typed": {
|
||||
"version": "1.52.9",
|
||||
"resolved": "https://registry.npmjs.org/heap-typed/-/heap-typed-1.52.9.tgz",
|
||||
"integrity": "sha512-YdCJFzKob73n5sDovGkL2Y/jqVe+vY9dXcDyx4ToZoneJqJ83IMVDl/qlGb/ujDMlTXqJR4/jiIT5s00jxS7jQ==",
|
||||
"version": "1.53.0",
|
||||
"resolved": "https://registry.npmjs.org/heap-typed/-/heap-typed-1.53.0.tgz",
|
||||
"integrity": "sha512-MtbVdNGb2mvLrv67j0ajaMDr/u0HpR0tMaCj1MUrmXKK+IhVqniq7I8ADUlDrEPpKXwES8RBa0v7lA5umKR9hg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"data-structure-typed": "^1.52.9"
|
||||
"data-structure-typed": "^1.53.0"
|
||||
}
|
||||
},
|
||||
"node_modules/html-escaper": {
|
||||
|
|
13
package.json
13
package.json
|
@ -1,9 +1,10 @@
|
|||
{
|
||||
"name": "data-structure-typed",
|
||||
"version": "1.53.0",
|
||||
"version": "1.53.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",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/mjs/index.js",
|
||||
"browser": "dist/umd/data-structure-typed.min.js",
|
||||
"types": "dist/mjs/index.d.ts",
|
||||
"umd:main": "dist/umd/data-structure-typed.min.js",
|
||||
"exports": {
|
||||
|
@ -68,11 +69,11 @@
|
|||
"@typescript-eslint/eslint-plugin": "^8.12.1",
|
||||
"@typescript-eslint/parser": "^8.12.1",
|
||||
"auto-changelog": "^2.5.0",
|
||||
"avl-tree-typed": "^1.52.9",
|
||||
"avl-tree-typed": "^1.53.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"binary-tree-typed": "^1.52.9",
|
||||
"bst-typed": "^1.52.9",
|
||||
"data-structure-typed": "^1.52.9",
|
||||
"binary-tree-typed": "^1.53.0",
|
||||
"bst-typed": "^1.53.0",
|
||||
"data-structure-typed": "^1.53.0",
|
||||
"dependency-cruiser": "^16.5.0",
|
||||
"doctoc": "^2.2.1",
|
||||
"eslint": "^9.13.0",
|
||||
|
@ -81,7 +82,7 @@
|
|||
"eslint-import-resolver-typescript": "^3.6.3",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"fast-glob": "^3.3.2",
|
||||
"heap-typed": "^1.52.9",
|
||||
"heap-typed": "^1.53.0",
|
||||
"istanbul-badges-readme": "^1.9.0",
|
||||
"jest": "^29.7.0",
|
||||
"js-sdsl": "^4.4.2",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {AVLTreeMultiMap, AVLTreeMultiMapNode} from '../../../data-structures';
|
||||
import type {AVLTreeOptions} from './avl-tree';
|
||||
import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
|
||||
import type { AVLTreeOptions } from './avl-tree';
|
||||
|
||||
export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {AVLTree, AVLTreeNode} from '../../../data-structures';
|
||||
import {BSTOptions} from './bst';
|
||||
import { AVLTree, AVLTreeNode } from '../../../data-structures';
|
||||
import { BSTOptions } from './bst';
|
||||
|
||||
export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {BinaryTree, BinaryTreeNode} from '../../../data-structures';
|
||||
import {IterationType, OptValue} from '../../common';
|
||||
import {DFSOperation} from '../../../constants';
|
||||
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
|
||||
import { IterationType, OptValue } from '../../common';
|
||||
import { DFSOperation } from '../../../constants';
|
||||
|
||||
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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {BST, BSTNode} from '../../../data-structures';
|
||||
import type {BinaryTreeOptions} from './binary-tree';
|
||||
import {Comparator} from '../../common';
|
||||
import { BST, BSTNode } from '../../../data-structures';
|
||||
import type { BinaryTreeOptions } from './binary-tree';
|
||||
import { Comparator } from '../../common';
|
||||
|
||||
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {RedBlackTree, RedBlackTreeNode} from '../../../data-structures';
|
||||
import type {BSTOptions} from "./bst";
|
||||
import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
|
||||
import type { BSTOptions } from "./bst";
|
||||
|
||||
export type RBTNColor = 'RED' | 'BLACK';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {TreeMultiMap, TreeMultiMapNode} from '../../../data-structures';
|
||||
import type {RBTreeOptions} from './rb-tree';
|
||||
import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures';
|
||||
import type { RBTreeOptions } from './rb-tree';
|
||||
|
||||
export type TreeMultiMapNodeNested<K, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as Benchmark from 'benchmark';
|
|||
import { getRandomIntArray, magnitude } from '../../../utils';
|
||||
|
||||
const suite = new Benchmark.Suite();
|
||||
const avlTree = new AVLTree<number>([], { isMapMode: true });
|
||||
const avlTree = new AVLTree<number>();
|
||||
const { HUNDRED_THOUSAND } = magnitude;
|
||||
const randomArray = getRandomIntArray(HUNDRED_THOUSAND, 0, HUNDRED_THOUSAND - 1, true);
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ import * as Benchmark from 'benchmark';
|
|||
import { getRandomIntArray, magnitude } from '../../../utils';
|
||||
|
||||
const suite = new Benchmark.Suite();
|
||||
const rbTree = new RedBlackTree<number>([], { isMapMode: true });
|
||||
const avlTree = new AVLTree<number>([], { isMapMode: true });
|
||||
const rbTree = new RedBlackTree<number>();
|
||||
const avlTree = new AVLTree<number>();
|
||||
const { TEN_THOUSAND } = magnitude;
|
||||
const arr = getRandomIntArray(TEN_THOUSAND, 0, TEN_THOUSAND - 1, true);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as Benchmark from 'benchmark';
|
|||
import { getRandomIntArray, magnitude } from '../../../utils';
|
||||
|
||||
const suite = new Benchmark.Suite();
|
||||
const biTree = new BinaryTree<number>([], { isMapMode: true });
|
||||
const biTree = new BinaryTree<number>();
|
||||
const { THOUSAND } = magnitude;
|
||||
const arr = getRandomIntArray(THOUSAND, 0, THOUSAND, true);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as Benchmark from 'benchmark';
|
|||
import { getRandomIntArray, magnitude } from '../../../utils';
|
||||
|
||||
const suite = new Benchmark.Suite();
|
||||
const bst = new BST<number>([], { isMapMode: true });
|
||||
const bst = new BST<number>();
|
||||
const { TEN_THOUSAND } = magnitude;
|
||||
const arr = getRandomIntArray(TEN_THOUSAND, 0, TEN_THOUSAND, true);
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ import { OrderedMap } from 'js-sdsl';
|
|||
import { isCompetitor } from '../../../config';
|
||||
|
||||
const suite = new Benchmark.Suite();
|
||||
const rbTree = new RedBlackTree<number>([], { isMapMode: true });
|
||||
const rbTree = new RedBlackTree<number>();
|
||||
const rbTreeNodeMode = new RedBlackTree<number>([], { isMapMode: false });
|
||||
const { HUNDRED_THOUSAND } = magnitude;
|
||||
const randomArray = getRandomIntArray(HUNDRED_THOUSAND, 0, HUNDRED_THOUSAND - 1, true);
|
||||
const cOrderedMap = new OrderedMap<number, number>();
|
||||
|
@ -22,6 +23,13 @@ suite
|
|||
.add(`${HUNDRED_THOUSAND.toLocaleString()} get`, () => {
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.get(randomArray[i]);
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} node mode add randomly`, () => {
|
||||
rbTreeNodeMode.clear();
|
||||
for (let i = 0; i < randomArray.length; i++) rbTree.add(randomArray[i]);
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} node mode get`, () => {
|
||||
for (let i = 0; i < randomArray.length; i++) rbTreeNodeMode.get(randomArray[i]);
|
||||
})
|
||||
.add(`${HUNDRED_THOUSAND.toLocaleString()} iterator`, () => {
|
||||
const entries = [...rbTree];
|
||||
return entries.length === HUNDRED_THOUSAND;
|
||||
|
|
|
@ -1035,4 +1035,18 @@ describe('delete', () => {
|
|||
// even though A no longer has any knowledge of C linking to it.
|
||||
expect(graph.outgoingEdgesOf('C').map(e => e.dest)).toEqual(['A']);
|
||||
});
|
||||
|
||||
// it('should print', () => {
|
||||
// const graph = new DirectedGraph();
|
||||
// graph.addVertex('A');
|
||||
// graph.addVertex('B');
|
||||
// graph.addVertex('C');
|
||||
//
|
||||
// graph.addEdge('A', 'B');
|
||||
// graph.addEdge('A', 'C');
|
||||
// graph.addEdge('B', 'C');
|
||||
// graph.addEdge('C', 'B');
|
||||
// graph.print();
|
||||
//
|
||||
// })
|
||||
});
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
import { getRandomInt } from './number';
|
||||
|
||||
export function getRandomIntArray(length: number = 1000, min: number = -1000, max: number = 1000, isDistinct = true) {
|
||||
if (isDistinct) {
|
||||
const set = new Set<number>();
|
||||
const ans: number[] = [];
|
||||
while (ans.length < length) {
|
||||
const num = getRandomInt(min, max);
|
||||
if (!set.has(num)) {
|
||||
ans.push(num);
|
||||
set.add(num);
|
||||
}
|
||||
export function getRandomIntArray(length: number = 1000, min: number = -1000, max: number = 1000, unique = true) {
|
||||
if (unique) {
|
||||
if (max - min + 1 < length) {
|
||||
throw new Error('Range too small for unique values with the specified length');
|
||||
}
|
||||
return ans;
|
||||
|
||||
const allNumbers = Array.from({ length: max - min + 1 }, (_, i) => i + min);
|
||||
|
||||
for (let i = allNumbers.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[allNumbers[i], allNumbers[j]] = [allNumbers[j], allNumbers[i]];
|
||||
}
|
||||
|
||||
return allNumbers.slice(0, length);
|
||||
} else {
|
||||
return Array.from({ length }, () => Math.floor(Math.random() * (max - min + 1)) + min);
|
||||
}
|
||||
return new Array<number>(length).fill(0).map(() => getRandomInt(min, max));
|
||||
}
|
||||
|
||||
const words = [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"sourceMap": false
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*.ts"
|
||||
|
|
Loading…
Reference in a new issue