| 77 | } |
| 78 | |
| 79 | void *prio_queue_get(struct prio_queue *queue) |
| 80 | { |
| 81 | void *result; |
| 82 | |
| 83 | if (!queue->nr) |
| 84 | return NULL; |
| 85 | if (!queue->compare) |
| 86 | return queue->array[--queue->nr].data; /* LIFO */ |
| 87 | |
| 88 | result = queue->array[0].data; |
| 89 | if (!--queue->nr) |
| 90 | return result; |
| 91 | |
| 92 | queue->array[0] = queue->array[queue->nr]; |
| 93 | sift_down_root(queue); |
| 94 | return result; |
| 95 | } |
| 96 | |
| 97 | void *prio_queue_peek(struct prio_queue *queue) |
| 98 | { |