HashTable.strHash

Converts a string to a hash value.

This function implements the widely used "djb" hash apparently posted by Daniel Bernstein to comp.lang.c some time ago. The 32 bit unsigned hash value starts at 5381 and for each byte 'c' in the string, is updated: hash = hash * 33 + c. This function uses the signed value of each byte.

It can be passed to g_hash_table_new() as the @hash_func parameter, when using non-%NULL strings as keys in a #GHashTable.

class HashTable
static
uint
strHash
(
void* v
)

Parameters

v void*

a string key

Return: a hash value corresponding to the key

Meta