Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
min_heap.h File Reference
#include <zephyr/sys/util.h>
#include <zephyr/kernel.h>

Go to the source code of this file.

Data Structures

struct  min_heap
 min-heap data structure with user-provided comparator. More...
 

Macros

#define MIN_HEAP_DEFINE(name, storage, cap, size, cmp_func)
 Define and initialize a heap instance at runtime.
 
#define MIN_HEAP_DEFINE_STATIC(name, cap, elem_sz, align, cmp_func)
 Define a statically allocated and aligned min-heap instance.
 
#define MIN_HEAP_FOREACH(heap, node_var, body)
 Iterate over each node in the heap.
 

Typedefs

typedef int(* min_heap_cmp_t) (const void *a, const void *b)
 Comparator function type for min-heap ordering.
 
typedef bool(* min_heap_eq_t) (const void *node, const void *other)
 Equality function for finding a node in the heap.
 

Functions

void min_heap_init (struct min_heap *heap, void *storage, size_t cap, size_t elem_size, min_heap_cmp_t cmp)
 Initialize a min-heap instance at runtime.
 
int min_heap_push (struct min_heap *heap, const void *item)
 Push an element into the min-heap.
 
void * min_heap_peek (const struct min_heap *heap)
 Peek at the top element of the min-heap.
 
bool min_heap_remove (struct min_heap *heap, size_t id, void *out_buf)
 Remove a specific element from the min-heap.
 
static bool min_heap_is_empty (struct min_heap *heap)
 Check if the min heap is empty.
 
bool min_heap_pop (struct min_heap *heap, void *out_buf)
 Remove and return the highest priority element in the heap.
 
void * min_heap_find (struct min_heap *heap, min_heap_eq_t eq, const void *other, size_t *out_id)
 Search for a node in the heap matching a condition.
 
static void * min_heap_get_element (const struct min_heap *heap, size_t index)
 Get a pointer to the element at the specified index.