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 
21 
27 
34 void cr8r_heap_sift_up(cr8r_vec*, cr8r_vec_ft*, void *e, int ord);
35 
42 void cr8r_heap_sift_down(cr8r_vec*, cr8r_vec_ft*, void *e, int ord);
43 
49 bool cr8r_heap_push(cr8r_vec*, cr8r_vec_ft*, const void *e, int ord);
50 
56 bool cr8r_heap_pop(cr8r_vec*, cr8r_vec_ft*, void *o, int ord);
57 
void * cr8r_heap_top(cr8r_vec *, cr8r_vec_ft *)
Get the top (typically max) element of a heap.
bool cr8r_heap_pop(cr8r_vec *, cr8r_vec_ft *, void *o, int ord)
Remove the top (typically max) element from the heap (has no relevant ordering guarantee)
void cr8r_heap_ify(cr8r_vec *, cr8r_vec_ft *, int ord)
Turn a vector into a heap in place in linear time.
void cr8r_heap_sift_up(cr8r_vec *, cr8r_vec_ft *, void *e, int ord)
Move an element up the heap as necessary to restore the heap invariant.
bool cr8r_heap_push(cr8r_vec *, cr8r_vec_ft *, const void *e, int ord)
Add a new element to the heap.
void cr8r_heap_sift_down(cr8r_vec *, cr8r_vec_ft *, void *e, int ord)
Move an element down the 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