CMR  1.3.0
Classes | Functions
heap.h File Reference
#include <cmr/env.h>
#include "env_internal.h"
#include <limits.h>

Go to the source code of this file.

Classes

struct  CMR_INTHEAP
 Structure for min-heap with unsigned int values. More...
 

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...
 
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...
 
static bool CMRintheapEmpty (CMR_INTHEAP *heap)
 Returns true if the heap is empty. More...
 
static int CMRintheapMinimumKey (CMR_INTHEAP *heap)
 Returns the key of the minimum element. More...
 
static int CMRintheapMinimumValue (CMR_INTHEAP *heap)
 Returns the value of the minimum element. More...
 
static bool CMRintheapContains (CMR_INTHEAP *heap, int key)
 Returns true if an element with key is present in the heap. More...
 
static int CMRintheapGetValue (CMR_INTHEAP *heap, int key)
 
static int CMRintheapGetValueInfinity (CMR_INTHEAP *heap, int key)
 Reutrns the value of key or INT_MAX if there is no such element. 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.

◆ CMRintheapContains()

static bool CMRintheapContains ( CMR_INTHEAP heap,
int  key 
)
inlinestatic

Returns true if an element with key is present in the heap.

Parameters
heapHeap pointer.
keyKey whose existence shall be checked.

◆ 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.

◆ CMRintheapEmpty()

static bool CMRintheapEmpty ( CMR_INTHEAP heap)
inlinestatic

Returns true if the heap is empty.

Parameters
heapHeap pointer.

◆ CMRintheapExtractMinimum()

int CMRintheapExtractMinimum ( CMR_INTHEAP heap)

Extracts the minimum element and returns its key.

Parameters
heapHeap pointer.

◆ CMRintheapGetValue()

static int CMRintheapGetValue ( CMR_INTHEAP heap,
int  key 
)
inlinestatic

◆ CMRintheapGetValueInfinity()

static int CMRintheapGetValueInfinity ( CMR_INTHEAP heap,
int  key 
)
inlinestatic

Reutrns the value of key or INT_MAX if there is no such element.

Parameters
heapHeap pointer.
keyKey to be searched.

◆ 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.

◆ CMRintheapMinimumKey()

static int CMRintheapMinimumKey ( CMR_INTHEAP heap)
inlinestatic

Returns the key of the minimum element.

Parameters
heapHeap pointer.

◆ CMRintheapMinimumValue()

static int CMRintheapMinimumValue ( CMR_INTHEAP heap)
inlinestatic

Returns the value of the minimum element.

Parameters
heapHeap.