minmax_heap.h
Go to the documentation of this file.
1 #pragma once
2 
11 
12 #include <stddef.h>
13 #include <inttypes.h>
14 
15 #include <crater/vec.h>
16 
19 
25 
32 
41 
50 
55 bool cr8r_mmheap_push(cr8r_vec*, cr8r_vec_ft*, const void *e);
56 
62 
68 
76 bool cr8r_mmheap_pop_idx(cr8r_vec*, cr8r_vec_ft*, void *o, uint64_t i);
77 
85 bool cr8r_mmheap_pushpop_min(cr8r_vec*, cr8r_vec_ft*, const void *e, void *o);
86 
94 bool cr8r_mmheap_pushpop_max(cr8r_vec*, cr8r_vec_ft*, const void *e, void *o);
95 
bool cr8r_mmheap_pop_max(cr8r_vec *, cr8r_vec_ft *, void *o)
Remove the max element from the minmax heap.
void cr8r_mmheap_sift_down(cr8r_vec *, cr8r_vec_ft *, void *e)
Move an element down the minmax heap as necessary to restore the heap invariant.
bool cr8r_mmheap_pushpop_max(cr8r_vec *, cr8r_vec_ft *, const void *e, void *o)
Push an element and then pop the max element in one operation.
void cr8r_mmheap_ify(cr8r_vec *, cr8r_vec_ft *)
Turn a vector into a minmax heap in place in linear time.
void * cr8r_mmheap_peek_min(cr8r_vec *, cr8r_vec_ft *)
Get the min element of a minmax heap.
bool cr8r_mmheap_pop_min(cr8r_vec *, cr8r_vec_ft *, void *o)
Remove the min element from the minmax heap.
void * cr8r_mmheap_peek_max(cr8r_vec *, cr8r_vec_ft *)
Get the max element of a minmax heap.
bool cr8r_mmheap_pop_idx(cr8r_vec *, cr8r_vec_ft *, void *o, uint64_t i)
Remove element at index i from the minmax heap.
bool cr8r_mmheap_pushpop_min(cr8r_vec *, cr8r_vec_ft *, const void *e, void *o)
Push an element and then pop the min element in one operation.
bool cr8r_mmheap_push(cr8r_vec *, cr8r_vec_ft *, const void *e)
Add a new element to the minmax heap.
void cr8r_mmheap_sift_up(cr8r_vec *, cr8r_vec_ft *, void *e)
Move an element up the minmax heap as necessary to restore the heap invariant.
Function table for vector.
Definition: vec.h:40
A vector Take care if manipulating these fields directly, this should only be done if the functions i...
Definition: vec.h:23