Priority queue implementation. More...
#include "priority_queue.h"#include "type_limits.h"#include "debug.h"#include <stdlib.h>#include <errno.h>#include <sys/types.h>
Go to the source code of this file.
Data Structures | |
| struct | element |
| An element in the priority queue. More... | |
Functions | |
| static int | upheap (priority_queue_t *pq, size_t n) |
| Restore the heap property by moving an element upwards. | |
| static int | downheap (priority_queue_t *pq, size_t n) |
| Restore the heap property by moving an element downwards. | |
| int | priority_queue_new (priority_queue_t **pq, size_t capacity) |
| Creates a new priority queue. | |
| int | priority_queue_free (priority_queue_t *pq) |
| Frees a priority queue. | |
| int | priority_queue_get_size (priority_queue_t *pq, size_t *size) |
| Gets the size of the priority queue. | |
| int | priority_queue_add (priority_queue_t *pq, void *data, int key, size_t *pos) |
| Adds an element to the priority queue. | |
| int | priority_queue_remove_max (priority_queue_t *pq, void **data) |
| Remove the element with the maximum priority from the priority queue. | |
| int | priority_queue_change_key (priority_queue_t *pq, size_t pos, int key) |
| Change the priority key of an element. | |
Priority queue implementation.
Definition in file priority_queue.c.
| static int downheap | ( | priority_queue_t * | pq, | |
| size_t | n | |||
| ) | [static] |
Restore the heap property by moving an element downwards.
| pq | the priority queue | |
| n | the index of the element to move downwards |
Definition at line 109 of file priority_queue.c.
References element::key.
Referenced by priority_queue_change_key(), and priority_queue_remove_max().

| static int upheap | ( | priority_queue_t * | pq, | |
| size_t | n | |||
| ) | [static] |
Restore the heap property by moving an element upwards.
| pq | the priority queue | |
| n | the index of the element to move upwards |
Definition at line 74 of file priority_queue.c.
References element::key.
Referenced by priority_queue_add(), and priority_queue_change_key().

1.6.1