.TH "hash.h" 3 "Sat Oct 12 2013" "Version 4.0.0a" "Coin" \" -*- nroff -*- .ad l .nh .SH NAME hash.h \- .SH SYNOPSIS .br .PP \fC#include \fP .br \fC#include \fP .br .SS "Typedefs" .in +1c .ti -1c .RI "typedef uintptr_t \fBcc_hash_key\fP" .br .ti -1c .RI "typedef struct cc_hash \fBcc_hash\fP" .br .ti -1c .RI "typedef cc_hash_key \fBcc_hash_func\fP (const cc_hash_key key)" .br .ti -1c .RI "typedef void \fBcc_hash_apply_func\fP (cc_hash_key key, void *val, void *closure)" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "cc_hash * \fBcc_hash_construct\fP (unsigned int size, float loadfactor)" .br .ti -1c .RI "void \fBcc_hash_destruct\fP (cc_hash *ht)" .br .ti -1c .RI "void \fBcc_hash_clear\fP (cc_hash *ht)" .br .ti -1c .RI "SbBool \fBcc_hash_put\fP (cc_hash *ht, cc_hash_key key, void *val)" .br .ti -1c .RI "SbBool \fBcc_hash_get\fP (cc_hash *ht, cc_hash_key key, void **val)" .br .ti -1c .RI "SbBool \fBcc_hash_remove\fP (cc_hash *ht, cc_hash_key key)" .br .ti -1c .RI "void \fBcc_hash_apply\fP (cc_hash *ht, cc_hash_apply_func *func, void *closure)" .br .ti -1c .RI "unsigned int \fBcc_hash_get_num_elements\fP (cc_hash *ht)" .br .ti -1c .RI "void \fBcc_hash_set_hash_func\fP (cc_hash *ht, cc_hash_func *func)" .br .ti -1c .RI "void \fBcc_hash_print_stat\fP (cc_hash *ht)" .br .in -1c .SH "Detailed Description" .PP .SH "Function Documentation" .PP .SS "cc_hash* cc_hash_construct (unsigned intsize, floatloadfactor)" Construct a hash table\&. .PP \fIsize\fP 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\&. .PP \fIloadfactor\fP 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\&. .SS "void cc_hash_destruct (cc_hash *ht)" Destruct the hash table \fIht\fP\&. .SS "void cc_hash_clear (cc_hash *ht)" Clear/remove all elements in the hash table \fIht\fP\&. .SS "SbBool cc_hash_put (cc_hash *ht, cc_hash_keykey, void *val)" Insert a new element in the hash table \fIht\fP\&. \fIkey\fP is the key used to identify the element, while \fIval\fP is the element value\&. If \fIkey\fP is already used by another element, the element value will be overwritten, and \fIFALSE\fP is returned\&. Otherwise a new element is created and \fITRUE\fP is returned\&. .SS "SbBool cc_hash_get (cc_hash *ht, cc_hash_keykey, void **val)" Find the element with key value \fIkey\fP\&. If found, the value is written to \fIval\fP, and TRUE is returned\&. Otherwise FALSE is returned and \fIval\fP is not changed\&. .SS "SbBool cc_hash_remove (cc_hash *ht, cc_hash_keykey)" Attempt to remove the element with key value \fIkey\fP\&. Returns TRUE if found, FALSE otherwise\&. .SS "void cc_hash_apply (cc_hash *ht, cc_hash_apply_func *func, void *closure)" Call \fIfunc\fP for for each element in the hash table\&. .SS "unsigned int cc_hash_get_num_elements (cc_hash *ht)" Return the number of elements in the hash table\&. .SS "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\&. .SS "void cc_hash_print_stat (cc_hash *ht)" For debugging only\&. Prints information about hash with cc_debugerror\&. .SH "Author" .PP Generated automatically by Doxygen for Coin from the source code\&.