Coin
4.0.3
Coin3D core library
|
The SbHeap class is a generic heap class. More...
#include <Inventor/SbHeap.h>
Public Member Functions | |
SbHeap (const SbHeapFuncs &SbHeapFuncs, const int initsize=1024) | |
~SbHeap () | |
int | add (void *obj) |
SbBool | buildHeap (SbBool(*progresscb)(float percentage, void *data)=NULL, void *data=NULL) |
void | emptyHeap (void) |
void * | extractMin () |
void * | getMin () |
void | newWeight (void *obj, int hpos=-1) |
void * | operator[] (const int idx) |
void | remove (const int pos) |
void | remove (void *obj) |
int | size (void) const |
SbBool | traverseHeap (SbBool(*func)(void *, void *), void *userdata) const |
The SbHeap class is a generic heap class.
FIXME: write doc
Note: SbHeap is an extension versus the Open Inventor API.
SbHeap::SbHeap | ( | const SbHeapFuncs & | hFuncs, |
const int | initsize = 1024 ) |
Constructor. hFuncs specifies the functions for modifying and returning information about the heap object, initsize specifies the initial number of allocated elements. This array will automatically grow when necessary, but if you know approximately how many elements the heap will contain, you should supply this to avoid some reallocs.
SbHeap::~SbHeap | ( | void | ) |
Destructor.
int SbHeap::add | ( | void * | obj | ) |
Adds an element to the heap. Returns the element's heap position.
SbBool SbHeap::buildHeap | ( | SbBool(*)(float percentage, void *data) | progresscb = NULL, |
void * | data = NULL ) |
Builds heap out of randomly ordered data-structure.
Returns and removes the first element in the heap, or NULL if heap is empty.
Fixes heap if necessary when the element at hpos has changed weight. If you know the element's heap position you can supply it in hpos.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int SbHeap::size | ( | void | ) | const |
Returns the number of elements in the heap.
Traverses each heap elements, and calls func for each element.