Skip to content

Commit ab8dee5

Browse files
committed
docs: add desc to .from method in readme
1 parent d8cf64a commit ab8dee5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ A performant priority queue implementation using a Heap data structure.
1414
* [import](#import)
1515
* [API](#api)
1616
* [constructor](#constructor)
17+
* [.from](#fromentries)
1718
* [.enqueue](#enqueue)
1819
* [.front](#front)
1920
* [.back](#back)
@@ -129,6 +130,30 @@ const biddersQueue = new MaxPriorityQueue<Bid>({
129130
});
130131
```
131132

133+
### from(entries)
134+
135+
Creates a priority queue from an array of element-priority pairs.
136+
137+
```js
138+
MaxPriorityQueue.from([
139+
['Alice', 19],
140+
['Bob', 18],
141+
['Charles', 20]
142+
])
143+
// { priority: 20, element: 'Charles' },
144+
// { priority: 19, element: 'Alice' },
145+
// { priority: 18, element: 'Bob' }
146+
147+
MinPriorityQueue.from([
148+
['Alice', 19],
149+
['Bob', 18],
150+
['Charles', 20]
151+
])
152+
// { priority: 18, element: 'Bob' },
153+
// { priority: 19, element: 'Alice' },
154+
// { priority: 20, element: 'Charles' },
155+
```
156+
132157
### .enqueue
133158
#### PriorityQueue - .enqueue(element)
134159
adds an element based on its comparison with other elements in the queue.

0 commit comments

Comments
 (0)