diff options
Diffstat (limited to 'prio-queue.c')
-rw-r--r-- | prio-queue.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/prio-queue.c b/prio-queue.c index 126d096727..d3f488cb05 100644 --- a/prio-queue.c +++ b/prio-queue.c @@ -20,7 +20,7 @@ void prio_queue_reverse(struct prio_queue *queue) int i, j; if (queue->compare != NULL) - die("BUG: prio_queue_reverse() on non-LIFO queue"); + BUG("prio_queue_reverse() on non-LIFO queue"); for (i = 0; i < (j = (queue->nr - 1) - i); i++) swap(queue, i, j); } @@ -85,3 +85,12 @@ void *prio_queue_get(struct prio_queue *queue) } return result; } + +void *prio_queue_peek(struct prio_queue *queue) +{ + if (!queue->nr) + return NULL; + if (!queue->compare) + return queue->array[queue->nr - 1].data; + return queue->array[0].data; +} |