CMR  1.3.0
Functions
heap.c File Reference
#include "heap.h"
#include <assert.h>
#include <limits.h>

Functions

CMR_ERROR CMRintheapInitStack (CMR *cmr, CMR_INTHEAP *heap, int memKeys)
 Initializes an empty heap using stack memory. More...
 
CMR_ERROR CMRintheapClearStack (CMR *cmr, CMR_INTHEAP *heap)
 Clears the given heap. More...
 
static void debugHeap (CMR_INTHEAP *heap)
 
CMR_ERROR CMRintheapInsert (CMR_INTHEAP *heap, int key, int value)
 Inserts a key value pair into the heap. More...
 
CMR_ERROR CMRintheapDecrease (CMR_INTHEAP *heap, int key, int newValue)
 Decreases the value of key to newValue. More...
 
CMR_ERROR CMRintheapDecreaseInsert (CMR_INTHEAP *heap, int key, int newValue)
 Decreases the value of key to newValue or inserts it. More...
 
int CMRintheapExtractMinimum (CMR_INTHEAP *heap)
 Extracts the minimum element and returns its key. More...
 

Function Documentation

◆ CMRintheapClearStack()

CMR_ERROR CMRintheapClearStack ( CMR cmr,
CMR_INTHEAP heap 
)

Clears the given heap.

Parameters
cmrCMR environment.
heapHeap pointer.

◆ CMRintheapDecrease()

CMR_ERROR CMRintheapDecrease ( CMR_INTHEAP heap,
int  key,
int  newValue 
)

Decreases the value of key to newValue.

Parameters
heapHeap pointer.
keyKey of element.
newValueNew value of element.

◆ CMRintheapDecreaseInsert()

CMR_ERROR CMRintheapDecreaseInsert ( CMR_INTHEAP heap,
int  key,
int  newValue 
)

Decreases the value of key to newValue or inserts it.

Parameters
heapHeap pointer.
keyKey of element.
newValueNew value of element.

◆ CMRintheapExtractMinimum()

int CMRintheapExtractMinimum ( CMR_INTHEAP heap)

Extracts the minimum element and returns its key.

Parameters
heapHeap pointer.

◆ CMRintheapInitStack()

CMR_ERROR CMRintheapInitStack ( CMR cmr,
CMR_INTHEAP heap,
int  memKeys 
)

Initializes an empty heap using stack memory.

Parameters
cmrCMR environment.
heapHeap pointer.
memKeysMaximum number of elements and bound on key entries.

◆ CMRintheapInsert()

CMR_ERROR CMRintheapInsert ( CMR_INTHEAP heap,
int  key,
int  value 
)

Inserts a key value pair into the heap.

Parameters
heapHeap pointer.
keyKey of new element.
valueValue of new element.

◆ debugHeap()

static void debugHeap ( CMR_INTHEAP heap)
inlinestatic