---
name: "heap.h"
section: "3"
platform: "linux"
package: "libcoin80-doc"
version: "3.1.4~abc9f50-7"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/heap.h"
---

# 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)\

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