A simple priority queue. More...
A simple priority queue.
Definition in file priority_queue.h.
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | priority_queue_node |
data type for priority queue nodes More... | |
struct | priority_queue_t |
data type for priority queues More... | |
#define | PRIORITY_QUEUE_NODE_INIT { NULL, 0, 0 } |
Static initializer for priority_queue_node_t. | |
#define | PRIORITY_QUEUE_INIT { NULL } |
Static initializer for priority_queue_t. | |
typedef struct priority_queue_node | priority_queue_node_t |
data type for priority queue nodes | |
static void | priority_queue_node_init (priority_queue_node_t *priority_queue_node) |
Initialize a priority queue node object. More... | |
static void | priority_queue_init (priority_queue_t *priority_queue) |
Initialize a priority queue object. More... | |
priority_queue_node_t * | priority_queue_remove_head (priority_queue_t *root) |
remove the priority queue's head More... | |
void | priority_queue_add (priority_queue_t *root, priority_queue_node_t *new_obj) |
insert new_obj into root based on its priority More... | |
void | priority_queue_remove (priority_queue_t *root, priority_queue_node_t *node) |
remove node from root More... | |
void | priority_queue_print (priority_queue_t *root) |
print the data and priority of every node in the given priority queue More... | |
void | priority_queue_print_node (priority_queue_t *root) |
print the data, priority, and successor of a given node More... | |
void priority_queue_add | ( | priority_queue_t * | root, |
priority_queue_node_t * | new_obj | ||
) |
insert new_obj
into root
based on its priority
The new object will be appended after objects with the same priority.
[in,out] | root | the queue's root |
[in] | new_obj | the object to prepend |
new_obj
.
|
inlinestatic |
Initialize a priority queue object.
For initialization of variables use PRIORITY_QUEUE_INIT instead. Only use this function for dynamically allocated priority queues.
[out] | priority_queue | pre-allocated priority_queue_t object, must not be NULL. |
Definition at line 79 of file priority_queue.h.
|
inlinestatic |
Initialize a priority queue node object.
For initialization of variables use PRIORITY_QUEUE_NODE_INIT instead. Only use this function for dynamically allocated priority queue nodes.
[out] | priority_queue_node | pre-allocated priority_queue_node_t object, must not be NULL. |
Definition at line 58 of file priority_queue.h.
void priority_queue_print | ( | priority_queue_t * | root | ) |
print the data and priority of every node in the given priority queue
void priority_queue_print_node | ( | priority_queue_t * | root | ) |
print the data, priority, and successor of a given node
void priority_queue_remove | ( | priority_queue_t * | root, |
priority_queue_node_t * | node | ||
) |
remove node
from root
[in,out] | root | the priority queue's root |
[in] | node | the node to remove |
priority_queue_node_t* priority_queue_remove_head | ( | priority_queue_t * | root | ) |
remove the priority queue's head
[out] | root | the queue's root |