Coin: SbHeap Class Reference

| Coin3D is Free Software, published under the BSD 3-clause license. | https://coin3d.github.io https://www.kongsberg.com/en/kogt/

SbHeap Class Reference
Base Classes

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 ()
void | emptyHeap (void)
int | size (void) const
int | add (void *obj)
void | remove (const int pos)
void | remove (void *obj)
void * | extractMin ()
void * | getMin ()
void * | operator[] (const int idx)
void | newWeight (void *obj, int hpos=-1)
SbBool | buildHeap (SbBool(*progresscb)(float percentage, void *data)=NULL, void *data=NULL)
SbBool | traverseHeap (SbBool(*func)(void *, void *), void *userdata) const

## Detailed Description

The SbHeap class is a generic heap class.

FIXME: write doc

Note: SbHeap is an extension versus the Open Inventor API.

## Constructor & Destructor Documentation

## ◆ SbHeap()

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::~SbHeap | ( | void |  | ) |

Destructor.

## Member Function Documentation

## ◆ emptyHeap()

void SbHeap::emptyHeap | ( | void |  | ) |

Removes all the elements from the heap.

## ◆ size()

int SbHeap::size | ( | void |  | ) | const

Returns the number of elements in the heap.

## ◆ add()

int SbHeap::add | ( | void * | obj | ) |

Adds an element to the heap. Returns the element's heap position.

## ◆ remove() [1/2]

void SbHeap::remove | ( | const int | idx | ) |

Removes an element from the heap.

## ◆ remove() [2/2]

void SbHeap::remove | ( | void * | obj | ) |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## ◆ extractMin()

void * SbHeap::extractMin | ( | void |  | ) |

Returns and removes the first element in the heap, or NULL if heap is empty.

## ◆ getMin()

void * SbHeap::getMin | ( | void |  | ) |

Returns the first element in the heap, or NULL if heap is empty.

## ◆ operator[]()

void * SbHeap::operator[] | ( | const int | idx | ) |

Returns the heap element at index idx in the heap.

## ◆ newWeight()

void SbHeap::newWeight | ( | void * | obj,
|  | int | hpos = -1 )

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.

## ◆ buildHeap()

SbBool SbHeap::buildHeap | ( | SbBool(* | progresscb )(float percentage, void *data) = NULL,
|  | void * | data = NULL )

Builds heap out of randomly ordered data-structure.

## ◆ traverseHeap()

SbBool SbHeap::traverseHeap | ( | SbBool(* | func )(void *, void *),
|  | void * | userdata ) const

Traverses each heap elements, and calls func for each element.

The documentation for this class was generated from the following files:

- SbHeap.h
- SbHeap.cpp