priority-queue-typed 1.34.4 → 1.34.6
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/coverage/clover.xml
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1696760609900" clover="3.2.0">
|
|
3
|
+
<project timestamp="1696760609900" name="All files">
|
|
4
4
|
<metrics statements="1" coveredstatements="1" conditionals="0" coveredconditionals="0" methods="3" coveredmethods="1" elements="4" coveredelements="2" complexity="0" loc="1" ncloc="1" packages="1" files="1" classes="1"/>
|
|
5
5
|
<file name="index.ts" path="/Users/revone/projects/data-structure-typed-individuals/priority-queue-typed/src/index.ts">
|
|
6
6
|
<metrics statements="1" coveredstatements="1" conditionals="0" coveredconditionals="0" methods="3" coveredmethods="1"/>
|
|
7
|
-
<line num="8" count="
|
|
7
|
+
<line num="8" count="10" type="stmt"/>
|
|
8
8
|
</file>
|
|
9
9
|
</project>
|
|
10
10
|
</coverage>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
{"/Users/revone/projects/data-structure-typed-individuals/priority-queue-typed/src/index.ts": {"path":"/Users/revone/projects/data-structure-typed-individuals/priority-queue-typed/src/index.ts","statementMap":{"0":{"start":{"line":8,"column":0},"end":{"line":8,"column":9}},"1":{"start":{"line":8,"column":9},"end":{"line":8,"column":24}},"2":{"start":{"line":8,"column":24},"end":{"line":8,"column":42}},"3":{"start":{"line":8,"column":42},"end":{"line":8,"column":89}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":8,"column":9},"end":{"line":8,"column":22}},"loc":{"start":{"line":8,"column":9},"end":{"line":8,"column":24}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":8,"column":24},"end":{"line":8,"column":40}},"loc":{"start":{"line":8,"column":24},"end":{"line":8,"column":42}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":8,"column":42},"end":{"line":8,"column":58}},"loc":{"start":{"line":8,"column":42},"end":{"line":8,"column":89}}}},"branchMap":{},"s":{"0":1,"1":
|
|
1
|
+
{"/Users/revone/projects/data-structure-typed-individuals/priority-queue-typed/src/index.ts": {"path":"/Users/revone/projects/data-structure-typed-individuals/priority-queue-typed/src/index.ts","statementMap":{"0":{"start":{"line":8,"column":0},"end":{"line":8,"column":9}},"1":{"start":{"line":8,"column":9},"end":{"line":8,"column":24}},"2":{"start":{"line":8,"column":24},"end":{"line":8,"column":42}},"3":{"start":{"line":8,"column":42},"end":{"line":8,"column":89}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":8,"column":9},"end":{"line":8,"column":22}},"loc":{"start":{"line":8,"column":9},"end":{"line":8,"column":24}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":8,"column":24},"end":{"line":8,"column":40}},"loc":{"start":{"line":8,"column":24},"end":{"line":8,"column":42}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":8,"column":42},"end":{"line":8,"column":58}},"loc":{"start":{"line":8,"column":42},"end":{"line":8,"column":89}}}},"branchMap":{},"s":{"0":1,"1":10,"2":1,"3":1},"f":{"0":9,"1":0,"2":0},"b":{}}
|
|
2
2
|
}
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
102
102
|
Code coverage generated by
|
|
103
103
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
104
|
-
at 2023-10-
|
|
104
|
+
at 2023-10-08T10:23:29.918Z
|
|
105
105
|
</div>
|
|
106
106
|
<script src="prettify.js"></script>
|
|
107
107
|
<script>
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
<span class="cline-any cline-neutral"> </span>
|
|
79
79
|
<span class="cline-any cline-neutral"> </span>
|
|
80
80
|
<span class="cline-any cline-neutral"> </span>
|
|
81
|
-
<span class="cline-any cline-yes">
|
|
81
|
+
<span class="cline-any cline-yes">10x</span>
|
|
82
82
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/**
|
|
83
83
|
* data-structure-typed
|
|
84
84
|
*
|
|
@@ -94,7 +94,7 @@ export { PriorityQueue, <span class="fstat-no" title="function not covered" >Max
|
|
|
94
94
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
95
95
|
Code coverage generated by
|
|
96
96
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
97
|
-
at 2023-10-
|
|
97
|
+
at 2023-10-08T10:23:29.918Z
|
|
98
98
|
</div>
|
|
99
99
|
<script src="prettify.js"></script>
|
|
100
100
|
<script>
|
package/coverage/lcov.info
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "priority-queue-typed",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.6",
|
|
4
4
|
"description": "Priority Queue, Min Priority Queue, Max Priority Queue. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -119,6 +119,6 @@
|
|
|
119
119
|
"typedoc": "^0.25.1"
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
|
-
"data-structure-typed": "^1.34.
|
|
122
|
+
"data-structure-typed": "^1.34.6"
|
|
123
123
|
}
|
|
124
124
|
}
|
package/test/index.test.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {PriorityQueue} from '../src';
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
describe('PriorityQueue Operation Test', () => {
|
|
4
5
|
it('should validate a priority queue', () => {
|
|
5
6
|
const minPQ = new PriorityQueue<number>({nodes: [1, 5, 7, 9, 3, 6, 2], comparator: (a, b) => a - b});
|
|
@@ -14,4 +15,46 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
14
15
|
})
|
|
15
16
|
).toBe(false);
|
|
16
17
|
});
|
|
18
|
+
|
|
19
|
+
it('should PriorityQueue poll, pee, heapify, toArray work well', function () {
|
|
20
|
+
const minPQ = new PriorityQueue<number>({nodes: [5, 2, 3, 4, 6, 1], comparator: (a, b) => a - b});
|
|
21
|
+
expect(minPQ.toArray()).toEqual([1, 2, 3, 4, 6, 5]);
|
|
22
|
+
minPQ.poll();
|
|
23
|
+
minPQ.poll();
|
|
24
|
+
minPQ.poll();
|
|
25
|
+
expect(minPQ.toArray()).toEqual([4, 5, 6]);
|
|
26
|
+
expect(minPQ.peek()).toBe(4);
|
|
27
|
+
expect(
|
|
28
|
+
PriorityQueue.heapify({
|
|
29
|
+
nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10],
|
|
30
|
+
comparator: (a, b) => a - b
|
|
31
|
+
}).toArray()
|
|
32
|
+
).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () {
|
|
36
|
+
const maxPriorityQueue = new PriorityQueue<number>({nodes: [5, 2, 3, 4, 6, 1], comparator: (a, b) => b - a});
|
|
37
|
+
expect(maxPriorityQueue.toArray()).toEqual([6, 5, 3, 4, 2, 1]);
|
|
38
|
+
maxPriorityQueue.poll();
|
|
39
|
+
maxPriorityQueue.poll();
|
|
40
|
+
maxPriorityQueue.poll();
|
|
41
|
+
expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]);
|
|
42
|
+
expect(maxPriorityQueue.peek()).toBe(3);
|
|
43
|
+
expect(
|
|
44
|
+
PriorityQueue.heapify({
|
|
45
|
+
nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10],
|
|
46
|
+
comparator: (a, b) => a - b
|
|
47
|
+
}).toArray()
|
|
48
|
+
).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should PriorityQueue clone, sort, getNodes, DFS work well', function () {
|
|
52
|
+
const minPQ1 = new PriorityQueue<number>({nodes: [2, 5, 8, 3, 1, 6, 7, 4], comparator: (a, b) => a - b});
|
|
53
|
+
const clonedPriorityQueue = minPQ1.clone();
|
|
54
|
+
expect(clonedPriorityQueue.getNodes()).toEqual(minPQ1.getNodes());
|
|
55
|
+
expect(clonedPriorityQueue.sort()).toEqual([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
56
|
+
expect(minPQ1.DFS('in')).toEqual([4, 3, 2, 5, 1, 8, 6, 7]);
|
|
57
|
+
expect(minPQ1.DFS('post')).toEqual([4, 3, 5, 2, 8, 7, 6, 1]);
|
|
58
|
+
expect(minPQ1.DFS('pre')).toEqual([1, 2, 3, 4, 5, 6, 8, 7]);
|
|
59
|
+
});
|
|
17
60
|
});
|