Skip to content

Commit

Permalink
lib: remove unused code
Browse files Browse the repository at this point in the history
PR-URL: #36632
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
mscdex authored and targos committed Jun 11, 2021
1 parent c90f1db commit c9861a3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
12 changes: 0 additions & 12 deletions lib/internal/priority_queue.js
Expand Up @@ -2,7 +2,6 @@

const {
Array,
ArrayPrototypeIndexOf,
Symbol,
} = primordials;

Expand Down Expand Up @@ -105,17 +104,6 @@ module.exports = class PriorityQueue {
}
}

remove(value) {
const heap = this[kHeap];
const pos = ArrayPrototypeIndexOf(heap, value);
if (pos < 1)
return false;

this.removeAt(pos);

return true;
}

shift() {
const heap = this[kHeap];
const value = heap[1];
Expand Down
21 changes: 0 additions & 21 deletions test/parallel/test-priority-queue.js
Expand Up @@ -43,27 +43,6 @@ const PriorityQueue = require('internal/priority_queue');
assert.strictEqual(queue.shift(), undefined);
}

{
// Checks that remove works as expected.
const queue = new PriorityQueue();
for (let i = 16; i > 0; i--)
queue.insert(i);

const removed = [5, 10, 15];
for (const id of removed)
assert(queue.remove(id));

assert(!queue.remove(100));
assert(!queue.remove(-100));

for (let i = 1; i < 17; i++) {
if (removed.indexOf(i) < 0)
assert.strictEqual(queue.shift(), i);
}

assert.strictEqual(queue.shift(), undefined);
}

{
// Make a max heap with a custom sort function.
const queue = new PriorityQueue((a, b) => b - a);
Expand Down

0 comments on commit c9861a3

Please sign in to comment.