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 nodejs-github-bot committed Dec 29, 2020
1 parent b00bb01 commit 34afcc6
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 34afcc6

Please sign in to comment.