| 59 | } |
| 60 | |
| 61 | static void sift_down_root(struct prio_queue *queue) |
| 62 | { |
| 63 | size_t ix, child; |
| 64 | |
| 65 | /* Push down the one at the root */ |
| 66 | for (ix = 0; ix * 2 + 1 < queue->nr; ix = child) { |
| 67 | child = ix * 2 + 1; /* left */ |
| 68 | if (child + 1 < queue->nr && |
| 69 | compare(queue, child, child + 1) >= 0) |
| 70 | child++; /* use right child */ |
| 71 | |
| 72 | if (compare(queue, ix, child) <= 0) |
| 73 | break; |
| 74 | |
| 75 | swap(queue, child, ix); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | void *prio_queue_get(struct prio_queue *queue) |
| 80 | { |
no test coverage detected