remove the item with the top priority return top item
| 226 | // remove the item with the top priority |
| 227 | // return top item |
| 228 | void *Heap_poll |
| 229 | ( |
| 230 | heap_t *hp |
| 231 | ) { |
| 232 | if(0 == Heap_count(hp)) { |
| 233 | return NULL; |
| 234 | } |
| 235 | |
| 236 | void *item = hp->array[0]; |
| 237 | |
| 238 | hp->array[0] = hp->array[hp->count - 1]; |
| 239 | hp->count--; |
| 240 | |
| 241 | if(hp->count > 1) { |
| 242 | __pushdown(hp, 0); |
| 243 | } |
| 244 | |
| 245 | return item; |
| 246 | } |
| 247 | |
| 248 | // return top item of the heap |
| 249 | void *Heap_peek |