]> git.ipfire.org Git - thirdparty/git.git/commit - prio-queue.c
prio-queue: add 'peek' operation
authorDerrick Stolee <stolee@gmail.com>
Thu, 1 Nov 2018 13:46:17 +0000 (13:46 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Nov 2018 03:14:21 +0000 (12:14 +0900)
commitaca4240f6a32423df5f95de6a9354b524fe57ec5
tree06a2b1efc6f6d9d0a66088e13965238bfb36e86b
parent2d3b1c576c85b7f5db1f418907af00ab88e0c303
prio-queue: add 'peek' operation

When consuming a priority queue, it can be convenient to inspect
the next object that will be dequeued without actually dequeueing
it. Our existing library did not have such a 'peek' operation, so
add it as prio_queue_peek().

Add a reference-level comparison in t/helper/test-prio-queue.c
so this method is exercised by t0009-prio-queue.sh. Further, add
a test that checks the behavior when the compare function is NULL
(i.e. the queue becomes a stack).

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
prio-queue.c
prio-queue.h
t/helper/test-prio-queue.c
t/t0009-prio-queue.sh