File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff 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)
134159adds an element based on its comparison with other elements in the queue.
You can’t perform that action at this time.
0 commit comments