data-structure-typed 1.45.0 → 1.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +6 -6
- package/CHANGELOG.md +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +58 -58
- package/dist/cjs/data-structures/hash/hash-map.js +73 -73
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/tree-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/tree-set.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix2d.js.map +1 -1
- package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
- package/dist/cjs/data-structures/matrix/vector2d.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/tree/tree.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/hash/hash-map.d.ts +58 -58
- package/dist/mjs/data-structures/hash/hash-map.js +76 -76
- package/dist/umd/data-structure-typed.js +74 -72
- package/dist/umd/data-structure-typed.min.js +1 -1
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/binary-tree/avl-tree.ts +7 -7
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -3
- package/src/data-structures/binary-tree/binary-tree.ts +39 -31
- package/src/data-structures/binary-tree/bst.ts +12 -8
- package/src/data-structures/binary-tree/rb-tree.ts +17 -6
- package/src/data-structures/binary-tree/segment-tree.ts +1 -1
- package/src/data-structures/binary-tree/tree-multimap.ts +12 -9
- package/src/data-structures/graph/abstract-graph.ts +46 -31
- package/src/data-structures/graph/directed-graph.ts +10 -5
- package/src/data-structures/graph/map-graph.ts +8 -8
- package/src/data-structures/graph/undirected-graph.ts +9 -9
- package/src/data-structures/hash/hash-map.ts +103 -103
- package/src/data-structures/hash/hash-table.ts +1 -1
- package/src/data-structures/hash/tree-map.ts +2 -1
- package/src/data-structures/hash/tree-set.ts +2 -1
- package/src/data-structures/heap/heap.ts +8 -5
- package/src/data-structures/heap/max-heap.ts +3 -3
- package/src/data-structures/heap/min-heap.ts +3 -3
- package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/data-structures/matrix/matrix.ts +2 -2
- package/src/data-structures/matrix/matrix2d.ts +1 -1
- package/src/data-structures/matrix/navigator.ts +3 -3
- package/src/data-structures/matrix/vector2d.ts +2 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/min-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/priority-queue.ts +3 -3
- package/src/data-structures/queue/deque.ts +5 -4
- package/src/data-structures/queue/queue.ts +2 -2
- package/src/data-structures/tree/tree.ts +1 -1
- package/src/data-structures/trie/trie.ts +1 -1
- package/src/interfaces/binary-tree.ts +2 -2
- package/src/interfaces/graph.ts +1 -1
- package/src/types/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/bst.ts +2 -2
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/tree-multimap.ts +2 -2
- package/src/types/data-structures/hash/hash-map.ts +6 -6
- package/src/types/data-structures/matrix/navigator.ts +1 -1
- package/src/types/utils/utils.ts +1 -1
- package/src/types/utils/validate-type.ts +18 -4
- package/src/utils/utils.ts +6 -6
- package/test/integration/all-in-one.ts +1 -1
- package/test/integration/avl-tree.test.ts +1 -1
- package/test/integration/bst.test.ts +19 -19
- package/test/integration/heap.test.js +1 -1
- package/test/integration/index.html +7 -7
- package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/binary-tree.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/bst.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +6 -6
- package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
- package/test/performance/data-structures/hash/hash-map.test.ts +6 -6
- package/test/performance/data-structures/heap/heap.test.ts +5 -5
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +6 -6
- package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +4 -4
- package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +7 -5
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +7 -7
- package/test/performance/data-structures/queue/deque.test.ts +5 -5
- package/test/performance/data-structures/queue/queue.test.ts +6 -6
- package/test/performance/data-structures/stack/stack.test.ts +6 -6
- package/test/performance/data-structures/trie/trie.test.ts +4 -4
- package/test/performance/reportor.ts +15 -13
- package/test/performance/types/reportor.ts +1 -1
- package/test/types/utils/json2html.ts +1 -1
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +6 -6
- package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +12 -12
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -76
- package/test/unit/data-structures/binary-tree/bst.test.ts +44 -40
- package/test/unit/data-structures/binary-tree/overall.test.ts +17 -17
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +9 -9
- package/test/unit/data-structures/binary-tree/segment-tree.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +35 -35
- package/test/unit/data-structures/graph/abstract-graph.test.ts +7 -7
- package/test/unit/data-structures/graph/directed-graph.test.ts +34 -14
- package/test/unit/data-structures/graph/map-graph.test.ts +1 -1
- package/test/unit/data-structures/graph/overall.test.ts +1 -1
- package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
- package/test/unit/data-structures/hash/coordinate-map.test.ts +1 -1
- package/test/unit/data-structures/hash/coordinate-set.test.ts +1 -1
- package/test/unit/data-structures/hash/hash-map.test.ts +10 -12
- package/test/unit/data-structures/hash/hash-table.test.ts +1 -1
- package/test/unit/data-structures/heap/heap.test.ts +35 -23
- package/test/unit/data-structures/heap/max-heap.test.ts +2 -2
- package/test/unit/data-structures/heap/min-heap.test.ts +2 -2
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +5 -5
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +5 -5
- package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
- package/test/unit/data-structures/matrix/matrix.test.ts +5 -5
- package/test/unit/data-structures/matrix/matrix2d.test.ts +3 -3
- package/test/unit/data-structures/matrix/navigator.test.ts +2 -2
- package/test/unit/data-structures/matrix/vector2d.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +7 -7
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +19 -19
- package/test/unit/data-structures/queue/deque.test.ts +3 -3
- package/test/unit/data-structures/queue/queue.test.ts +3 -3
- package/test/unit/data-structures/stack/stack.test.ts +1 -1
- package/test/unit/data-structures/tree/tree.test.ts +1 -1
- package/test/unit/data-structures/trie/trie.test.ts +1 -1
- package/test/utils/array.ts +1 -1
- package/test/utils/big-o.ts +4 -4
- package/test/utils/json2html.ts +7 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {AVLTreeNode} from '../../../data-structures';
|
|
2
|
-
import {BSTOptions} from './bst';
|
|
1
|
+
import { AVLTreeNode } from '../../../data-structures';
|
|
2
|
+
import { BSTOptions } from './bst';
|
|
3
3
|
|
|
4
4
|
export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
5
|
export type AVLTreeOptions = BSTOptions & {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {BSTNode} from '../../../data-structures';
|
|
2
|
-
import type {BinaryTreeOptions, BTNKey} from './binary-tree';
|
|
1
|
+
import { BSTNode } from '../../../data-structures';
|
|
2
|
+
import type { BinaryTreeOptions, BTNKey } from './binary-tree';
|
|
3
3
|
|
|
4
4
|
export type BSTComparator = (a: BTNKey, b: BTNKey) => number;
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {TreeMultimapNode} from '../../../data-structures';
|
|
2
|
-
import {AVLTreeOptions} from './avl-tree';
|
|
1
|
+
import { TreeMultimapNode } from '../../../data-structures';
|
|
2
|
+
import { AVLTreeOptions } from './avl-tree';
|
|
3
3
|
|
|
4
4
|
export type TreeMultimapNodeNested<T> = TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
5
|
|
|
@@ -7,11 +7,11 @@ export type HashMapOptions<T> = {
|
|
|
7
7
|
sizeFunction?: number | (() => number);
|
|
8
8
|
fixedLength?: number;
|
|
9
9
|
forEach: (callback: (el: T) => void) => void;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
export type HashMapLinkedNode<K, V> = {
|
|
13
|
-
key: K
|
|
14
|
-
value: V
|
|
15
|
-
next: HashMapLinkedNode<K, V
|
|
16
|
-
prev: HashMapLinkedNode<K, V
|
|
17
|
-
}
|
|
13
|
+
key: K;
|
|
14
|
+
value: V;
|
|
15
|
+
next: HashMapLinkedNode<K, V>;
|
|
16
|
+
prev: HashMapLinkedNode<K, V>;
|
|
17
|
+
};
|
package/src/types/utils/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type ToThunkFn = () => ReturnType<TrlFn>;
|
|
2
|
-
export type Thunk = () => ReturnType<ToThunkFn> & {__THUNK__: symbol};
|
|
2
|
+
export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: symbol };
|
|
3
3
|
export type TrlFn = (...args: any[]) => any;
|
|
4
4
|
export type TrlAsyncFn = (...args: any[]) => any;
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type KeyValueObject = {[key: string]: any};
|
|
1
|
+
export type KeyValueObject = { [key: string]: any };
|
|
2
2
|
|
|
3
|
-
export type KeyValueObjectWithKey = {[key: string]: any; key: string | number | symbol};
|
|
3
|
+
export type KeyValueObjectWithKey = { [key: string]: any; key: string | number | symbol };
|
|
4
4
|
|
|
5
5
|
export type NonNumberNonObjectButDefined = string | boolean | symbol | null;
|
|
6
6
|
|
|
@@ -16,6 +16,20 @@ export type ObjectWithNumberKey = {
|
|
|
16
16
|
key: number;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export type RestrictValByKey =
|
|
19
|
+
export type RestrictValByKey =
|
|
20
|
+
| NonNumberNonObjectButDefined
|
|
21
|
+
| ObjectWithoutKey
|
|
22
|
+
| ObjectWithNonNumberKey
|
|
23
|
+
| ObjectWithNumberKey;
|
|
20
24
|
|
|
21
|
-
export type DummyAny =
|
|
25
|
+
export type DummyAny =
|
|
26
|
+
| string
|
|
27
|
+
| number
|
|
28
|
+
| boolean
|
|
29
|
+
| null
|
|
30
|
+
| undefined
|
|
31
|
+
| object
|
|
32
|
+
| symbol
|
|
33
|
+
| void
|
|
34
|
+
| ((...args: []) => any)
|
|
35
|
+
| never;
|
package/src/utils/utils.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type {Thunk, ToThunkFn, TrlAsyncFn, TrlFn} from '../types';
|
|
8
|
+
import type { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types';
|
|
9
9
|
|
|
10
10
|
export const uuidV4 = function () {
|
|
11
11
|
return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
|
|
@@ -57,7 +57,7 @@ export const trampoline = (fn: TrlFn) => {
|
|
|
57
57
|
|
|
58
58
|
return result;
|
|
59
59
|
},
|
|
60
|
-
{cont}
|
|
60
|
+
{ cont }
|
|
61
61
|
);
|
|
62
62
|
};
|
|
63
63
|
|
|
@@ -74,7 +74,7 @@ export const trampolineAsync = (fn: TrlAsyncFn) => {
|
|
|
74
74
|
|
|
75
75
|
return result;
|
|
76
76
|
},
|
|
77
|
-
{cont}
|
|
77
|
+
{ cont }
|
|
78
78
|
);
|
|
79
79
|
};
|
|
80
80
|
|
|
@@ -87,13 +87,13 @@ export const getMSB = (value: number): number => {
|
|
|
87
87
|
|
|
88
88
|
export const rangeCheck = (index: number, min: number, max: number, message = 'Index out of bounds.'): void => {
|
|
89
89
|
if (index < min || index > max) throw new RangeError(message);
|
|
90
|
-
}
|
|
90
|
+
};
|
|
91
91
|
|
|
92
92
|
export const throwRangeError = (message = 'The value is off-limits.'): void => {
|
|
93
93
|
throw new RangeError(message);
|
|
94
|
-
}
|
|
94
|
+
};
|
|
95
95
|
|
|
96
96
|
export const isObjOrFunc = (input: unknown): input is Record<string, unknown> | ((...args: any[]) => any) => {
|
|
97
97
|
const inputType = typeof input;
|
|
98
98
|
return (inputType === 'object' && input !== null) || inputType === 'function';
|
|
99
|
-
}
|
|
99
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {BST, BSTNode, CP} from 'bst-typed';
|
|
1
|
+
import { BST, BSTNode, CP } from 'bst-typed';
|
|
2
2
|
|
|
3
3
|
describe('Individual package BST operations test', () => {
|
|
4
4
|
it('should perform various operations on a Binary Search Tree with numeric values', () => {
|
|
@@ -183,25 +183,25 @@ describe('Individual package BST operations test', () => {
|
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
it('should perform various operations on a Binary Search Tree with object values', () => {
|
|
186
|
-
const objBST = new BST<{key: number; keyA: number}>();
|
|
186
|
+
const objBST = new BST<{ key: number; keyA: number }>();
|
|
187
187
|
expect(objBST).toBeInstanceOf(BST);
|
|
188
|
-
objBST.add(11, {key: 11, keyA: 11});
|
|
189
|
-
objBST.add(3, {key: 3, keyA: 3});
|
|
188
|
+
objBST.add(11, { key: 11, keyA: 11 });
|
|
189
|
+
objBST.add(3, { key: 3, keyA: 3 });
|
|
190
190
|
const values = [
|
|
191
|
-
{key: 15, keyA: 15},
|
|
192
|
-
{key: 1, keyA: 1},
|
|
193
|
-
{key: 8, keyA: 8},
|
|
194
|
-
{key: 13, keyA: 13},
|
|
195
|
-
{key: 16, keyA: 16},
|
|
196
|
-
{key: 2, keyA: 2},
|
|
197
|
-
{key: 6, keyA: 6},
|
|
198
|
-
{key: 9, keyA: 9},
|
|
199
|
-
{key: 12, keyA: 12},
|
|
200
|
-
{key: 14, keyA: 14},
|
|
201
|
-
{key: 4, keyA: 4},
|
|
202
|
-
{key: 7, keyA: 7},
|
|
203
|
-
{key: 10, keyA: 10},
|
|
204
|
-
{key: 5, keyA: 5}
|
|
191
|
+
{ key: 15, keyA: 15 },
|
|
192
|
+
{ key: 1, keyA: 1 },
|
|
193
|
+
{ key: 8, keyA: 8 },
|
|
194
|
+
{ key: 13, keyA: 13 },
|
|
195
|
+
{ key: 16, keyA: 16 },
|
|
196
|
+
{ key: 2, keyA: 2 },
|
|
197
|
+
{ key: 6, keyA: 6 },
|
|
198
|
+
{ key: 9, keyA: 9 },
|
|
199
|
+
{ key: 12, keyA: 12 },
|
|
200
|
+
{ key: 14, keyA: 14 },
|
|
201
|
+
{ key: 4, keyA: 4 },
|
|
202
|
+
{ key: 7, keyA: 7 },
|
|
203
|
+
{ key: 10, keyA: 10 },
|
|
204
|
+
{ key: 5, keyA: 5 }
|
|
205
205
|
];
|
|
206
206
|
|
|
207
207
|
objBST.addMany(
|
|
@@ -230,7 +230,7 @@ describe('Individual package BST operations test', () => {
|
|
|
230
230
|
expect(leftMost?.key).toBe(1);
|
|
231
231
|
|
|
232
232
|
const node15 = objBST.getNode(15);
|
|
233
|
-
expect(node15?.value).toEqual({key: 15, keyA: 15});
|
|
233
|
+
expect(node15?.value).toEqual({ key: 15, keyA: 15 });
|
|
234
234
|
const minNodeBySpecificNode = node15 && objBST.getLeftMost(node15);
|
|
235
235
|
expect(minNodeBySpecificNode?.key).toBe(12);
|
|
236
236
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
console.error(e);
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
38
|
-
const {AVLTree} = window.dataStructureTyped;
|
|
38
|
+
const { AVLTree } = window.dataStructureTyped;
|
|
39
39
|
const avlTree = new AVLTree();
|
|
40
40
|
const $avlTree = document.createElement('li');
|
|
41
41
|
const $avlTreeSpan = document.createElement('span');
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
try {
|
|
55
|
-
const {BinaryTree} = dataStructureTyped;
|
|
55
|
+
const { BinaryTree } = dataStructureTyped;
|
|
56
56
|
const tree = new BinaryTree();
|
|
57
57
|
tree.add(3);
|
|
58
58
|
tree.add(12);
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
try {
|
|
79
|
-
const {OrderedMap} = sdsl;
|
|
80
|
-
const {RedBlackTree} = dataStructureTyped;
|
|
79
|
+
const { OrderedMap } = sdsl;
|
|
80
|
+
const { RedBlackTree } = dataStructureTyped;
|
|
81
81
|
const cTree = new OrderedMap();
|
|
82
82
|
const tree = new RedBlackTree();
|
|
83
83
|
const tS = performance.now();
|
|
@@ -101,9 +101,9 @@
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
try {
|
|
104
|
-
const {PriorityQueue: CPriorityQueue} = sdsl;
|
|
105
|
-
const {PriorityQueue} = dataStructureTyped;
|
|
106
|
-
const pq = new PriorityQueue({comparator: (a, b) => b - a});
|
|
104
|
+
const { PriorityQueue: CPriorityQueue } = sdsl;
|
|
105
|
+
const { PriorityQueue } = dataStructureTyped;
|
|
106
|
+
const pq = new PriorityQueue({ comparator: (a, b) => b - a });
|
|
107
107
|
|
|
108
108
|
const tS = performance.now();
|
|
109
109
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {AVLTree} from '../../../../src';
|
|
1
|
+
import { AVLTree } from '../../../../src';
|
|
2
2
|
import * as Benchmark from 'benchmark';
|
|
3
|
-
import {getRandomIntArray, magnitude} from '../../../utils';
|
|
3
|
+
import { getRandomIntArray, magnitude } from '../../../utils';
|
|
4
4
|
|
|
5
5
|
const suite = new Benchmark.Suite();
|
|
6
6
|
const avl = new AVLTree<number>();
|
|
7
|
-
const {TEN_THOUSAND} = magnitude;
|
|
7
|
+
const { TEN_THOUSAND } = magnitude;
|
|
8
8
|
const arr = getRandomIntArray(TEN_THOUSAND, 0, TEN_THOUSAND, true);
|
|
9
9
|
|
|
10
10
|
suite
|
|
@@ -33,4 +33,4 @@ suite
|
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
export {suite};
|
|
36
|
+
export { suite };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {BinaryTree} from '../../../../src';
|
|
1
|
+
import { BinaryTree } from '../../../../src';
|
|
2
2
|
import * as Benchmark from 'benchmark';
|
|
3
|
-
import {getRandomIntArray, magnitude} from '../../../utils';
|
|
3
|
+
import { getRandomIntArray, magnitude } from '../../../utils';
|
|
4
4
|
|
|
5
5
|
const suite = new Benchmark.Suite();
|
|
6
6
|
const biTree = new BinaryTree<number>();
|
|
7
|
-
const {N_LOG_N} = magnitude;
|
|
7
|
+
const { N_LOG_N } = magnitude;
|
|
8
8
|
const arr = getRandomIntArray(N_LOG_N, 0, N_LOG_N, true);
|
|
9
9
|
|
|
10
10
|
suite
|
|
@@ -42,4 +42,4 @@ suite
|
|
|
42
42
|
for (let i = 0; i < N_LOG_N; i++) biTree.morris(n => n, 'pre');
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
export {suite};
|
|
45
|
+
export { suite };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {BST} from '../../../../src';
|
|
1
|
+
import { BST } from '../../../../src';
|
|
2
2
|
import * as Benchmark from 'benchmark';
|
|
3
|
-
import {getRandomIntArray, magnitude} from '../../../utils';
|
|
3
|
+
import { getRandomIntArray, magnitude } from '../../../utils';
|
|
4
4
|
|
|
5
5
|
const suite = new Benchmark.Suite();
|
|
6
6
|
const bst = new BST<number>();
|
|
7
|
-
const {TEN_THOUSAND} = magnitude;
|
|
7
|
+
const { TEN_THOUSAND } = magnitude;
|
|
8
8
|
const arr = getRandomIntArray(TEN_THOUSAND, 0, TEN_THOUSAND, true);
|
|
9
9
|
|
|
10
10
|
suite
|
|
@@ -33,4 +33,4 @@ suite
|
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
export {suite};
|
|
36
|
+
export { suite };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {RedBlackTree} from '../../../../src';
|
|
1
|
+
import { RedBlackTree } from '../../../../src';
|
|
2
2
|
import * as Benchmark from 'benchmark';
|
|
3
|
-
import {getRandomIntArray, magnitude} from '../../../utils';
|
|
4
|
-
import {OrderedMap} from 'js-sdsl';
|
|
5
|
-
import {isCompetitor} from '../../../config';
|
|
3
|
+
import { getRandomIntArray, magnitude } from '../../../utils';
|
|
4
|
+
import { OrderedMap } from 'js-sdsl';
|
|
5
|
+
import { isCompetitor } from '../../../config';
|
|
6
6
|
|
|
7
7
|
const suite = new Benchmark.Suite();
|
|
8
8
|
const rbTree = new RedBlackTree();
|
|
9
|
-
const {HUNDRED_THOUSAND} = magnitude;
|
|
9
|
+
const { HUNDRED_THOUSAND } = magnitude;
|
|
10
10
|
const arr = getRandomIntArray(HUNDRED_THOUSAND, 0, HUNDRED_THOUSAND, true);
|
|
11
11
|
const competitor = new OrderedMap<number, number>();
|
|
12
12
|
|
|
@@ -41,4 +41,4 @@ suite
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
export {suite};
|
|
44
|
+
export { suite };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {DirectedGraph} from '../../../../src';
|
|
1
|
+
import { DirectedGraph } from '../../../../src';
|
|
2
2
|
import * as Benchmark from 'benchmark';
|
|
3
|
-
import {getRandomIndex, getRandomWords, magnitude} from '../../../utils';
|
|
3
|
+
import { getRandomIndex, getRandomWords, magnitude } from '../../../utils';
|
|
4
4
|
|
|
5
5
|
const suite = new Benchmark.Suite();
|
|
6
|
-
const {THOUSAND} = magnitude;
|
|
6
|
+
const { THOUSAND } = magnitude;
|
|
7
7
|
const graph = new DirectedGraph<number, number>();
|
|
8
8
|
const vertexes = getRandomWords(THOUSAND);
|
|
9
9
|
|
|
@@ -46,4 +46,4 @@ suite
|
|
|
46
46
|
// }
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
export {suite};
|
|
49
|
+
export { suite };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {HashMap} from '../../../../src';
|
|
2
|
-
import {HashMap as CHashMap} from 'js-sdsl';
|
|
1
|
+
import { HashMap } from '../../../../src';
|
|
2
|
+
import { HashMap as CHashMap } from 'js-sdsl';
|
|
3
3
|
import * as Benchmark from 'benchmark';
|
|
4
|
-
import {magnitude} from '../../../utils';
|
|
5
|
-
import {isCompetitor} from '../../../config';
|
|
4
|
+
import { magnitude } from '../../../utils';
|
|
5
|
+
import { isCompetitor } from '../../../config';
|
|
6
6
|
|
|
7
7
|
const suite = new Benchmark.Suite();
|
|
8
|
-
const {TEN_THOUSAND} = magnitude;
|
|
8
|
+
const { TEN_THOUSAND } = magnitude;
|
|
9
9
|
|
|
10
10
|
suite.add(`${TEN_THOUSAND.toLocaleString()} set`, () => {
|
|
11
11
|
const hm = new HashMap<number, number>();
|
|
@@ -45,4 +45,4 @@ if (isCompetitor) {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
export {suite};
|
|
48
|
+
export { suite };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {FibonacciHeap, Heap} from '../../../../src';
|
|
1
|
+
import { FibonacciHeap, Heap } from '../../../../src';
|
|
2
2
|
import * as Benchmark from 'benchmark';
|
|
3
|
-
import {magnitude} from '../../../utils';
|
|
3
|
+
import { magnitude } from '../../../utils';
|
|
4
4
|
|
|
5
5
|
const suite = new Benchmark.Suite();
|
|
6
|
-
const {TEN_THOUSAND} = magnitude;
|
|
6
|
+
const { TEN_THOUSAND } = magnitude;
|
|
7
7
|
|
|
8
8
|
suite
|
|
9
9
|
.add(`${TEN_THOUSAND.toLocaleString()} add & pop`, () => {
|
|
10
|
-
const heap = new Heap<number>({comparator: (a, b) => b - a});
|
|
10
|
+
const heap = new Heap<number>({ comparator: (a, b) => b - a });
|
|
11
11
|
|
|
12
12
|
for (let i = 0; i < TEN_THOUSAND; i++) {
|
|
13
13
|
heap.add(i);
|
|
@@ -27,4 +27,4 @@ suite
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
export {suite};
|
|
30
|
+
export { suite };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {DoublyLinkedList, DoublyLinkedListNode} from '../../../../src';
|
|
2
|
-
import {LinkList as CLinkedList} from 'js-sdsl';
|
|
1
|
+
import { DoublyLinkedList, DoublyLinkedListNode } from '../../../../src';
|
|
2
|
+
import { LinkList as CLinkedList } from 'js-sdsl';
|
|
3
3
|
import * as Benchmark from 'benchmark';
|
|
4
|
-
import {magnitude} from '../../../utils';
|
|
5
|
-
import {isCompetitor} from '../../../config';
|
|
4
|
+
import { magnitude } from '../../../utils';
|
|
5
|
+
import { isCompetitor } from '../../../config';
|
|
6
6
|
|
|
7
7
|
const suite = new Benchmark.Suite();
|
|
8
|
-
const {LINEAR} = magnitude;
|
|
8
|
+
const { LINEAR } = magnitude;
|
|
9
9
|
|
|
10
10
|
suite.add(`${LINEAR.toLocaleString()} unshift`, () => {
|
|
11
11
|
const list = new DoublyLinkedList<number>();
|
|
@@ -48,4 +48,4 @@ suite
|
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
export {suite};
|
|
51
|
+
export { suite };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {SinglyLinkedList, SinglyLinkedListNode} from '../../../../src';
|
|
1
|
+
import { SinglyLinkedList, SinglyLinkedListNode } from '../../../../src';
|
|
2
2
|
import * as Benchmark from 'benchmark';
|
|
3
|
-
import {magnitude} from '../../../utils';
|
|
3
|
+
import { magnitude } from '../../../utils';
|
|
4
4
|
|
|
5
5
|
const suite = new Benchmark.Suite();
|
|
6
|
-
const {TEN_THOUSAND} = magnitude;
|
|
6
|
+
const { TEN_THOUSAND } = magnitude;
|
|
7
7
|
|
|
8
8
|
suite
|
|
9
9
|
.add(`${TEN_THOUSAND.toLocaleString()} push & pop`, () => {
|
|
@@ -31,4 +31,4 @@ suite
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
export {suite};
|
|
34
|
+
export { suite };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {MaxPriorityQueue} from '../../../../src';
|
|
1
|
+
import { MaxPriorityQueue } from '../../../../src';
|
|
2
2
|
import * as Benchmark from 'benchmark';
|
|
3
|
-
import {magnitude} from '../../../utils';
|
|
3
|
+
import { magnitude } from '../../../utils';
|
|
4
4
|
|
|
5
5
|
const suite = new Benchmark.Suite();
|
|
6
|
-
const {TEN_THOUSAND} = magnitude;
|
|
6
|
+
const { TEN_THOUSAND } = magnitude;
|
|
7
7
|
|
|
8
8
|
suite.add(`${TEN_THOUSAND.toLocaleString()} refill & poll`, () => {
|
|
9
|
-
const nodes = Array.from(
|
|
9
|
+
const nodes = Array.from(
|
|
10
|
+
new Set<number>(Array.from(new Array(TEN_THOUSAND), () => Math.floor(Math.random() * TEN_THOUSAND * 100)))
|
|
11
|
+
);
|
|
10
12
|
const maxPQ = new MaxPriorityQueue<number>();
|
|
11
13
|
maxPQ.refill(nodes);
|
|
12
14
|
while (maxPQ.size > 0) {
|
|
@@ -14,4 +16,4 @@ suite.add(`${TEN_THOUSAND.toLocaleString()} refill & poll`, () => {
|
|
|
14
16
|
}
|
|
15
17
|
});
|
|
16
18
|
|
|
17
|
-
export {suite};
|
|
19
|
+
export { suite };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {PriorityQueue as CPriorityQueue} from 'js-sdsl';
|
|
2
|
-
import {PriorityQueue} from '../../../../src';
|
|
1
|
+
import { PriorityQueue as CPriorityQueue } from 'js-sdsl';
|
|
2
|
+
import { PriorityQueue } from '../../../../src';
|
|
3
3
|
import * as Benchmark from 'benchmark';
|
|
4
|
-
import {magnitude} from '../../../utils';
|
|
5
|
-
import {isCompetitor} from '../../../config';
|
|
4
|
+
import { magnitude } from '../../../utils';
|
|
5
|
+
import { isCompetitor } from '../../../config';
|
|
6
6
|
|
|
7
7
|
const suite = new Benchmark.Suite();
|
|
8
|
-
const {TEN_THOUSAND} = magnitude;
|
|
8
|
+
const { TEN_THOUSAND } = magnitude;
|
|
9
9
|
|
|
10
10
|
suite.add(`${TEN_THOUSAND.toLocaleString()} add & pop`, () => {
|
|
11
|
-
const pq = new PriorityQueue<number>({comparator: (a, b) => b - a});
|
|
11
|
+
const pq = new PriorityQueue<number>({ comparator: (a, b) => b - a });
|
|
12
12
|
|
|
13
13
|
for (let i = 0; i < TEN_THOUSAND; i++) {
|
|
14
14
|
pq.add(i);
|
|
@@ -32,4 +32,4 @@ if (isCompetitor) {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export {suite};
|
|
35
|
+
export { suite };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {Deque} from '../../../../src';
|
|
2
|
-
import {Deque as CDeque} from 'js-sdsl';
|
|
1
|
+
import { Deque } from '../../../../src';
|
|
2
|
+
import { Deque as CDeque } from 'js-sdsl';
|
|
3
3
|
import * as Benchmark from 'benchmark';
|
|
4
|
-
import {magnitude} from '../../../utils';
|
|
5
|
-
import {isCompetitor} from '../../../config';
|
|
4
|
+
import { magnitude } from '../../../utils';
|
|
5
|
+
import { isCompetitor } from '../../../config';
|
|
6
6
|
|
|
7
7
|
export const suite = new Benchmark.Suite();
|
|
8
|
-
const {LINEAR} = magnitude;
|
|
8
|
+
const { LINEAR } = magnitude;
|
|
9
9
|
|
|
10
10
|
suite.add(`${LINEAR.toLocaleString()} push`, () => {
|
|
11
11
|
const deque = new Deque<number>();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {Queue} from '../../../../src';
|
|
2
|
-
import {Queue as CQueue} from 'js-sdsl';
|
|
1
|
+
import { Queue } from '../../../../src';
|
|
2
|
+
import { Queue as CQueue } from 'js-sdsl';
|
|
3
3
|
import * as Benchmark from 'benchmark';
|
|
4
|
-
import {magnitude} from '../../../utils';
|
|
5
|
-
import {isCompetitor} from '../../../config';
|
|
4
|
+
import { magnitude } from '../../../utils';
|
|
5
|
+
import { isCompetitor } from '../../../config';
|
|
6
6
|
|
|
7
7
|
const suite = new Benchmark.Suite();
|
|
8
|
-
const {LINEAR} = magnitude;
|
|
8
|
+
const { LINEAR } = magnitude;
|
|
9
9
|
|
|
10
10
|
suite.add(`${LINEAR.toLocaleString()} push`, () => {
|
|
11
11
|
const queue = new Queue<number>();
|
|
@@ -32,4 +32,4 @@ suite.add(`${LINEAR.toLocaleString()} push & shift`, () => {
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
export {suite};
|
|
35
|
+
export { suite };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {Stack} from '../../../../src';
|
|
2
|
-
import {Stack as CStack} from 'js-sdsl';
|
|
1
|
+
import { Stack } from '../../../../src';
|
|
2
|
+
import { Stack as CStack } from 'js-sdsl';
|
|
3
3
|
import * as Benchmark from 'benchmark';
|
|
4
|
-
import {magnitude} from '../../../utils';
|
|
5
|
-
import {isCompetitor} from '../../../config';
|
|
4
|
+
import { magnitude } from '../../../utils';
|
|
5
|
+
import { isCompetitor } from '../../../config';
|
|
6
6
|
|
|
7
7
|
const suite = new Benchmark.Suite();
|
|
8
|
-
const {LINEAR} = magnitude;
|
|
8
|
+
const { LINEAR } = magnitude;
|
|
9
9
|
|
|
10
10
|
suite.add(`${LINEAR.toLocaleString()} push`, () => {
|
|
11
11
|
const stack = new Stack<number>();
|
|
@@ -46,4 +46,4 @@ if (isCompetitor) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export {suite};
|
|
49
|
+
export { suite };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {Trie} from '../../../../src';
|
|
1
|
+
import { Trie } from '../../../../src';
|
|
2
2
|
import * as Benchmark from 'benchmark';
|
|
3
|
-
import {getRandomWords, magnitude} from '../../../utils';
|
|
3
|
+
import { getRandomWords, magnitude } from '../../../utils';
|
|
4
4
|
|
|
5
5
|
const suite = new Benchmark.Suite();
|
|
6
|
-
const {HUNDRED_THOUSAND} = magnitude;
|
|
6
|
+
const { HUNDRED_THOUSAND } = magnitude;
|
|
7
7
|
const trie = new Trie();
|
|
8
8
|
const randomWords = getRandomWords(HUNDRED_THOUSAND, false);
|
|
9
9
|
|
|
@@ -19,4 +19,4 @@ suite
|
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
export {suite};
|
|
22
|
+
export { suite };
|