HASHKIT_SET_CUSTOM_FUNCTION(3)
π NAME π
hashkit_set_custom_function β libhashkit Documentation β¨
okay bestie, pull up a chair π«Ά this is the libhashkit page for setting your own hash function, and honestly? it's giving main character energy. no cap. π
π¦ SYNOPSIS π¦
#include <libhashkit-1.0/hashkit.h>
Compile and link with -lhashkit
πΈ the custom hash function type πΈ
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 key without any terminating zero byte π - Param
contextβ the custom hash function context set throughhashkit_set_custom_function()orhashkit_set_custom_distribution_function()π - Returns β the custom hash function should return a hash value for
keyas an unsigned 32bit integer π’
π the return type π
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β Invalidhashkit_hash_algorithm_tpassed. π - enumerator
HASHKIT_INVALID_ARGUMENTβ Invalid argument passed. π«
π§ the algorithm enum π§
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). the classic, the blueprint β¨ - 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 libhashkit hash been built with HSIEH support. (that typo is theirs, not mine, i'm just the messenger π ) - enumerator
HASHKIT_HASH_MURMURβ Only available if libhashkit has been built with MURMUR support. - enumerator
HASHKIT_HASH_MURMUR3β Only available if libhashkit has been built with MURMUR support. - enumerator
HASHKIT_HASH_JENKINS - enumerator
HASHKIT_HASH_CUSTOMβ Use customhashkit_hash_fnfunction set throughhashkit_set_custom_function()orhashkit_set_custom_distribution_function(). this is the one, the moment, the icon π
π₯ the actual functions π₯
hashkit_return_t hashkit_set_function(hashkit_st *hash,
hashkit_hash_algorithm_t hash_algorithm)
Parameters
hashβ pointer to an initializedhashkit_ststructhash_algorithmβ validhashkit_hash_algorithm_tconstant
Returns β hashkit_return_t indicating success or failure
hashkit_return_t hashkit_set_custom_function(hashkit_st *hash,
hashkit_hash_fn function, void *context)
Parameters
hashβ pointer to initializedhashkit_ststructfunctionβhashkit_hash_fnfunction pointer to use as hash function forHASHKIT_HASH_CUSTOMcontextβ pointer to an opaque user managed context for the custom hash function
Returns β hashkit_return_t indicating success or failure
hashkit_hash_algorithm_t hashkit_get_function(const hashkit_st *hash)
Parameters
hashβ pointer to an initializedhashkit_ststruct
Returns β hashkit_hash_algorithm_t indicating the currently set hash algorithm to use
hashkit_return_t hashkit_set_distribution_function(hashkit_st *hash,
hashkit_hash_algorithm_t hash_algorithm)
Parameters
hashβ pointer to an initializedhashkit_ststructhash_algorithmβ validhashkit_hash_algrothm_tconstant
Returns β hashkit_return_t indicating success or failure
hashkit_return_t hashkit_set_custom_distribution_function(hashkit_st
*hash, hashkit_hash_fn function, void *context)
Parameters
hashβ pointer to initializedhashkit_ststructfunctionβhashkit_hash_fnfunction pointer to use as distribution hash function forHASHKIT_HASH_CUSTOMcontextβ pointer to an opaque user managed context for the custom distribution hash function
hashkit_hash_algorithm_t hashkit_get_distribution_function(const
hashkit_st *hash)
Parameters
hashβ pointer to an initializedhashkit_ststruct
Returns β hashkit_hash_algorithm_t indicating the currently set distribution hash algorithm to use
β¨ DESCRIPTION β¨
These functions are used to set and retrieve the key and distribution hash functions. that's it, that's the whole vibe β you put a function in, you get a function out, slay π«Ά
π 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. π
π SEE ALSO π
okay bestie that's the whole page, no cap, go forth and hash π
this one's from libmemcached-awesome, version 1.1, dated Jul 24, 2025 β periodt. π πΈ
π¦ where this page comes from
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- fedora 43: libmemcached-awesome-devel 1.1.4-7.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms