src/cx/hash_key.h

changeset 1050
3df63e95921a
parent 1049
415bf2ce6bab
equal deleted inserted replaced
1049:415bf2ce6bab 1050:3df63e95921a
116 CxHashKey cx_hash_key( 116 CxHashKey cx_hash_key(
117 const void *obj, 117 const void *obj,
118 size_t len 118 size_t len
119 ); 119 );
120 120
121 #ifdef __cplusplus
122 } // extern "C"
123
124 cx_attr_nodiscard
125 static inline CxHashKey cx_hash_key_cxstr(cxstring str) {
126 return cx_hash_key(str.ptr, str.length);
127 }
128
129 cx_attr_nodiscard
130 static inline CxHashKey cx_hash_key_cxstr(cxmutstr str) {
131 return cx_hash_key(str.ptr, str.length);
132 }
133
134 #else
135 /** 121 /**
136 * Computes a hash key from a UCX string. 122 * Computes a hash key from a UCX string.
137 * 123 *
138 * @param str the string 124 * @param str the string
139 * @return the hash key 125 * @return the hash key
140 */ 126 */
141 #define cx_hash_key_cxstr(str) _Generic((str), \
142 cxstring: cx_hash_key_cxstring, \
143 cxmutstr: cx_hash_key_cxmutstr) \
144 (str)
145
146 /**
147 * @copydoc cx_hash_key_cxstr()
148 */
149 cx_attr_nodiscard 127 cx_attr_nodiscard
150 static inline CxHashKey cx_hash_key_cxstring(cxstring str) { 128 static inline CxHashKey cx_hash_key_cxstr(cxstring str) {
151 return cx_hash_key(str.ptr, str.length); 129 return cx_hash_key(str.ptr, str.length);
152 } 130 }
153 131
154 /** 132 /**
155 * @copydoc cx_hash_key_cxstr() 133 * Computes a hash key from a UCX string.
134 *
135 * @param str the string
136 * @return the hash key
156 */ 137 */
157 cx_attr_nodiscard 138 #define cx_hash_key_cxstr(str) cx_hash_key_cxstr(cx_strcast(str))
158 static inline CxHashKey cx_hash_key_cxmutstr(cxmutstr str) { 139
159 return cx_hash_key(str.ptr, str.length); 140 #ifdef __cplusplus
160 } 141 } // extern "C"
161 #endif 142 #endif
162 143
163 #endif // UCX_HASH_KEY_H 144 #endif // UCX_HASH_KEY_H

mercurial