data-structure-typed 1.43.1 → 1.43.3
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 +3 -1
- package/CHANGELOG.md +1 -1
- package/README.md +7 -0
- package/benchmark/report.html +30 -30
- package/benchmark/report.json +201 -147
- package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +62 -62
- package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +4 -4
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +1 -1
- package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.d.ts +24 -24
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
- package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
- package/dist/cjs/src/data-structures/graph/abstract-graph.js +37 -37
- package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/src/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/src/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/src/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/src/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/src/interfaces/binary-tree.d.ts +1 -1
- package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
- package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +62 -62
- package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +4 -4
- package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +1 -1
- package/dist/mjs/src/data-structures/binary-tree/tree-multimap.d.ts +24 -24
- package/dist/mjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
- package/dist/mjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
- package/dist/mjs/src/data-structures/graph/abstract-graph.js +37 -37
- package/dist/mjs/src/interfaces/binary-tree.d.ts +1 -1
- package/dist/umd/data-structure-typed.js +10497 -0
- 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 +2 -3
- package/src/data-structures/binary-tree/binary-tree.ts +85 -92
- package/src/data-structures/binary-tree/bst.ts +14 -22
- package/src/data-structures/binary-tree/rb-tree.ts +11 -20
- package/src/data-structures/binary-tree/tree-multimap.ts +56 -58
- package/src/data-structures/graph/abstract-graph.ts +6 -22
- package/src/data-structures/graph/directed-graph.ts +3 -9
- package/src/data-structures/graph/map-graph.ts +6 -6
- package/src/data-structures/graph/undirected-graph.ts +1 -2
- package/src/data-structures/heap/heap.ts +1 -6
- package/src/data-structures/trie/trie.ts +1 -1
- package/src/interfaces/binary-tree.ts +1 -1
- package/src/types/utils/validate-type.ts +2 -16
- package/test/integration/index.html +50 -4
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +18 -19
- package/test/performance/data-structures/hash/hash-map.test.ts +10 -13
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +16 -16
- package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +1 -3
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +10 -12
- package/test/performance/data-structures/queue/deque.test.ts +18 -19
- package/test/performance/data-structures/queue/queue.test.ts +18 -19
- package/test/performance/data-structures/stack/stack.test.ts +10 -11
- package/test/performance/reportor.ts +4 -5
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +0 -1
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +83 -61
- package/test/unit/data-structures/binary-tree/bst.test.ts +2 -6
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +34 -25
- package/test/unit/data-structures/graph/abstract-graph.test.ts +6 -6
- package/test/unit/data-structures/graph/directed-graph.test.ts +8 -28
- package/test/unit/data-structures/heap/heap.test.ts +1 -8
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +34 -12
- package/test/utils/json2html.ts +2 -6
- package/tsup.config.js +19 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {PriorityQueue} from '../../../../src';
|
|
2
|
-
import {
|
|
2
|
+
import {PriorityQueue as CPriorityQueue} from 'js-sdsl';
|
|
3
|
+
import {isDebugTest} from '../../../config';
|
|
3
4
|
|
|
5
|
+
const isDebug = isDebugTest;
|
|
4
6
|
describe('PriorityQueue Operation Test', () => {
|
|
5
7
|
it('should PriorityQueue poll, pee, heapify, toArray work well', function () {
|
|
6
8
|
const minPQ = new PriorityQueue<number>({comparator: (a, b) => a - b});
|
|
@@ -11,9 +13,9 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
11
13
|
minPQ.poll();
|
|
12
14
|
expect(minPQ.toArray()).toEqual([4, 5, 6]);
|
|
13
15
|
expect(minPQ.peek()).toBe(4);
|
|
14
|
-
expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual(
|
|
15
|
-
|
|
16
|
-
);
|
|
16
|
+
expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual([
|
|
17
|
+
1, 2, 3, 5, 6, 7, 8, 9, 10
|
|
18
|
+
]);
|
|
17
19
|
});
|
|
18
20
|
|
|
19
21
|
it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () {
|
|
@@ -25,9 +27,9 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
25
27
|
maxPriorityQueue.poll();
|
|
26
28
|
expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]);
|
|
27
29
|
expect(maxPriorityQueue.peek()).toBe(3);
|
|
28
|
-
expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual(
|
|
29
|
-
|
|
30
|
-
);
|
|
30
|
+
expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual([
|
|
31
|
+
1, 2, 3, 5, 6, 7, 8, 9, 10
|
|
32
|
+
]);
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
it('should PriorityQueue clone, sort, getNodes, dfs work well', function () {
|
|
@@ -44,10 +46,30 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
44
46
|
|
|
45
47
|
describe('Priority Queue Performance Test', () => {
|
|
46
48
|
it('should numeric heap work well', function () {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const pq = new PriorityQueue({comparator: (a, b) => b - a});
|
|
50
|
+
|
|
51
|
+
const tS = performance.now();
|
|
52
|
+
|
|
53
|
+
for (let i = 0; i < 100000; i++) {
|
|
54
|
+
pq.add(i);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// for (let i = 0; i < 10000; i++) {
|
|
58
|
+
// pq.pop();
|
|
59
|
+
// }
|
|
60
|
+
isDebug && console.log(performance.now() - tS);
|
|
61
|
+
isDebug && console.log(pq.size);
|
|
62
|
+
const cS = performance.now();
|
|
63
|
+
const cpq = new CPriorityQueue();
|
|
64
|
+
|
|
65
|
+
for (let i = 0; i < 100000; i++) {
|
|
66
|
+
cpq.push(i);
|
|
67
|
+
}
|
|
68
|
+
//
|
|
69
|
+
// for (let i = 0; i < 10000; i++) {
|
|
70
|
+
// cpq.pop();
|
|
71
|
+
// }
|
|
72
|
+
isDebug && console.log(performance.now() - cS);
|
|
73
|
+
isDebug && console.log(cpq.size());
|
|
52
74
|
});
|
|
53
75
|
});
|
package/test/utils/json2html.ts
CHANGED
|
@@ -14,9 +14,7 @@ function makeLabelDiv(options: any, level: number, keyName: string | number, dat
|
|
|
14
14
|
return `<div class='index'><span class='json-to-html-label'>${keyName} </span></div>`;
|
|
15
15
|
} else if (typeof keyName === 'string') {
|
|
16
16
|
if (datatype === 'array') {
|
|
17
|
-
return `<div class='collapsible level${level}' ${toggleJS(
|
|
18
|
-
options
|
|
19
|
-
)}><span class='json-to-html-label'>${keyName}</span></div>`;
|
|
17
|
+
return `<div class='collapsible level${level}' ${toggleJS(options)}><span class='json-to-html-label'>${keyName}</span></div>`;
|
|
20
18
|
} else if (datatype === 'object') {
|
|
21
19
|
return `<div class='attribute collapsible level${level}' ${toggleJS(
|
|
22
20
|
options
|
|
@@ -122,9 +120,7 @@ function _render(name: string, data: any, options: Json2htmlOptions, level: numb
|
|
|
122
120
|
} else {
|
|
123
121
|
subs =
|
|
124
122
|
"<div class='altRows'>" +
|
|
125
|
-
data
|
|
126
|
-
.map((val: any, idx: number) => _render(idx.toString(), val, options, level + 1, idx % 2))
|
|
127
|
-
.join("</div><div class='altRows'>") +
|
|
123
|
+
data.map((val: any, idx: number) => _render(idx.toString(), val, options, level + 1, idx % 2)).join("</div><div class='altRows'>") +
|
|
128
124
|
'</div>';
|
|
129
125
|
}
|
|
130
126
|
return `<div class="json-to-html-collapse clearfix ${altRow}">
|
package/tsup.config.js
CHANGED
|
@@ -15,4 +15,22 @@ export default [{
|
|
|
15
15
|
js: `.min.js`,
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
entryPoints: {
|
|
21
|
+
"data-structure-typed": "src/index.ts"
|
|
22
|
+
},
|
|
23
|
+
format: ["iife"],
|
|
24
|
+
clean: true,
|
|
25
|
+
sourcemap: false,
|
|
26
|
+
minify: false,
|
|
27
|
+
outDir: "dist/umd",
|
|
28
|
+
globalName: "dataStructureTyped",
|
|
29
|
+
platform: "browser",
|
|
30
|
+
bundle: true,
|
|
31
|
+
outExtension() {
|
|
32
|
+
return {
|
|
33
|
+
js: `.js`,
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
}];
|