You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-12Lines changed: 26 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,20 @@ For more information, please check [wiki](https://en.wikipedia.org/wiki/Priority
10
10
11
11
During practising some challenges in `leetcode`. I found this [problem](https://leetcode.com/problems/last-stone-weight/) requires `priority queue`. So I decided to research some documentations online and try to implement by myself this lib. The result beats 97% in `leetcode`.
12
12
13
+
## Installation
14
+
15
+
_npm_
16
+
17
+
```bash
18
+
npm i p-queue-ts
19
+
```
20
+
21
+
_yarn_
22
+
23
+
```bash
24
+
yarn add p-queue-ts
25
+
```
26
+
13
27
## Usage
14
28
15
29
The `priority queue` lib uses max heap as a default way to build a queue.
@@ -37,12 +51,12 @@ const p = new PriorityQueue(function (a, b) {
37
51
returna.value<b.value;
38
52
});
39
53
40
-
p.push({ text: "a", value: 2 });
41
-
p.push({ text: "b", value: 7 });
42
-
p.push({ text: "c", value: 4 });
43
-
p.push({ text: "d", value: 1 });
44
-
p.push({ text: "e", value: 8 });
45
-
p.push({ text: "f", value: 1 });
54
+
p.push({ text: 'a', value: 2 });
55
+
p.push({ text: 'b', value: 7 });
56
+
p.push({ text: 'c', value: 4 });
57
+
p.push({ text: 'd', value: 1 });
58
+
p.push({ text: 'e', value: 8 });
59
+
p.push({ text: 'f', value: 1 });
46
60
47
61
/** The queue
48
62
[
@@ -83,12 +97,12 @@ const p = new PriorityQueue(function (a, b) {
0 commit comments