![]() |
The ROme OpTimistic Simulator
3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
|
Heap datatype. More...
#include <datatypes/array.h>
Go to the source code of this file.
Macros | |
#define | binary_heap(type) dyn_array(type) |
#define | heap_items(self) array_items(self) |
#define | heap_count(self) array_count(self) |
#define | heap_init(self) array_init(self) |
Initializes an empty heap. More... | |
#define | heap_fini(self) array_fini(self) |
Finalizes an heap. More... | |
#define | heap_is_empty(self) array_is_empty(self) |
#define | heap_min(self) ((__typeof(*array_items(self)) const)(array_items(self)[0])) |
#define | heap_insert(self, cmp_f, elem) |
Inserts an element into the heap. More... | |
#define | heap_extract(self, cmp_f) |
Extracts an element from the heap. More... | |
Heap datatype.
A very simple binary heap implemented on top of our dynamic array
Definition in file heap.h.
#define heap_extract | ( | self, | |
cmp_f | |||
) |
Extracts an element from the heap.
self | the heap from where to extract the element |
cmp_f | a comparing function f(a, b) which returns true iff a < b |
For correct operation of the heap you need to always pass the same cmp_f both for insertion and extraction
#define heap_fini | ( | self | ) | array_fini(self) |
#define heap_init | ( | self | ) | array_init(self) |
#define heap_insert | ( | self, | |
cmp_f, | |||
elem | |||
) |
Inserts an element into the heap.
self | the heap target of the insertion |
cmp_f | a comparing function f(a, b) which returns true iff a < b |
elem | the element to insert |
For correct operation of the heap you need to always pass the same cmp_f, both for insertion and extraction