af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Returns hash code for the key. */
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainentypedef unsigned int hash2_key_callback_t(const void *key);
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Returns TRUE if the key matches the value. */
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainentypedef bool hash2_cmp_callback_t(const void *key, const void *value,
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Create a new hash table. If initial_size is 0, the default value is used. */
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainenhash2_create(unsigned int initial_size, unsigned int value_size,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen hash2_cmp_callback_t *key_compare_cb, void *context) ATTR_NULL(5);
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Remove all nodes from hash table. */
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainenvoid *hash2_lookup(const struct hash2_table *hash, const void *key) ATTR_PURE;
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Iterate through all nodes with the given hash. iter must initially be
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen zero-filled. */
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainenvoid *hash2_iterate(const struct hash2_table *hash,
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen unsigned int key_hash, struct hash2_iter *iter);
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Insert node to the hash table and returns pointer to the value that can be
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen written to. Assumes it doesn't already exist (or that a duplicate entry
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen is wanted). */
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainenvoid *hash2_insert(struct hash2_table *hash, const void *key);
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Like hash2_insert(), but insert directly using a hash. */
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainenvoid *hash2_insert_hash(struct hash2_table *hash, unsigned int key_hash);
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Remove a node. */
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainenvoid hash2_remove(struct hash2_table *hash, const void *key);
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Remove the last node iterator returned. Iterating continues from the next
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainenvoid hash2_remove_iter(struct hash2_table *hash, struct hash2_iter *iter);
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainen/* Return the number of nodes in hash table. */
af5423cd2fb397e699c76f0d687ff23773d07a7cTimo Sirainenunsigned int hash2_count(const struct hash2_table *hash) ATTR_PURE;