7 #ifndef PRIORITY_QUEUE_H
8 #define PRIORITY_QUEUE_H
235 #define PRIORITY_QUEUE_BASE_ITERATE( pq, idx, data, iter_count, iter_depth ) \
237 priority_queue_base_reset(pq); \
238 while ((iter_count < iter_depth) && ((idx = priority_queue_base_next(pq)) >= 0) && (data = priority_queue_peek_at(pq, idx)) && (iter_count += 1))
241 #define PRIORITY_QUEUE_STATIC_ITERATE( pq, idx, data, iter_count, iter_depth ) \
243 while ((iter_count < iter_depth) && ((idx = priority_queue_static_next(pq)) >= 0) && (data = priority_queue_peek_at(pq, idx)) && (iter_count += 1))
246 #define PRIORITY_QUEUE_ROTATE_ITERATE( pq, idx, data, iter_count, iter_depth ) \
248 while ((iter_count < iter_depth) && ((idx = priority_queue_rotate_next(pq)) >= 0) && (data = priority_queue_peek_at(pq, idx)) && (iter_count += 1))
int priority_queue_size(struct priority_queue *pq)
Count the elements in a priority queue.
double priority_queue_get_priority(struct priority_queue *pq, int index)
Get the priority of an element at a specified index.
void * priority_queue_peek_at(struct priority_queue *pq, int index)
Get an element from a priority queue by a specified index.
int priority_queue_push(struct priority_queue *pq, void *data, double priority)
Push an element into a priority queue.
int priority_queue_update_priority(struct priority_queue *pq, void *data, double new_priority)
Update the priority of an element in a priority queue.
int priority_queue_base_next(struct priority_queue *pq)
Advance the base_cursor to the next element and return the index.
int priority_queue_remove(struct priority_queue *pq, int idx)
Remove the element with the specified index from a priority queue.
int priority_queue_find_idx(struct priority_queue *pq, void *data)
Find the index of an element in a priority queue.
void * priority_queue_peek_top(struct priority_queue *pq)
Get the element with the highest priority from a priority queue.
int priority_queue_static_next(struct priority_queue *pq)
Advance the static_cursor to the next element and return the index.
void priority_queue_rotate_reset(struct priority_queue *pq)
Reset the rotate_cursor to 0.
void priority_queue_base_reset(struct priority_queue *pq)
Reset the base_cursor to 0.
void priority_queue_delete(struct priority_queue *pq)
Delete a priority queue.
int priority_queue_rotate_next(struct priority_queue *pq)
Advance the rotate_cursor to the next element and return the index.
struct priority_queue * priority_queue_create(int init_capacity)
Create a new priority queue.
void * priority_queue_pop(struct priority_queue *pq)
Pop the element with the highest priority from a priority queue.