Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
heap.h File Reference
#include <Inventor/C/basic.h>

Go to the source code of this file.

Typedefs

typedef int cc_heap_compare_cb(void *o1, void *o2)
 
typedef struct cc_heap cc_heap
 

Functions

cc_heapcc_heap_construct (unsigned int size, cc_heap_compare_cb *comparecb, SbBool support_remove)
 
void cc_heap_destruct (cc_heap *h)
 
void cc_heap_clear (cc_heap *h)
 
void cc_heap_add (cc_heap *h, void *o)
 
void * cc_heap_get_top (cc_heap *h)
 
void * cc_heap_extract_top (cc_heap *h)
 
int cc_heap_remove (cc_heap *h, void *o)
 
unsigned int cc_heap_elements (cc_heap *h)
 
SbBool cc_heap_empty (cc_heap *h)
 

Typedef Documentation

◆ cc_heap_compare_cb

int cc_heap_compare_cb

A type definition for heap compare callback function.

◆ cc_heap

struct cc_heap cc_heap

A type definition for the cc_heap structure

Function Documentation

◆ cc_heap_construct()

cc_heap* cc_heap_construct ( unsigned int  size,
cc_heap_compare_cb comparecb,
SbBool  support_remove 
)

Construct a heap. size is the initial array size.

comparecb should return a negative value if the first element is less than the second, zero if they are equal and a positive value if the first element is greater than the second.

support_remove specifies if the heap should support removal of elements (other than the top element) after they are added; this requires use of a hash table to be efficent, but as a slight runtime overhead will be incurred for the add and extract_top functions the support can be disabled if you don't need it.

◆ cc_heap_destruct()

void cc_heap_destruct ( cc_heap h)

Destruct the heap h.

◆ cc_heap_clear()

void cc_heap_clear ( cc_heap h)

Clear/remove all elements in the heap h.

◆ cc_heap_add()

void cc_heap_add ( cc_heap h,
void *  o 
)

Add the element o to the heap h.

◆ cc_heap_get_top()

void* cc_heap_get_top ( cc_heap h)

Returns the top element from the heap h. If the heap is empty, NULL is returned.

◆ cc_heap_extract_top()

void* cc_heap_extract_top ( cc_heap h)

Returns and removes the top element from the heap h. If the heap is empty, NULL is returned.

◆ cc_heap_remove()

int cc_heap_remove ( cc_heap h,
void *  o 
)

Remove o from the heap h; if present TRUE is returned, otherwise FALSE. Please note that the heap must have been created with support_remove.

◆ cc_heap_elements()

unsigned int cc_heap_elements ( cc_heap h)

Returns the number of elements in the heap h.

◆ cc_heap_empty()

SbBool cc_heap_empty ( cc_heap h)

Returns TRUE of the heap h is empty; otherwise FALSE.