59#ifndef CCC_FLAT_PRIORITY_QUEUE_H
60#define CCC_FLAT_PRIORITY_QUEUE_H
67#include "impl/impl_flat_priority_queue.h"
98#define ccc_fpq_init(mem_ptr, any_type_name, cmp_order, cmp_fn, alloc_fn, \
100 ccc_impl_fpq_init(mem_ptr, any_type_name, cmp_order, cmp_fn, alloc_fn, \
114#define ccc_fpq_heapify_init(mem_ptr, any_type_name, cmp_order, cmp_fn, \
115 alloc_fn, aux_data, capacity, size) \
116 ccc_impl_fpq_heapify_init(mem_ptr, any_type_name, cmp_order, cmp_fn, \
117 alloc_fn, aux_data, capacity, size)
217#define ccc_fpq_emplace(fpq, val_initializer...) \
218 ccc_impl_fpq_emplace(fpq, val_initializer)
239 void *input_array,
size_t input_n,
240 size_t input_sizeof_type);
335#define ccc_fpq_update_w(fpq_ptr, any_type_ptr, update_closure_over_T...) \
336 ccc_impl_fpq_update_w(fpq_ptr, any_type_ptr, update_closure_over_T)
371#define ccc_fpq_increase_w(fpq_ptr, any_type_ptr, increase_closure_over_T...) \
372 ccc_impl_fpq_increase_w(fpq_ptr, any_type_ptr, increase_closure_over_T)
407#define ccc_fpq_decrease_w(fpq_ptr, any_type_ptr, decrease_closure_over_T...) \
408 ccc_impl_fpq_decrease_w(fpq_ptr, any_type_ptr, decrease_closure_over_T)
556#ifdef FLAT_PRIORITY_QUEUE_USING_NAMESPACE_CCC
558# define fpq_init(args...) ccc_fpq_init(args)
559# define fpq_heapify_init(args...) ccc_fpq_heapify_init(args)
560# define fpq_copy(args...) ccc_fpq_copy(args)
561# define fpq_reserve(args...) ccc_fpq_reserve(args)
562# define fpq_heapify(args...) ccc_fpq_heapify(args)
563# define fpq_heapify_inplace(args...) ccc_fpq_heapify_inplace(args)
564# define fpq_heapsort(args...) ccc_fpq_heapsort(args)
565# define fpq_emplace(args...) ccc_fpq_emplace(args)
566# define fpq_realloc(args...) ccc_fpq_realloc(args)
567# define fpq_push(args...) ccc_fpq_push(args)
568# define fpq_front(args...) ccc_fpq_front(args)
569# define fpq_i(args...) ccc_fpq_i(args)
570# define fpq_pop(args...) ccc_fpq_pop(args)
571# define fpq_extract(args...) ccc_fpq_extract(args)
572# define fpq_update(args...) ccc_fpq_update(args)
573# define fpq_increase(args...) ccc_fpq_increase(args)
574# define fpq_decrease(args...) ccc_fpq_decrease(args)
575# define fpq_update_w(args...) ccc_fpq_update_w(args)
576# define fpq_increase_w(args...) ccc_fpq_increase_w(args)
577# define fpq_decrease_w(args...) ccc_fpq_decrease_w(args)
578# define fpq_clear(args...) ccc_fpq_clear(args)
579# define fpq_clear_and_free(args...) ccc_fpq_clear_and_free(args)
580# define fpq_clear_and_free_reserve(args...) \
581 ccc_fpq_clear_and_free_reserve(args)
582# define fpq_is_empty(args...) ccc_fpq_is_empty(args)
583# define fpq_count(args...) ccc_fpq_count(args)
584# define fpq_data(args...) ccc_fpq_data(args)
585# define fpq_validate(args...) ccc_fpq_validate(args)
586# define fpq_order(args...) ccc_fpq_order(args)
struct ccc_buffer ccc_buffer
A contiguous block of storage for elements of the same type.
Definition: buffer.h:74
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_heapify(ccc_flat_priority_queue *fpq, void *tmp, void *input_array, size_t input_n, size_t input_sizeof_type)
Copy input array into the fpq, organizing into heap. O(N).
ccc_tribool ccc_fpq_is_empty(ccc_flat_priority_queue const *fpq)
Returns true if the fpq is empty false if not. O(1).
void * ccc_fpq_update(ccc_flat_priority_queue *fpq, void *elem, void *tmp, 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_heapify_inplace(ccc_flat_priority_queue *fpq, void *tmp, size_t n)
Order n elements of the underlying fpq buffer as an fpq.
void * ccc_fpq_increase(ccc_flat_priority_queue *fpq, void *elem, void *tmp, ccc_any_type_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.
ccc_buffer ccc_fpq_heapsort(ccc_flat_priority_queue *fpq, void *tmp)
Destroys the fpq by sorting its data and returning the underlying buffer. The data is sorted in O(N *...
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:80
ccc_result ccc_fpq_pop(ccc_flat_priority_queue *fpq, void *tmp)
Pop the front element (min or max) element in the fpq. O(lgN).
void * ccc_fpq_push(ccc_flat_priority_queue *fpq, void const *elem, void *tmp)
Pushes element pointed to at e into fpq. O(lgN).
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_decrease(ccc_flat_priority_queue *fpq, void *elem, void *tmp, 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_result ccc_fpq_erase(ccc_flat_priority_queue *fpq, void *elem, void *tmp)
Erase element e that is a handle to the stored fpq element.
ccc_ucount ccc_fpq_count(ccc_flat_priority_queue const *fpq)
Returns the count of the fpq active slots.
ccc_ucount ccc_fpq_capacity(ccc_flat_priority_queue const *fpq)
Returns the capacity of the fpq representing total possible slots.
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