Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
min_heap_ref.h File Reference

Header-file for the reference (handle-based) min-heap data structure. More...

#include <zephyr/sys/util.h>

Go to the source code of this file.

Data Structures

struct  min_heap_handle
 Embeddable heap position handle. More...
struct  min_heap_ref
 min-heap data structure with user-provided comparator. More...

Macros

#define MIN_HEAP_REF_DEFINE(name, cap, cmp_func)
 Define a min-heap instance.
#define MIN_HEAP_REF_DEFINE_STATIC(name, cap, cmp_func)
 Define a statically allocated min-heap instance.
#define MIN_HEAP_REF_FOREACH(__heap, __handle)
 Iterate over every element currently in the min-heap.
#define MIN_HEAP_REF_FOREACH_CONTAINER(__heap, __cn, __field)
 Iterate over every element in the min-heap yielding the embedding container struct.

Typedefs

typedef int(* min_heap_ref_cmp_t) (const struct min_heap_handle *a, const struct min_heap_handle *b)
 Comparator function type for min-heap ordering.

Functions

static void min_heap_ref_init (struct min_heap_ref *heap, struct min_heap_handle **storage, size_t capacity, min_heap_ref_cmp_t cmp)
 Initialize a min-heap instance at runtime.
static void min_heap_ref_swap (struct min_heap_ref *heap, size_t a, size_t b)
 Swap two elements in the heap storage, updating their idx fields.
static void min_heap_ref_heapify_up (struct min_heap_ref *heap, size_t index)
 Restore heap order by moving a node up the tree.
static void min_heap_ref_heapify_down (struct min_heap_ref *heap, size_t index)
 Restore heap order by moving a node down the tree.
static int min_heap_ref_push (struct min_heap_ref *heap, struct min_heap_handle *handle)
 Push a handle into the min-heap.
static const struct min_heap_handlemin_heap_ref_peek (const struct min_heap_ref *heap)
 Peek at the top element of the min-heap.
static bool min_heap_ref_remove (struct min_heap_ref *heap, struct min_heap_handle *handle)
 Remove a specific element from the min-heap by handle.
static bool min_heap_ref_is_empty (struct min_heap_ref *heap)
 Check if the min heap is empty.
static struct min_heap_handlemin_heap_ref_pop (struct min_heap_ref *heap)
 Remove and return the highest priority element's handle.

Detailed Description

Header-file for the reference (handle-based) min-heap data structure.