src/ucx/cx/hash_key.h

changeset 490
d218607f5a7e
parent 438
22eca559aded
equal deleted inserted replaced
489:921f83a8943f 490:d218607f5a7e
36 36
37 37
38 #ifndef UCX_HASH_KEY_H 38 #ifndef UCX_HASH_KEY_H
39 #define UCX_HASH_KEY_H 39 #define UCX_HASH_KEY_H
40 40
41 #include "stddef.h" 41 #include "common.h"
42 42
43 #ifdef __cplusplus 43 #ifdef __cplusplus
44 extern "C" { 44 extern "C" {
45 #endif 45 #endif
46 46
47 /** Internal structure for a key within a hash map. */ 47 /** Internal structure for a key within a hash map. */
48 struct cx_hash_key_s { 48 struct cx_hash_key_s {
49 /** The key data. */ 49 /** The key data. */
50 union { 50 void const *data;
51 unsigned char *bytes;
52 unsigned char const *cbytes;
53 char *str;
54 char const *cstr;
55 void *obj;
56 void const *cobj;
57 } data;
58 /** 51 /**
59 * The key data length. 52 * The key data length.
60 */ 53 */
61 size_t len; 54 size_t len;
62 /** The hash value of the key data. */ 55 /** The hash value of the key data. */
119 CxHashKey cx_hash_key( 112 CxHashKey cx_hash_key(
120 void const *obj, 113 void const *obj,
121 size_t len 114 size_t len
122 ); 115 );
123 116
117 /**
118 * Computes a hash key from a UCX string.
119 *
120 * @param str the string
121 * @return the hash key
122 */
123 #define cx_hash_key_cxstr(str) cx_hash_key((void*)(str).ptr, (str).length)
124
124 #ifdef __cplusplus 125 #ifdef __cplusplus
125 } // extern "C" 126 } // extern "C"
126 #endif 127 #endif
127 128
128 #endif // UCX_HASH_KEY_H 129 #endif // UCX_HASH_KEY_H

mercurial