Skip to content

Instantly share code, notes, and snippets.

View teldridge11's full-sized avatar
💭
🦅

Tom Eldridge teldridge11

💭
🦅
View GitHub Profile
void dyHeapRemoveMin(DynamicArray* heap, compareFunction compare)
{
// FIXME: implement
int last = dySize(heap)-1;
assert (last != 0); /* make sure we have at least one element */
/* Copy the last element to the first position */
dyPut(heap, dyGet(heap, last), 0);
dyRemoveAt(heap, last); /* Remove last element.*/
adjustHeap(heap, last, 0, compare);/* Rebuild heap */
}