Paul Hsieh's SuperFastHash implemented as inline functions for 32-bit input datatypes. More...
Functions | |
static void | hsieh_hash32_init (uint32 *hashp, uint32 nvalues) |
Initialise the hash value for Paul Hsieh's super fast hash function. More... | |
static void | hsieh_hash32_step (uint32 *hashp, uint32 value) |
Perform one step in Paul Hsieh's super fast hash function, using a 32-bit input value. More... | |
static void | hsieh_hash32_finish (uint32 *hashp) |
Finish the hashing for Paul Hsieh's super fast hash function. More... | |
Paul Hsieh's SuperFastHash implemented as inline functions for 32-bit input datatypes.
This header file should ONLY be included by C files that use this hash function. Header files should not include this, if the hash function is not used by a source file that includes it, there will be warnings about unused static functions.
|
inlinestatic |
Finish the hashing for Paul Hsieh's super fast hash function.
[in,out] | hashp | A pointer to the hash value to finalise. This should have been initialised by calling hsieh_hash32_init(), and values should have been merged by calling hsieh_hash32_step(). |
The returned hash value is 32 bits and if a smaller range is required it is up to the caller to do either a mod, for general hash table sizes, or a mask to size of the hash table minus one, for hash table sizes that are a power of two.
eg.
For general hash sizes (slower). or
For power of two hash sizes.
It is recommended to make your hash table size a power of two.
Initialise the hash value for Paul Hsieh's super fast hash function.
[out] | hashp | A pointer to the hash value to initialise. |
[in] | nvalues | The number of 32-bit values that will be used to create the hash key. |
To create a hash value, this function is called first, followed by nvalues iterations of hsieh_hash32_step(), and then finally hsieh_hash32_finish(). All of these functions are inlined in the caller.
Perform one step in Paul Hsieh's super fast hash function, using a 32-bit input value.
[in,out] | hashp | A pointer to the hash value to combine the value with. This should have been initialised by calling hsieh_hash32_init(). |
[in] | value | A 32-bit value to merge into the hash value. |