core.ds.maxh¶
Max-heap: extracts the element with the highest priority value first.
Overview¶
core.ds.maxh is a thin typed wrapper over core.ds.bheap that creates a max-heap. In a max-heap, maxh_ExtractMax always yields the element whose Priority value is the largest among all inserted elements. This is suitable for applications such as scheduling where the most urgent (highest-valued) item should be processed first.
All heap mechanics (index-array indirection, free-slot recycling, automatic growth) are handled by the underlying core.ds.bheap engine.
Dependencies¶
core.ds.types—TBinaryHeap,PBinaryHeapcore.ds.bheap— heap engineio.syslog— test output (implementation only)core.strings— test output formatting (implementation only)memory.heap—kfree(implementation only)
Functions and Procedures¶
maxh_New¶
Creates a new max-heap.ElementSize is the size in bytes of each data element. InitialCapacity is the starting number of slots (grows automatically).
maxh_Insert¶
Inserts an element with the given priority. Higher priority values are extracted first.maxh_ExtractMax¶
Removes and copies the element with the highest priority intoData. Returns false if the heap is empty.
maxh_PeekMax¶
Returns a direct pointer to the highest-priority element's data without removing it. Returnsnil if the heap is empty.
maxh_Size¶
Returns the number of elements in the heap.maxh_IsEmpty¶
Returnstrue if the heap contains no elements.
maxh_Free¶
Frees the heap and all its internal buffers.UnitTest¶
Runs the max-heap test suite (inserts 5 elements out of order, verifies extraction in descending order) and logs a pass/fail summary to syslog under the'MAXH' channel.