Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: remove unused code #36632

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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