strHash

fun strHash(v: <Error class: unknown class>): <Error class: unknown class>

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.

Note that this function may not be a perfect fit for all use cases. For example, it produces some hash collisions with strings as short as 2.

Return

a hash value corresponding to the key

Parameters

v

a string key