Compare commits

...

2 Commits

Author SHA1 Message Date
PradeepG-07
49f15c4532
Merge 587648a11e into 2c67b48c21 2024-03-09 16:08:15 -07:00
PradeepG-07
587648a11e
Update PriorityQueue.js
Changed the default priority to value of the item in the add() method.
2023-09-15 19:44:26 +05:30

View File

@ -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;