(heap)
| 2250 | return first === undefined ? null : first; |
| 2251 | } |
| 2252 | function pop(heap) { |
| 2253 | var first = heap[0]; |
| 2254 | |
| 2255 | if (first !== undefined) { |
| 2256 | var last = heap.pop(); |
| 2257 | |
| 2258 | if (last !== first) { |
| 2259 | heap[0] = last; |
| 2260 | siftDown(heap, last, 0); |
| 2261 | } |
| 2262 | |
| 2263 | return first; |
| 2264 | } else { |
| 2265 | return null; |
| 2266 | } |
| 2267 | } |
| 2268 | |
| 2269 | function siftUp(heap, node, i) { |
| 2270 | var index = i; |
no test coverage detected