summaryrefslogtreecommitdiff
path: root/lib/pqueue.c
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2017-04-19 07:04:04 -0400
committerGitHub <noreply@github.com>2017-04-19 07:04:04 -0400
commitae731843400043a6a6540cc60c99bf5f9ab63ba7 (patch)
tree45d474a6afcfbfaedf561d1897f30501d82ed7a1 /lib/pqueue.c
parentde72643d15dff0225e7d05b130dd34db9e7c08fb (diff)
parent6cbc63316b75e72a04e57ffca146e81ee89d645c (diff)
Merge pull request #374 from qlyoung/pqueue-linear-remove
lib: add removal by item to pqueue
Diffstat (limited to 'lib/pqueue.c')
-rw-r--r--lib/pqueue.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/pqueue.c b/lib/pqueue.c
index 0f870564da..fa502b462a 100644
--- a/lib/pqueue.c
+++ b/lib/pqueue.c
@@ -188,3 +188,11 @@ pqueue_remove_at (int index, struct pqueue *queue)
trickle_down (index, queue);
}
}
+
+void
+pqueue_remove (void *data, struct pqueue *queue)
+{
+ for (int i = 0; i < queue->size; i++)
+ if (queue->array[i] == data)
+ pqueue_remove_at (i, queue);
+}