priority_queue.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013, 2014 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef PRIORITY_QUEUE_H
20 #define PRIORITY_QUEUE_H
21 
22 #include <stddef.h>
23 #include <stdint.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
32 typedef struct priority_queue_node {
34  uint32_t priority;
35  unsigned int data;
37 
41 typedef struct {
44 
48 #define PRIORITY_QUEUE_NODE_INIT { NULL, 0, 0 }
49 
58 static inline void priority_queue_node_init(
60 {
62 
63  *priority_queue_node = qn;
64 }
65 
69 #define PRIORITY_QUEUE_INIT { NULL }
70 
79 static inline void priority_queue_init(priority_queue_t *priority_queue)
80 {
82 
83  *priority_queue = q;
84 }
85 
94 
107 
115 
116 #if ENABLE_DEBUG
117 
123 
130 #endif
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 
137 #endif /* PRIORITY_QUEUE_H */
priority_queue_node::data
unsigned int data
queue node data
Definition: priority_queue.h:35
priority_queue_print_node
void priority_queue_print_node(priority_queue_t *root)
print the data, priority, and successor of a given node
priority_queue_remove_head
priority_queue_node_t * priority_queue_remove_head(priority_queue_t *root)
remove the priority queue's head
priority_queue_node::priority
uint32_t priority
queue node priority
Definition: priority_queue.h:34
priority_queue_node::next
struct priority_queue_node * next
next queue node
Definition: priority_queue.h:33
priority_queue_init
static void priority_queue_init(priority_queue_t *priority_queue)
Initialize a priority queue object.
Definition: priority_queue.h:79
priority_queue_t::first
priority_queue_node_t * first
first queue node
Definition: priority_queue.h:42
priority_queue_print
void priority_queue_print(priority_queue_t *root)
print the data and priority of every node in the given priority queue
PRIORITY_QUEUE_NODE_INIT
#define PRIORITY_QUEUE_NODE_INIT
Static initializer for priority_queue_node_t.
Definition: priority_queue.h:48
priority_queue_remove
void priority_queue_remove(priority_queue_t *root, priority_queue_node_t *node)
remove node from root
priority_queue_node
data type for priority queue nodes
Definition: priority_queue.h:32
priority_queue_node_t
struct priority_queue_node priority_queue_node_t
data type for priority queue nodes
priority_queue_add
void priority_queue_add(priority_queue_t *root, priority_queue_node_t *new_obj)
insert new_obj into root based on its priority
priority_queue_node_init
static void priority_queue_node_init(priority_queue_node_t *priority_queue_node)
Initialize a priority queue node object.
Definition: priority_queue.h:58
PRIORITY_QUEUE_INIT
#define PRIORITY_QUEUE_INIT
Static initializer for priority_queue_t.
Definition: priority_queue.h:69
priority_queue_t
data type for priority queues
Definition: priority_queue.h:41