| 104 | } |
| 105 | |
| 106 | void prio_queue_replace(struct prio_queue *queue, void *thing) |
| 107 | { |
| 108 | if (!queue->nr) { |
| 109 | prio_queue_put(queue, thing); |
| 110 | } else if (!queue->compare) { |
| 111 | queue->array[queue->nr - 1].ctr = queue->insertion_ctr++; |
| 112 | queue->array[queue->nr - 1].data = thing; |
| 113 | } else { |
| 114 | queue->array[0].ctr = queue->insertion_ctr++; |
| 115 | queue->array[0].data = thing; |
| 116 | sift_down_root(queue); |
| 117 | } |
| 118 | } |