| 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 * |
| 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 |