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_DATA_SIGNALING (UINTPTR_MAX) |
Constant for signaling in the priority queue data member. | |
#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. | |
static void | priority_queue_init (priority_queue_t *priority_queue) |
Initialize a priority queue object. | |
priority_queue_node_t * | priority_queue_remove_head (priority_queue_t *root) |
remove the priority queue's head | |
void | priority_queue_add (priority_queue_t *root, priority_queue_node_t *new_obj) |
insert new_obj into root based on its priority | |
void | priority_queue_remove (priority_queue_t *root, priority_queue_node_t *node) |
remove node from root | |
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 | |
#define PRIORITY_QUEUE_DATA_SIGNALING (UINTPTR_MAX) |
Constant for signaling in the priority queue data member.
Definition at line 53 of file priority_queue.h.
#define PRIORITY_QUEUE_INIT { NULL } |
Static initializer for priority_queue_t.
Definition at line 74 of file priority_queue.h.
#define PRIORITY_QUEUE_NODE_INIT { NULL, 0, 0 } |
Static initializer for priority_queue_node_t.
Definition at line 48 of file priority_queue.h.
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 84 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 63 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 |