18#ifndef CCC_PRIORITY_QUEUE_H
19#define CCC_PRIORITY_QUEUE_H
26#include "impl/impl_priority_queue.h"
66#define ccc_pq_init(struct_name, pq_elem_field, pq_order, alloc_fn, cmp_fn, \
68 ccc_impl_pq_init(struct_name, pq_elem_field, pq_order, alloc_fn, cmp_fn, \
98#define ccc_pq_emplace(priority_queue_ptr, lazy_value...) \
99 ccc_impl_pq_emplace(priority_queue_ptr, lazy_value)
166#define ccc_pq_update_w(pq_ptr, pq_elem_ptr, update_closure_over_T...) \
167 ccc_impl_pq_update_w(pq_ptr, pq_elem_ptr, update_closure_over_T)
220#define ccc_pq_increase_w(pq_ptr, pq_elem_ptr, increase_closure_over_T...) \
221 ccc_impl_pq_increase_w(pq_ptr, pq_elem_ptr, increase_closure_over_T)
271#define ccc_pq_decrease_w(pq_ptr, pq_elem_ptr, decrease_closure_over_T...) \
272 ccc_impl_pq_decrease_w(pq_ptr, pq_elem_ptr, decrease_closure_over_T)
330#ifdef PRIORITY_QUEUE_USING_NAMESPACE_CCC
333# define pq_init(args...) ccc_pq_init(args)
334# define pq_front(args...) ccc_pq_front(args)
335# define pq_push(args...) ccc_pq_push(args)
336# define pq_emplace(args...) ccc_pq_emplace(args)
337# define pq_pop(args...) ccc_pq_pop(args)
338# define pq_extract(args...) ccc_pq_extract(args)
339# define pq_is_empty(args...) ccc_pq_is_empty(args)
340# define pq_size(args...) ccc_pq_size(args)
341# define pq_update(args...) ccc_pq_update(args)
342# define pq_increase(args...) ccc_pq_increase(args)
343# define pq_decrease(args...) ccc_pq_decrease(args)
344# define pq_update_w(args...) ccc_pq_update_w(args)
345# define pq_increase_w(args...) ccc_pq_increase_w(args)
346# define pq_decrease_w(args...) ccc_pq_decrease_w(args)
347# define pq_order(args...) ccc_pq_order(args)
348# define pq_clear(args...) ccc_pq_clear(args)
349# define pq_validate(args...) ccc_pq_validate(args)
void * ccc_pq_push(ccc_priority_queue *pq, ccc_pq_elem *elem)
Adds an element to the priority queue in correct total order. O(1).
void * ccc_pq_extract(ccc_priority_queue *pq, ccc_pq_elem *elem)
bool ccc_pq_update(ccc_priority_queue *pq, ccc_pq_elem *elem, ccc_update_fn *fn, void *aux)
Update the priority in the user type wrapping elem.
bool ccc_pq_decrease(ccc_priority_queue *pq, ccc_pq_elem *elem, ccc_update_fn *fn, void *aux)
Decreases the value of the type wrapping elem. O(1) or O(lgN)
struct ccc_pq_elem_ ccc_pq_elem
The embedded struct type for operation of the priority queue.
Definition: priority_queue.h:49
bool ccc_pq_is_empty(ccc_priority_queue const *pq)
Returns true if the priority queue is empty false if not. O(1).
ccc_result ccc_pq_erase(ccc_priority_queue *pq, ccc_pq_elem *elem)
Erase elem from the pq. Amortized O(lgN).
void * ccc_pq_front(ccc_priority_queue const *pq)
Obtain a reference to the front of the priority queue. O(1).
bool ccc_pq_validate(ccc_priority_queue const *pq)
Verifies the internal invariants of the pq hold.
size_t ccc_pq_size(ccc_priority_queue const *pq)
Returns the size of the priority queue.
ccc_result ccc_pq_clear(ccc_priority_queue *pq, ccc_destructor_fn *fn)
Removes all elements from the pq, freeing if needed.
ccc_threeway_cmp ccc_pq_order(ccc_priority_queue const *pq)
Return the order used to initialize the pq.
bool ccc_pq_increase(ccc_priority_queue *pq, ccc_pq_elem *elem, ccc_update_fn *fn, void *aux)
Increases the priority of the type wrapping elem. O(1) or O(lgN)
struct ccc_pq_ ccc_priority_queue
A container for pointer stability and an O(1) push and amortized o(lg N) increase/decrease key.
Definition: priority_queue.h:39
ccc_result ccc_pq_pop(ccc_priority_queue *pq)
Pops the front element from the priority queue. Amortized O(lgN).
The C Container Collection Fundamental Types.
ccc_result
A result of actions on containers.
Definition: types.h:65
void ccc_update_fn(ccc_user_type)
A callback function for modifying an element in the container.
Definition: types.h:216
ccc_threeway_cmp
A three-way comparison for comparison functions.
Definition: types.h:84
void ccc_destructor_fn(ccc_user_type)
A callback function for destroying an element in the container.
Definition: types.h:234