diff options
author | Christian Franke <chris@opensourcerouting.org> | 2013-11-19 15:11:42 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2014-04-22 21:17:00 +0200 |
commit | 4becea724ccd87e88f8454622ae227308b5fa3ce (patch) | |
tree | a1e07f06ae43698a72a15ee801de86ce3d9ffdf4 /lib/pqueue.c | |
parent | lib: remove unused thread_master_debug function (diff) | |
download | frr-4becea724ccd87e88f8454622ae227308b5fa3ce.tar.xz frr-4becea724ccd87e88f8454622ae227308b5fa3ce.zip |
lib: use heap to manage timers
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/pqueue.c')
-rw-r--r-- | lib/pqueue.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/pqueue.c b/lib/pqueue.c index 12a779f2a..69ab8e65d 100644 --- a/lib/pqueue.c +++ b/lib/pqueue.c @@ -168,3 +168,20 @@ pqueue_dequeue (struct pqueue *queue) trickle_down (0, queue); return data; } + +void +pqueue_remove_at (int index, struct pqueue *queue) +{ + queue->array[index] = queue->array[--queue->size]; + + if (index > 0 + && (*queue->cmp) (queue->array[index], + queue->array[PARENT_OF(index)]) < 0) + { + trickle_up (index, queue); + } + else + { + trickle_down (index, queue); + } +} |