Harlequin RIP SDK

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...
 

Detailed Description

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.

Function Documentation

◆ hsieh_hash32_finish()

static void hsieh_hash32_finish ( uint32 hashp)
inlinestatic

Finish the hashing for Paul Hsieh's super fast hash function.

Parameters
[in,out]hashpA 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.

hash % size

For general hash sizes (slower). or

hash & (size - 1)

For power of two hash sizes.

It is recommended to make your hash table size a power of two.

◆ hsieh_hash32_init()

static void hsieh_hash32_init ( uint32 hashp,
uint32  nvalues 
)
inlinestatic

Initialise the hash value for Paul Hsieh's super fast hash function.

Parameters
[out]hashpA pointer to the hash value to initialise.
[in]nvaluesThe 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.

◆ hsieh_hash32_step()

static void hsieh_hash32_step ( uint32 hashp,
uint32  value 
)
inlinestatic

Perform one step in Paul Hsieh's super fast hash function, using a 32-bit input value.

Parameters
[in,out]hashpA pointer to the hash value to combine the value with. This should have been initialised by calling hsieh_hash32_init().
[in]valueA 32-bit value to merge into the hash value.