src/ucx/cx/hash_key.h

changeset 416
e2093ca0ef90
parent 415
d938228c382e
child 438
22eca559aded
equal deleted inserted replaced
415:d938228c382e 416:e2093ca0ef90
48 struct cx_hash_key_s { 48 struct cx_hash_key_s {
49 /** The key data. */ 49 /** The key data. */
50 union { 50 union {
51 unsigned char *bytes; 51 unsigned char *bytes;
52 unsigned char const *cbytes; 52 unsigned char const *cbytes;
53 char *str;
53 char const *cstr; 54 char const *cstr;
54 char *str;
55 void *obj; 55 void *obj;
56 void const *cobj;
56 } data; 57 } data;
57 /** 58 /**
58 * The key data length. 59 * The key data length.
59 */ 60 */
60 size_t len; 61 size_t len;
66 * Type for a hash key. 67 * Type for a hash key.
67 */ 68 */
68 typedef struct cx_hash_key_s CxHashKey; 69 typedef struct cx_hash_key_s CxHashKey;
69 70
70 /** 71 /**
71 * Computes a murmur hash-2. 72 * Computes a murmur2 32 bit hash.
72 * 73 *
73 * You need to initialize data and len in the key struct. 74 * You need to initialize \c data and \c len in the key struct.
74 * The hash is then directly written to that struct. 75 * The hash is then directly written to that struct.
76 *
77 * \note If \c data is \c NULL, the hash is defined as 1574210520.
75 * 78 *
76 * @param key the key, the hash shall be computed for 79 * @param key the key, the hash shall be computed for
77 */ 80 */
78 void cx_hash_murmur(CxHashKey *key); 81 void cx_hash_murmur(CxHashKey *key);
79 82
112 * @param len the length of object in memory 115 * @param len the length of object in memory
113 * @return the hash key 116 * @return the hash key
114 */ 117 */
115 __attribute__((__warn_unused_result__)) 118 __attribute__((__warn_unused_result__))
116 CxHashKey cx_hash_key( 119 CxHashKey cx_hash_key(
117 void *obj, 120 void const *obj,
118 size_t len 121 size_t len
119 ); 122 );
120 123
121 #ifdef __cplusplus 124 #ifdef __cplusplus
122 } // extern "C" 125 } // extern "C"

mercurial