33#ifndef CCC_PRIORITY_QUEUE_H
34#define CCC_PRIORITY_QUEUE_H
40#include "impl/impl_priority_queue.h"
80#define ccc_pq_init(struct_name, pq_elem_field, pq_order, cmp_fn, alloc_fn, \
82 ccc_impl_pq_init(struct_name, pq_elem_field, pq_order, cmp_fn, alloc_fn, \
112#define ccc_pq_emplace(priority_queue_ptr, lazy_value...) \
113 ccc_impl_pq_emplace(priority_queue_ptr, lazy_value)
180#define ccc_pq_update_w(pq_ptr, any_type_ptr, update_closure_over_T...) \
181 ccc_impl_pq_update_w(pq_ptr, any_type_ptr, update_closure_over_T)
233#define ccc_pq_increase_w(pq_ptr, any_type_ptr, increase_closure_over_T...) \
234 ccc_impl_pq_increase_w(pq_ptr, any_type_ptr, increase_closure_over_T)
284#define ccc_pq_decrease_w(pq_ptr, any_type_ptr, decrease_closure_over_T...) \
285 ccc_impl_pq_decrease_w(pq_ptr, any_type_ptr, decrease_closure_over_T)
343#ifdef PRIORITY_QUEUE_USING_NAMESPACE_CCC
346# define pq_init(args...) ccc_pq_init(args)
347# define pq_front(args...) ccc_pq_front(args)
348# define pq_push(args...) ccc_pq_push(args)
349# define pq_emplace(args...) ccc_pq_emplace(args)
350# define pq_pop(args...) ccc_pq_pop(args)
351# define pq_extract(args...) ccc_pq_extract(args)
352# define pq_is_empty(args...) ccc_pq_is_empty(args)
353# define pq_size(args...) ccc_pq_size(args)
354# define pq_update(args...) ccc_pq_update(args)
355# define pq_increase(args...) ccc_pq_increase(args)
356# define pq_decrease(args...) ccc_pq_decrease(args)
357# define pq_update_w(args...) ccc_pq_update_w(args)
358# define pq_increase_w(args...) ccc_pq_increase_w(args)
359# define pq_decrease_w(args...) ccc_pq_decrease_w(args)
360# define pq_order(args...) ccc_pq_order(args)
361# define pq_clear(args...) ccc_pq_clear(args)
362# define pq_validate(args...) ccc_pq_validate(args)
void * ccc_pq_update(ccc_priority_queue *pq, ccc_pq_elem *elem, ccc_any_type_update_fn *fn, void *aux)
Update the priority in the user type wrapping elem.
void * ccc_pq_decrease(ccc_priority_queue *pq, ccc_pq_elem *elem, ccc_any_type_update_fn *fn, void *aux)
Decreases the value of the type wrapping elem. O(1) or O(lgN)
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)
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:53
ccc_result ccc_pq_clear(ccc_priority_queue *pq, ccc_any_type_destructor_fn *fn)
Removes all elements from the pq, freeing if needed.
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).
ccc_ucount ccc_pq_size(ccc_priority_queue const *pq)
Returns the size of the priority queue.
ccc_tribool ccc_pq_validate(ccc_priority_queue const *pq)
Verifies the internal invariants of the pq hold.
void * ccc_pq_increase(ccc_priority_queue *pq, ccc_pq_elem *elem, ccc_any_type_update_fn *fn, void *aux)
Increases the priority of the type wrapping elem. O(1) or O(lgN)
ccc_tribool ccc_pq_is_empty(ccc_priority_queue const *pq)
Returns true if the priority queue is empty false if not. O(1).
ccc_threeway_cmp ccc_pq_order(ccc_priority_queue const *pq)
Return the order used to initialize the pq.
struct ccc_pq_elem ccc_pq_elem
The embedded struct type for operation of the priority queue.
Definition: priority_queue.h:63
ccc_result ccc_pq_pop(ccc_priority_queue *pq)
Pops the front element from the priority queue. Amortized O(lgN).
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:187
The C Container Collection Fundamental Types.
ccc_result
A result of actions on containers.
Definition: types.h:132
ccc_tribool
A three state boolean to allow for an error state. Error is -1, False is 0, and True is 1.
Definition: types.h:117
void ccc_any_type_destructor_fn(ccc_any_type)
A callback function for destroying an element in the container.
Definition: types.h:347
void ccc_any_type_update_fn(ccc_any_type)
A callback function for modifying an element in the container.
Definition: types.h:329
ccc_threeway_cmp
A three-way comparison for comparison functions.
Definition: types.h:153