--- a/docs/Writerside/topics/hash_key.h.md Fri Jan 24 21:38:40 2025 +0100 +++ b/docs/Writerside/topics/hash_key.h.md Sat Jan 25 13:40:50 2025 +0100 @@ -3,14 +3,27 @@ UCX implements the MurmurHash2 algorithm for computing hashes that are primarily used for [CxMap](map.h.md). But it can be used for arbitrary custom scenarios, too. -There are four functions which all generate a `CxHashKey` structure for given data. +## Overview +```C +#include <cx/hash_key.h> + +void cx_hash_murmur(CxHashKey *key); +CxHashKey cx_hash_key(const void *obj, size_t len); +CxHashKey cx_hash_key_str(const char *str); +CxHashKey cx_hash_key_bytes(const unsigned char *bytes, size_t len); +CxHashKey cx_hash_key_cxstr(cxstring str); +``` -* `cx_hash_key()` takes an arbitrary pointer and a length -* `cx_hash_key_bytes()` takes an `unsigned char*` and a length -* `cx_hash_key_str()` takes a usual C string -* `cx_hash_key_cxstr()` takes a [UCX string](string.h.md) +## Description + +The primary function for creating a `CxHashKey` structure is `cx_hash_key()`. +The other functions do effectively the same, but -The hash is then available in the `hash` field of the returned structure. +* `cx_hash_key_bytes()` is strongly typed if you want to avoid passing `void*` +* `cx_hash_key_str()` conveniently takes a C string and computes the length on its own +* `cx_hash_key_cxstr()` conveniently takes a [UCX string](string.h.md) + +In all cases, the hash will be available in the `hash` field of the returned structure. <note> UCX assigns the hash value <code>1574210520</code> to the <code>NULL</code> pointer. @@ -29,3 +42,9 @@ key.len = strlen(mystring); cx_hash_murmur(&key); ``` + +<seealso> +<category ref="apidoc"> +<a href="https://ucx.sourceforge.io/api/hash__key_8h.html">hash_key.h</a> +</category> +</seealso> \ No newline at end of file