This repository has been archived on 2026-02-22. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
libvieter/include/vieter_heap.h
Jef Roosens d11d074960
Some checks failed
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/test-mem Pipeline failed
chore: some reorganising
2023-01-22 12:35:55 +01:00

44 lines
895 B
C

#ifndef VIETER_HEAP
#define VIETER_HEAP
#include <stdint.h>
typedef struct vieter_heap vieter_heap;
typedef enum vieter_heap_error {
vieter_heap_ok = 0,
vieter_heap_empty = 1
} vieter_heap_error;
/*
* Allocate and initalize an empty heap.
*/
vieter_heap *vieter_heap_init();
/*
* Deallocate a heap.
*/
void vieter_heap_free(vieter_heap *heap);
/*
* Return how many elements are currently in the heap.
*/
uint64_t vieter_heap_size(vieter_heap *heap);
/*
* Insert a new value into the heap.
*/
vieter_heap_error vieter_heap_insert(vieter_heap *heap, uint64_t key,
void *data);
/*
* Remove the smallest element from the heap.
*/
vieter_heap_error vieter_heap_pop(void **out, vieter_heap *heap);
/*
* Get the smallest element in the heap without removing it.
*/
vieter_heap_error vieter_heap_peek(void **out, vieter_heap *heap);
#endif