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.