16#ifndef CCC_FLAT_PRIORITY_QUEUE_H
17#define CCC_FLAT_PRIORITY_QUEUE_H
24#include "impl/impl_flat_priority_queue.h"
58#define ccc_fpq_init(mem_ptr, capacity, cmp_order, alloc_fn, cmp_fn, aux_data) \
59 ccc_impl_fpq_init(mem_ptr, capacity, cmp_order, alloc_fn, cmp_fn, aux_data)
75#define ccc_fpq_heapify_init(mem_ptr, capacity, size, cmp_order, alloc_fn, \
77 ccc_impl_fpq_heapify_init(mem_ptr, capacity, size, cmp_order, alloc_fn, \
157#define ccc_fpq_emplace(fpq, val_initializer...) \
158 ccc_impl_fpq_emplace(fpq, val_initializer)
175 size_t input_n,
size_t input_elem_size);
238#define ccc_fpq_update_w(fpq_ptr, T_ptr, update_closure_over_T...) \
239 ccc_impl_fpq_update_w(fpq_ptr, T_ptr, update_closure_over_T)
271#define ccc_fpq_increase_w(fpq_ptr, T_ptr, increase_closure_over_T...) \
272 ccc_impl_fpq_increase_w(fpq_ptr, T_ptr, increase_closure_over_T)
304#define ccc_fpq_decrease_w(fpq_ptr, T_ptr, decrease_closure_over_T...) \
305 ccc_impl_fpq_decrease_w(fpq_ptr, T_ptr, decrease_closure_over_T)
400#ifdef FLAT_PRIORITY_QUEUE_USING_NAMESPACE_CCC
402# define fpq_init(args...) ccc_fpq_init(args)
403# define fpq_heapify_init(args...) ccc_fpq_heapify_init(args)
404# define fpq_copy(args...) ccc_fpq_copy(args)
405# define fpq_heapify(args...) ccc_fpq_heapify(args)
406# define fpq_emplace(args...) ccc_fpq_emplace(args)
407# define fpq_realloc(args...) ccc_fpq_realloc(args)
408# define fpq_push(args...) ccc_fpq_push(args)
409# define fpq_front(args...) ccc_fpq_front(args)
410# define fpq_i(args...) ccc_fpq_i(args)
411# define fpq_pop(args...) ccc_fpq_pop(args)
412# define fpq_extract(args...) ccc_fpq_extract(args)
413# define fpq_update(args...) ccc_fpq_update(args)
414# define fpq_increase(args...) ccc_fpq_increase(args)
415# define fpq_decrease(args...) ccc_fpq_decrease(args)
416# define fpq_update_w(args...) ccc_fpq_update_w(args)
417# define fpq_increase_w(args...) ccc_fpq_increase_w(args)
418# define fpq_decrease_w(args...) ccc_fpq_decrease_w(args)
419# define fpq_clear(args...) ccc_fpq_clear(args)
420# define fpq_clear_and_free(args...) ccc_fpq_clear_and_free(args)
421# define fpq_is_empty(args...) ccc_fpq_is_empty(args)
422# define fpq_size(args...) ccc_fpq_size(args)
423# define fpq_data(args...) ccc_fpq_data(args)
424# define fpq_validate(args...) ccc_fpq_validate(args)
425# define fpq_order(args...) ccc_fpq_order(args)
void * ccc_fpq_data(ccc_flat_priority_queue const *fpq)
Return a pointer to the base of the backing array. O(1).
ccc_result ccc_fpq_copy(ccc_flat_priority_queue *dst, ccc_flat_priority_queue const *src, ccc_alloc_fn *fn)
Copy the fpq from src to newly initialized dst.
ccc_result ccc_fpq_clear(ccc_flat_priority_queue *fpq, ccc_destructor_fn *fn)
Clears the fpq calling fn on every element if provided. O(1)-O(N).
void * ccc_fpq_increase(ccc_flat_priority_queue *fpq, void *e, ccc_update_fn *fn, void *aux)
Increase e that is a handle to the stored fpq element. O(lgN).
ccc_threeway_cmp ccc_fpq_order(ccc_flat_priority_queue const *fpq)
Return the order used to initialize the fpq.
void * ccc_fpq_front(ccc_flat_priority_queue const *fpq)
Return a pointer to the front (min or max) element in the fpq. O(1).
ccc_result ccc_fpq_alloc(ccc_flat_priority_queue *fpq, size_t new_capacity, ccc_alloc_fn *fn)
Many allocate memory for the fpq.
size_t ccc_fpq_capacity(ccc_flat_priority_queue const *fpq)
Returns the capacity of the fpq.
size_t ccc_fpq_size(ccc_flat_priority_queue const *fpq)
Returns the size of the fpq.
bool ccc_fpq_validate(ccc_flat_priority_queue const *fpq)
Verifies the internal invariants of the fpq hold.
void * ccc_fpq_decrease(ccc_flat_priority_queue *fpq, void *e, ccc_update_fn *fn, void *aux)
Decrease e that is a handle to the stored fpq element. O(lgN).
void * ccc_fpq_update(ccc_flat_priority_queue *fpq, void *e, ccc_update_fn *fn, void *aux)
Update e that is a handle to the stored fpq element. O(lgN).
struct ccc_fpq_ ccc_flat_priority_queue
A container offering direct storage and sorting of user data by heap order.
Definition: flat_priority_queue.h:37
ccc_result ccc_fpq_heapify(ccc_flat_priority_queue *fpq, void *input_array, size_t input_n, size_t input_elem_size)
Copy input array into the fpq, organizing into heap. O(N).
bool ccc_fpq_is_empty(ccc_flat_priority_queue const *fpq)
Returns true if the fpq is empty false if not. O(1).
ccc_result ccc_fpq_pop(ccc_flat_priority_queue *fpq)
Pop the front element (min or max) element in the fpq. O(lgN).
ccc_result ccc_fpq_clear_and_free(ccc_flat_priority_queue *fpq, ccc_destructor_fn *fn)
Clears the fpq calling fn on every element if provided and frees the underlying buffer....
ptrdiff_t ccc_fpq_i(ccc_flat_priority_queue const *fpq, void const *e)
Return the index of an element known to be in the fpq. O(1).
void * ccc_fpq_push(ccc_flat_priority_queue *fpq, void const *e)
Pushes element pointed to at e into fpq. O(lgN).
ccc_result ccc_fpq_erase(ccc_flat_priority_queue *fpq, void *e)
Erase element e that is a handle to the stored fpq element.
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
void * ccc_alloc_fn(void *ptr, size_t size, void *aux)
An allocation function at the core of all containers.
Definition: types.h:199
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