Scroll to navigation

heap.h(3) Coin heap.h(3)

NAME

heap.h -

SYNOPSIS

#include <Inventor/C/basic.h>
 
 

Typedefs


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

Functions


cc_heap * cc_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)
 

Detailed Description

 

Function Documentation

cc_heap* cc_heap_construct (unsigned intsize, cc_heap_compare_cb *comparecb, SbBoolsupport_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.

void cc_heap_destruct (cc_heap *h)

Destruct the heap h.

void cc_heap_clear (cc_heap *h)

Clear/remove all elements in the heap h.

void cc_heap_add (cc_heap *h, void *o)

Add the element o to the heap h.

void* cc_heap_get_top (cc_heap *h)

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

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.

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.

unsigned int cc_heap_elements (cc_heap *h)

Returns the number of elements in the heap h.

SbBool cc_heap_empty (cc_heap *h)

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

Author

Generated automatically by Doxygen for Coin from the source code.
Sat Oct 12 2013 Version 4.0.0a