* @return {*}
()
| 115 | * @return {*} |
| 116 | */ |
| 117 | poll() { |
| 118 | if (this.heapContainer.length === 0) { |
| 119 | return null; |
| 120 | } |
| 121 | |
| 122 | if (this.heapContainer.length === 1) { |
| 123 | return this.heapContainer.pop(); |
| 124 | } |
| 125 | |
| 126 | const item = this.heapContainer[0]; |
| 127 | |
| 128 | // Move the last element from the end to the head. |
| 129 | this.heapContainer[0] = this.heapContainer.pop(); |
| 130 | this.heapifyDown(); |
| 131 | |
| 132 | return item; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * @param {*} item |
no test coverage detected