()
| 110 | // deletes the highest priority value from the heap. The last |
| 111 | // element goes to ahead to first position and reorder heap |
| 112 | delete() { |
| 113 | // checks empty and one element array conditions |
| 114 | if (this.isEmpty()) return |
| 115 | if (this.size === 1) { |
| 116 | this.size-- |
| 117 | return this.heap.pop() |
| 118 | } |
| 119 | const min = this.heap[1] |
| 120 | this.heap[1] = this.heap.pop() |
| 121 | this.size-- |
| 122 | this.sink() |
| 123 | return min |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | export { MinPriorityQueue } |
no test coverage detected