Merge branch 'en/merge-path-collision'
[gitweb.git] / prio-queue.c
index 126d09672738533b6ecc6b94b7405dff888bbaf6..d3f488cb05f29bc90e4e03810d9bf4b972d0834f 100644 (file)
@@ -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;
+}