55#ifndef JUNO_DS_HEAP_API_H
56#define JUNO_DS_HEAP_API_H
231 ptHeap->ptHeapArray &&
232 ptHeap->ptHeapPointerApi &&
233 ptHeap->ptHeapPointerApi->Compare &&
234 ptHeap->ptHeapPointerApi->Swap &&
236 ptHeap->ptApi->Insert &&
237 ptHeap->ptApi->Heapify &&
Abstract fixed-capacity array interface for DS modules.
struct JUNO_DS_ARRAY_ROOT_TAG JUNO_DS_ARRAY_ROOT_T
Opaque array root carrying capacity and API pointer.
Definition array_api.h:58
static JUNO_STATUS_T JunoDs_ArrayVerify(const JUNO_DS_ARRAY_ROOT_T *ptArray)
Verify an array instance's capacity and API.
Definition array_api.h:117
JUNO_STATUS_T JunoDs_Heap_SiftDown(JUNO_DS_HEAP_ROOT_T *ptHeap, size_t iStart)
Sift down from a starting index to restore the heap property.
Definition juno_heap.c:166
JUNO_STATUS_T JunoDs_Heap_Init(JUNO_DS_HEAP_ROOT_T *ptHeap, const JUNO_DS_HEAP_POINTER_API_T *ptHeapPointerApi, JUNO_DS_ARRAY_ROOT_T *ptHeapArray, JUNO_FAILURE_HANDLER_T pfcnFailureHdlr, JUNO_USER_DATA_T *pvUserData)
Initialize a heap over a backing array and element pointer API.
Definition juno_heap.c:32
static JUNO_STATUS_T JunoDs_Heap_Verify(JUNO_DS_HEAP_ROOT_T *ptHeap)
Verify heap configuration and dependent APIs.
Definition heap_api.h:227
JUNO_STATUS_T JunoDs_Heap_Insert(JUNO_DS_HEAP_ROOT_T *ptHeap, JUNO_POINTER_T tValue)
Insert a new element into the heap.
Definition juno_heap.c:257
JUNO_STATUS_T JunoDs_Heap_Heapify(JUNO_DS_HEAP_ROOT_T *ptHeap)
Transform the underlying array into a heap.
Definition juno_heap.c:282
JUNO_STATUS_T JunoDs_Heap_Pop(JUNO_DS_HEAP_ROOT_T *ptHeap, JUNO_POINTER_T tReturn)
Pop the root element into tReturn.
Definition juno_heap.c:322
#define JUNO_ASSERT_EXISTS(ptr)
Returns JUNO_STATUS_NULLPTR_ERROR if the expression is falsy.
Definition macros.h:50
#define JUNO_MODULE_RESULT(NAME_T, OK_T)
Define a result type combining a status and a success payload.
Definition module.h:193
#define JUNO_MODULE_ROOT(API_T,...)
Implement a module root struct containing ptApi and failure fields.
Definition module.h:126
#define JUNO_MODULE_OPTION(NAME_T, SOME_T)
Define an option type combining a presence flag and a payload.
Definition module.h:236
void(* JUNO_FAILURE_HANDLER_T)(JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)
Failure handler callback signature.
Definition status.h:104
int32_t JUNO_STATUS_T
Canonical status type for LibJuno functions.
Definition status.h:49
void JUNO_USER_DATA_T
Opaque user data type for failure callbacks.
Definition status.h:96
struct JUNO_DS_HEAP_ROOT_TAG JUNO_DS_HEAP_ROOT_T
Heap root type holding state and API pointer.
Definition heap_api.h:70
JUNO_STATUS_T JunoDs_Heap_Update(JUNO_DS_HEAP_ROOT_T *ptHeap)
Bubble-up the last inserted element to restore the heap property.
Definition juno_heap.c:114
Common assertion and helper macros for LibJuno modules.
Module system and dependency injection primitives for LibJuno.
Pointer trait and helpers for memory operations.
struct JUNO_POINTER_TAG JUNO_POINTER_T
Definition pointer_api.h:49
Status codes and failure-handling helpers for LibJuno.
Heap API vtable.
Definition heap_api.h:128
JUNO_STATUS_T(* Heapify)(JUNO_DS_HEAP_ROOT_T *ptHeap)
Transform the underlying array into a heap in-place.
Definition heap_api.h:134
JUNO_STATUS_T(* Insert)(JUNO_DS_HEAP_ROOT_T *ptHeap, JUNO_POINTER_T tValue)
Insert a new element into the heap.
Definition heap_api.h:132
JUNO_STATUS_T(* Pop)(JUNO_DS_HEAP_ROOT_T *ptHeap, JUNO_POINTER_T tReturn)
Pop the root element (extreme) into tReturn.
Definition heap_api.h:136
Element-level operations required by the heap.
Definition heap_api.h:111
JUNO_STATUS_T(* Swap)(JUNO_DS_HEAP_ROOT_T *ptHeap, JUNO_POINTER_T tLeft, JUNO_POINTER_T tRight)
Swap two values in the underlying storage.
Definition heap_api.h:120
JUNO_DS_HEAP_COMPARE_RESULT_T(* Compare)(JUNO_DS_HEAP_ROOT_T *ptHeap, JUNO_POINTER_T tParent, JUNO_POINTER_T tChild)
Compare two values to determine ordering (heap property).
Definition heap_api.h:116