From 587648a11e8753832bd41da07874875ca996a10c Mon Sep 17 00:00:00 2001 From: PradeepG-07 <143615010+PradeepG-07@users.noreply.github.com> Date: Fri, 15 Sep 2023 19:44:26 +0530 Subject: [PATCH] Update PriorityQueue.js Changed the default priority to value of the item in the add() method. --- src/data-structures/priority-queue/PriorityQueue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data-structures/priority-queue/PriorityQueue.js b/src/data-structures/priority-queue/PriorityQueue.js index 0b283c2c..94bda233 100644 --- a/src/data-structures/priority-queue/PriorityQueue.js +++ b/src/data-structures/priority-queue/PriorityQueue.js @@ -22,7 +22,7 @@ export default class PriorityQueue extends MinHeap { * @param {number} [priority] - items priority. * @return {PriorityQueue} */ - add(item, priority = 0) { + add(item, priority = item) { this.priorities.set(item, priority); super.add(item); return this;