ucx/cx/hash_key.h

changeset 16
04c9f8d8f03b
parent 11
0aa8cbd7912e
child 22
112b85020dc9
equal deleted inserted replaced
15:862ab606ee06 16:04c9f8d8f03b
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 /** 28 /**
29 * \file hash_key.h 29 * @file hash_key.h
30 * \brief Interface for map implementations. 30 * @brief Interface for map implementations.
31 * \author Mike Becker 31 * @author Mike Becker
32 * \author Olaf Wintermann 32 * @author Olaf Wintermann
33 * \copyright 2-Clause BSD License 33 * @copyright 2-Clause BSD License
34 */ 34 */
35 35
36 36
37 #ifndef UCX_HASH_KEY_H 37 #ifndef UCX_HASH_KEY_H
38 #define UCX_HASH_KEY_H 38 #define UCX_HASH_KEY_H
60 * Type for a hash key. 60 * Type for a hash key.
61 */ 61 */
62 typedef struct cx_hash_key_s CxHashKey; 62 typedef struct cx_hash_key_s CxHashKey;
63 63
64 /** 64 /**
65 * Computes a murmur2 32 bit hash. 65 * Computes a murmur2 32-bit hash.
66 * 66 *
67 * You need to initialize \c data and \c len in the key struct. 67 * You need to initialize @c data and @c len in the key struct.
68 * The hash is then directly written to that struct. 68 * The hash is then directly written to that struct.
69 * 69 *
70 * \note If \c data is \c NULL, the hash is defined as 1574210520. 70 * Usually you should not need this function.
71 * Use cx_hash_key(), instead.
72 *
73 * @note If @c data is @c NULL, the hash is defined as 1574210520.
71 * 74 *
72 * @param key the key, the hash shall be computed for 75 * @param key the key, the hash shall be computed for
76 * @see cx_hash_key()
73 */ 77 */
74 cx_attr_nonnull 78 cx_attr_nonnull
79 cx_attr_export
75 void cx_hash_murmur(CxHashKey *key); 80 void cx_hash_murmur(CxHashKey *key);
76 81
77 /** 82 /**
78 * Computes a hash key from a string. 83 * Computes a hash key from a string.
79 * 84 *
82 * @param str the string 87 * @param str the string
83 * @return the hash key 88 * @return the hash key
84 */ 89 */
85 cx_attr_nodiscard 90 cx_attr_nodiscard
86 cx_attr_cstr_arg(1) 91 cx_attr_cstr_arg(1)
92 cx_attr_export
87 CxHashKey cx_hash_key_str(const char *str); 93 CxHashKey cx_hash_key_str(const char *str);
88 94
89 /** 95 /**
90 * Computes a hash key from a byte array. 96 * Computes a hash key from a byte array.
91 * 97 *
93 * @param len the length 99 * @param len the length
94 * @return the hash key 100 * @return the hash key
95 */ 101 */
96 cx_attr_nodiscard 102 cx_attr_nodiscard
97 cx_attr_access_r(1, 2) 103 cx_attr_access_r(1, 2)
104 cx_attr_export
98 CxHashKey cx_hash_key_bytes( 105 CxHashKey cx_hash_key_bytes(
99 const unsigned char *bytes, 106 const unsigned char *bytes,
100 size_t len 107 size_t len
101 ); 108 );
102 109
111 * @param len the length of object in memory 118 * @param len the length of object in memory
112 * @return the hash key 119 * @return the hash key
113 */ 120 */
114 cx_attr_nodiscard 121 cx_attr_nodiscard
115 cx_attr_access_r(1, 2) 122 cx_attr_access_r(1, 2)
123 cx_attr_export
116 CxHashKey cx_hash_key( 124 CxHashKey cx_hash_key(
117 const void *obj, 125 const void *obj,
118 size_t len 126 size_t len
119 ); 127 );
120 128
130 } 138 }
131 139
132 /** 140 /**
133 * Computes a hash key from a UCX string. 141 * Computes a hash key from a UCX string.
134 * 142 *
135 * @param str the string 143 * @param str (@c cxstring or @c cxmutstr) the string
136 * @return the hash key 144 * @return (@c CxHashKey) the hash key
137 */ 145 */
138 #define cx_hash_key_cxstr(str) cx_hash_key_cxstr(cx_strcast(str)) 146 #define cx_hash_key_cxstr(str) cx_hash_key_cxstr(cx_strcast(str))
139 147
140 #ifdef __cplusplus 148 #ifdef __cplusplus
141 } // extern "C" 149 } // extern "C"

mercurial