mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Update PriorityQueue.js
Changed the default priority to value of the item in the add() method.
This commit is contained in:
parent
76617fa83a
commit
587648a11e
@ -22,7 +22,7 @@ export default class PriorityQueue extends MinHeap {
|
|||||||
* @param {number} [priority] - items priority.
|
* @param {number} [priority] - items priority.
|
||||||
* @return {PriorityQueue}
|
* @return {PriorityQueue}
|
||||||
*/
|
*/
|
||||||
add(item, priority = 0) {
|
add(item, priority = item) {
|
||||||
this.priorities.set(item, priority);
|
this.priorities.set(item, priority);
|
||||||
super.add(item);
|
super.add(item);
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
Reference in New Issue
Block a user