31#ifndef CCC_FLAT_PRIORITY_QUEUE_H
32#define CCC_FLAT_PRIORITY_QUEUE_H
38#include "impl/impl_flat_priority_queue.h"
72#define ccc_fpq_init(mem_ptr, cmp_order, cmp_fn, alloc_fn, aux_data, capacity) \
73 ccc_impl_fpq_init(mem_ptr, cmp_order, cmp_fn, alloc_fn, aux_data, capacity)
89#define ccc_fpq_heapify_init(mem_ptr, cmp_order, cmp_fn, alloc_fn, aux_data, \
91 ccc_impl_fpq_heapify_init(mem_ptr, cmp_order, cmp_fn, alloc_fn, aux_data, \
192#define ccc_fpq_emplace(fpq, val_initializer...) \
193 ccc_impl_fpq_emplace(fpq, val_initializer)
210 size_t input_n,
size_t input_sizeof_type);
283#define ccc_fpq_update_w(fpq_ptr, any_type_ptr, update_closure_over_T...) \
284 ccc_impl_fpq_update_w(fpq_ptr, any_type_ptr, update_closure_over_T)
315#define ccc_fpq_increase_w(fpq_ptr, any_type_ptr, increase_closure_over_T...) \
316 ccc_impl_fpq_increase_w(fpq_ptr, any_type_ptr, increase_closure_over_T)
347#define ccc_fpq_decrease_w(fpq_ptr, any_type_ptr, decrease_closure_over_T...) \
348 ccc_impl_fpq_decrease_w(fpq_ptr, any_type_ptr, decrease_closure_over_T)
467#ifdef FLAT_PRIORITY_QUEUE_USING_NAMESPACE_CCC
469# define fpq_init(args...) ccc_fpq_init(args)
470# define fpq_heapify_init(args...) ccc_fpq_heapify_init(args)
471# define fpq_copy(args...) ccc_fpq_copy(args)
472# define fpq_reserve(args...) ccc_fpq_reserve(args)
473# define fpq_heapify(args...) ccc_fpq_heapify(args)
474# define fpq_emplace(args...) ccc_fpq_emplace(args)
475# define fpq_realloc(args...) ccc_fpq_realloc(args)
476# define fpq_push(args...) ccc_fpq_push(args)
477# define fpq_front(args...) ccc_fpq_front(args)
478# define fpq_i(args...) ccc_fpq_i(args)
479# define fpq_pop(args...) ccc_fpq_pop(args)
480# define fpq_extract(args...) ccc_fpq_extract(args)
481# define fpq_update(args...) ccc_fpq_update(args)
482# define fpq_increase(args...) ccc_fpq_increase(args)
483# define fpq_decrease(args...) ccc_fpq_decrease(args)
484# define fpq_update_w(args...) ccc_fpq_update_w(args)
485# define fpq_increase_w(args...) ccc_fpq_increase_w(args)
486# define fpq_decrease_w(args...) ccc_fpq_decrease_w(args)
487# define fpq_clear(args...) ccc_fpq_clear(args)
488# define fpq_clear_and_free(args...) ccc_fpq_clear_and_free(args)
489# define fpq_clear_and_free_reserve(args...) \
490 ccc_fpq_clear_and_free_reserve(args)
491# define fpq_is_empty(args...) ccc_fpq_is_empty(args)
492# define fpq_size(args...) ccc_fpq_size(args)
493# define fpq_data(args...) ccc_fpq_data(args)
494# define fpq_validate(args...) ccc_fpq_validate(args)
495# 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_tribool 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_heapify_inplace(ccc_flat_priority_queue *fpq, size_t n)
Order n elements of the underlying fpq buffer as an fpq.
ccc_result ccc_fpq_heapify(ccc_flat_priority_queue *fpq, void *input_array, size_t input_n, size_t input_sizeof_type)
Copy input array into the fpq, organizing into heap. O(N).
ccc_threeway_cmp ccc_fpq_order(ccc_flat_priority_queue const *fpq)
Return the order used to initialize the fpq.
ccc_ucount ccc_fpq_size(ccc_flat_priority_queue const *fpq)
Returns the size of the fpq representing active slots.
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).
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:51
ccc_result ccc_fpq_clear_and_free(ccc_flat_priority_queue *fpq, ccc_any_type_destructor_fn *fn)
Clears the fpq calling fn on every element if provided and frees the underlying buffer....
ccc_result ccc_fpq_clear(ccc_flat_priority_queue *fpq, ccc_any_type_destructor_fn *fn)
Clears the fpq calling fn on every element if provided. O(1)-O(N).
void * ccc_fpq_update(ccc_flat_priority_queue *fpq, void *e, ccc_any_type_update_fn *fn, void *aux)
Update e that is a handle to the stored fpq element. O(lgN).
ccc_result ccc_fpq_pop(ccc_flat_priority_queue *fpq)
Pop the front element (min or max) element in the fpq. O(lgN).
void * ccc_fpq_decrease(ccc_flat_priority_queue *fpq, void *e, ccc_any_type_update_fn *fn, void *aux)
Decrease e that is a handle to the stored fpq element. O(lgN).
ccc_result ccc_fpq_reserve(ccc_flat_priority_queue *fpq, size_t to_add, ccc_any_alloc_fn *fn)
Reserves space for at least to_add more elements.
ccc_tribool ccc_fpq_validate(ccc_flat_priority_queue const *fpq)
Verifies the internal invariants of the fpq hold.
ccc_result ccc_fpq_clear_and_free_reserve(ccc_flat_priority_queue *fpq, ccc_any_type_destructor_fn *destructor, ccc_any_alloc_fn *alloc)
Frees all slots in the fpq and frees the underlying buffer that was previously dynamically reserved w...
ccc_result ccc_fpq_copy(ccc_flat_priority_queue *dst, ccc_flat_priority_queue const *src, ccc_any_alloc_fn *fn)
Copy the fpq from src to newly initialized dst.
ccc_result ccc_fpq_alloc(ccc_flat_priority_queue *fpq, size_t new_capacity, ccc_any_alloc_fn *fn)
Many allocate memory for the fpq.
ccc_ucount ccc_fpq_capacity(ccc_flat_priority_queue const *fpq)
Returns the capacity of the fpq representing total possible slots.
void * ccc_fpq_push(ccc_flat_priority_queue *fpq, void const *e)
Pushes element pointed to at e into fpq. O(lgN).
void * ccc_fpq_increase(ccc_flat_priority_queue *fpq, void *e, ccc_any_type_update_fn *fn, void *aux)
Increase e that is a handle to the stored fpq element. 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.
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.
void * ccc_any_alloc_fn(void *ptr, size_t size, void *aux)
An allocation function at the core of all containers.
Definition: types.h:312
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