| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7fe1b5e commit eb6b386
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | Array, | |
| 5 | - ArrayPrototypeIndexOf, | ||
| 6 | 5 | Symbol, | |
| 7 | 6 | } = primordials; | |
| 8 | 7 | ||
@@ -105,17 +104,6 @@ module.exports = class PriorityQueue { | |||
| 105 | 104 | } | |
| 106 | 105 | } | |
| 107 | 106 | ||
| 108 | - remove(value) { | ||
| 109 | - const heap = this[kHeap]; | ||
| 110 | - const pos = ArrayPrototypeIndexOf(heap, value); | ||
| 111 | - if (pos < 1) | ||
| 112 | - return false; | ||
| 113 | - | ||
| 114 | - this.removeAt(pos); | ||
| 115 | - | ||
| 116 | - return true; | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | 107 | shift() { | |
| 120 | 108 | const heap = this[kHeap]; | |
| 121 | 109 | const value = heap[1]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,27 +43,6 @@ const PriorityQueue = require('internal/priority_queue'); | |||
| 43 | 43 | assert.strictEqual(queue.shift(), undefined); | |
| 44 | 44 | } | |
| 45 | 45 | ||
| 46 | - { | ||
| 47 | - // Checks that remove works as expected. | ||
| 48 | - const queue = new PriorityQueue(); | ||
| 49 | - for (let i = 16; i > 0; i--) | ||
| 50 | - queue.insert(i); | ||
| 51 | - | ||
| 52 | - const removed = [5, 10, 15]; | ||
| 53 | - for (const id of removed) | ||
| 54 | - assert(queue.remove(id)); | ||
| 55 | - | ||
| 56 | - assert(!queue.remove(100)); | ||
| 57 | - assert(!queue.remove(-100)); | ||
| 58 | - | ||
| 59 | - for (let i = 1; i < 17; i++) { | ||
| 60 | - if (removed.indexOf(i) < 0) | ||
| 61 | - assert.strictEqual(queue.shift(), i); | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - assert.strictEqual(queue.shift(), undefined); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | 46 | { | |
| 68 | 47 | // Make a max heap with a custom sort function. | |
| 69 | 48 | const queue = new PriorityQueue((a, b) => b - a); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments