docs/Writerside/topics/hash_key.h.md

changeset 1400
7bc88ae62755
parent 1244
9a8e781258ac
--- a/docs/Writerside/topics/hash_key.h.md	Sat Sep 27 17:47:10 2025 +0200
+++ b/docs/Writerside/topics/hash_key.h.md	Sat Sep 27 17:49:13 2025 +0200
@@ -7,17 +7,25 @@
 ```C
 #include <cx/hash_key.h>
 
-void 	  cx_hash_murmur(CxHashKey *key);
+void cx_hash_murmur(CxHashKey *key);
+
+uint32_t cx_hash_u32(uint32_t x);
+uint64_t cx_hash_u64(uint64_t x);
+
 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);
+CxHashKey cx_hash_key_u32(uint32_t x);
+CxHashKey cx_hash_key_u64(uint64_t x);
+
+int cx_hash_key_cmp(const CxHashKey *left, const CxHashKey *right);
 ``` 
 
 ## Description
 
-The primary function for creating a `CxHashKey` structure is `cx_hash_key()`.
-The other functions do effectively the same, but
+The primary function for creating a `CxHashKey` structure from non-integers is `cx_hash_key()`.
+The other functions effectively do the same, but
 
 * `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
@@ -25,7 +33,6 @@
 
 In all cases, the hash will be available in the `hash` field of the returned structure.
 
-
 > UCX assigns the hash value `1574210520` to the `NULL` pointer.
 > This is a careful choice which is not standard MurmurHash2 and an extension to support `NULL` pointers.
 
@@ -42,6 +49,14 @@
 cx_hash_murmur(&key);
 ```
 
+Hashes from integers are created more efficiently by mixing up the bits to produce a good statistical distribution.
+The function `cx_hash_u32()` and `cx_hash_u64()` are provided for this purpose and provide collision-free hashes.
+The corresponding functions `cx_hash_key_u32()` and `cx_hash_key_u64()` can be used to create `CxHashKey` structures with those hashes.
+
+> Since integer hashes are collision-free, there is no need to store any `data` in the `CxHashKey` structure. 
+
+Hash keys are compared with `cx_hash_key_cmp()`.
+
 <seealso>
 <category ref="apidoc">
 <a href="https://ucx.sourceforge.io/api/hash__key_8h.html">hash_key.h</a>

mercurial