hashkit_set_distribution_function3
Libhashkit documentation
Usage
- #include <libhashkit-1.0/hashkit.h>
-
Compile and link with -lhashkit
- typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length, void *context)
-
- Param key
-
the key to generate a hash of
- Param key_length
-
the length of the
keywithout any terminating zero byte
- Param context
-
the custom hash function context set through
hashkit_set_custom_function()orhashkit_set_custom_distribution_function()
Returns-
the custom hash function should return a hash value for
keyas an unsigned 32bit integer
- typedef enum hashkit_return_t hashkit_return_t
- enum hashkit_return_t
-
- enumerator HASHKIT_SUCCESS
-
Operation succeeded.
- enumerator HASHKIT_FAILURE
-
Operation failed.
- enumerator HASHKIT_MEMORY_ALLOCATION_FAILURE
-
Memory allocation failed.
- enumerator HASHKIT_INVALID_HASH
-
Invalid
hashkit_hash_algorithm_tpassed.
- enumerator HASHKIT_INVALID_ARGUMENT
-
Invalid argument passed.
- typedef enum hashkit_hash_algorithm_t hashkit_hash_algorithm_t
- enum hashkit_hash_algorithm_t
-
- enumerator HASHKIT_HASH_DEFAULT
-
Default hash algorithm (one_at_a_time).
- enumerator HASHKIT_HASH_MD5
- enumerator HASHKIT_HASH_CRC
- enumerator HASHKIT_HASH_FNV1_64
- enumerator HASHKIT_HASH_FNV1A_64
- enumerator HASHKIT_HASH_FNV1_32
- enumerator HASHKIT_HASH_FNV1A_32
- enumerator HASHKIT_HASH_HSIEH
-
Only available if
libhashkithash been built with HSIEH support.
- enumerator HASHKIT_HASH_MURMUR
-
Only available if
libhashkithas been built with MURMUR support.
- enumerator HASHKIT_HASH_MURMUR3
-
Only available if
libhashkithas been built with MURMUR support.
- enumerator HASHKIT_HASH_JENKINS
- enumerator HASHKIT_HASH_CUSTOM
-
Use custom
hashkit_hash_fnfunction set throughhashkit_set_custom_function()orhashkit_set_custom_distribution_function().
- hashkit_return_t hashkit_set_function(hashkit_st <#_CPPv410hashkit_st> *hash, hashkit_hash_algorithm_t hash_algorithm)
-
Parameters-
- •
-
hash-- pointer to an initializedhashkit_st<#_CPPv410hashkit_st> struct
- •
-
hash_algorithm-- validhashkit_hash_algorithm_tconstant
Returns-
hashkit_return_tindicating success or failure
- hashkit_return_t hashkit_set_custom_function(hashkit_st <#_CPPv410hashkit_st> *hash, hashkit_hash_fn function, void *context)
-
Parameters-
- •
-
hash-- pointer to initializedhashkit_st<#_CPPv410hashkit_st> struct
- •
-
function--hashkit_hash_fnfunction pointer to use as hash function forHASHKIT_HASH_CUSTOM
- •
-
context-- pointer to an opaque user managed context for the custom hash function
Returns-
hashkit_return_tindicating success or failure
- hashkit_hash_algorithm_t hashkit_get_function(const hashkit_st <#_CPPv410hashkit_st> *hash)
-
Parameters-
hash-- pointer to an initializedhashkit_st<#_CPPv410hashkit_st> struct
Returns-
hashkit_hash_algorithm_tindicating the currently set hash algorithm to use
- hashkit_return_t hashkit_set_distribution_function(hashkit_st <#_CPPv410hashkit_st> *hash, hashkit_hash_algorithm_t hash_algorithm)
-
Parameters-
- •
-
hash-- pointer to an initializedhashkit_st<#_CPPv410hashkit_st> struct
- •
-
hash_algorithm-- validhashkit_hash_algrothm_tconstant
Returns-
hashkit_return_tindicating success or failure
- hashkit_return_t hashkit_set_custom_distribution_function(hashkit_st <#_CPPv410hashkit_st> *hash, hashkit_hash_fn function, void *context)
-
Parameters-
- •
-
hash-- pointer to initializedhashkit_st<#_CPPv410hashkit_st> struct
- •
-
function--hashkit_hash_fnfunction pointer to use as distribution hash function forHASHKIT_HASH_CUSTOM
- •
-
context-- pointer to an opaque user managed context for the custom distribution hash function
- hashkit_hash_algorithm_t hashkit_get_distribution_function(const hashkit_st <#_CPPv410hashkit_st> *hash)
-
Parameters-
hash-- pointer to an initializedhashkit_st<#_CPPv410hashkit_st> struct
Returns-
hashkit_hash_algorithm_tindicating the currently set distribution hash algorithm to use
Overview
These functions are used to set and retrieve the key and distribution hash functions.
Return value
hashkit_set_function(), hashkit_set_custom_function() and the distribution equivalents return hashkit_return_t::HASHKIT_SUCCESS on success.
hashkit_get_function() and hashkit_get_distribution_function() return hashkit_hash_algorithm_t indicating the hash function used.
Releases
3 releases since Debian 12 (Bookworm); the text changed 2 times.