---
name: "hash.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/hash.h"
---

# hash.h(3)

## NAME

hash.h -

## SYNOPSIS

`#include <stdlib.h>`\
 `#include <Inventor/C/basic.h>`\

### Typedefs

typedef uintptr\_t **cc\_hash\_key**\
 typedef struct cc\_hash **cc\_hash**\
 typedef cc\_hash\_key **cc\_hash\_func** (const cc\_hash\_key key)\
 typedef void **cc\_hash\_apply\_func** (cc\_hash\_key key, void \*val, void \*closure)\

### Functions

cc\_hash \* **cc\_hash\_construct** (unsigned int size, float loadfactor)\
 void **cc\_hash\_destruct** (cc\_hash \*ht)\
 void **cc\_hash\_clear** (cc\_hash \*ht)\
 SbBool **cc\_hash\_put** (cc\_hash \*ht, cc\_hash\_key key, void \*val)\
 SbBool **cc\_hash\_get** (cc\_hash \*ht, cc\_hash\_key key, void \*\*val)\
 SbBool **cc\_hash\_remove** (cc\_hash \*ht, cc\_hash\_key key)\
 void **cc\_hash\_apply** (cc\_hash \*ht, cc\_hash\_apply\_func \*func, void \*closure)\
 unsigned int **cc\_hash\_get\_num\_elements** (cc\_hash \*ht)\
 void **cc\_hash\_set\_hash\_func** (cc\_hash \*ht, cc\_hash\_func \*func)\
 void **cc\_hash\_print\_stat** (cc\_hash \*ht)\

## Function Documentation

### cc\_hash\* cc\_hash\_construct (unsigned intsize, floatloadfactor)

Construct a hash table.

*size* is the initial bucket size. The caller need not attempt to find a good (prime number) value for this argument to ensure good hashing. That will be taken care of internally.

*loadfactor* is the percentage the table should be filled before resizing, and should be a number from 0 to 1. It is of course possible to specify a number bigger than 1, but then there will be greater chance of having many elements on the same bucket (linear search for an element). If you supply a number \<= 0 for loadfactor, the default value 0.75 will be used.

### void cc\_hash\_destruct (cc\_hash \*ht)

Destruct the hash table *ht*.

### void cc\_hash\_clear (cc\_hash \*ht)

Clear/remove all elements in the hash table *ht*.

### SbBool cc\_hash\_put (cc\_hash \*ht, cc\_hash\_keykey, void \*val)

Insert a new element in the hash table *ht*. *key* is the key used to identify the element, while *val* is the element value. If *key* is already used by another element, the element value will be overwritten, and *FALSE* is returned. Otherwise a new element is created and *TRUE* is returned.

### SbBool cc\_hash\_get (cc\_hash \*ht, cc\_hash\_keykey, void \*\*val)

Find the element with key value *key*. If found, the value is written to *val*, and TRUE is returned. Otherwise FALSE is returned and *val* is not changed.

### SbBool cc\_hash\_remove (cc\_hash \*ht, cc\_hash\_keykey)

Attempt to remove the element with key value *key*. Returns TRUE if found, FALSE otherwise.

### void cc\_hash\_apply (cc\_hash \*ht, cc\_hash\_apply\_func \*func, void \*closure)

Call *func* for for each element in the hash table.

### unsigned int cc\_hash\_get\_num\_elements (cc\_hash \*ht)

Return the number of elements in the hash table.

### void cc\_hash\_set\_hash\_func (cc\_hash \*ht, cc\_hash\_func \*func)

Set the hash func that is used to map key values into a bucket index.

### void cc\_hash\_print\_stat (cc\_hash \*ht)

For debugging only. Prints information about hash with cc\_debugerror.

## Author

Generated automatically by Doxygen for Coin from the source code.
