Go to the documentation of this file.
24 #ifndef MUTT_LIB_HASH_H
25 #define MUTT_LIB_HASH_H
97 #define MUTT_HASH_NO_FLAGS 0
98 #define MUTT_HASH_STRCASECMP (1 << 0)
99 #define MUTT_HASH_STRDUP_KEYS (1 << 1)
100 #define MUTT_HASH_ALLOW_DUPS (1 << 2)
struct HashElem * mutt_hash_find_bucket(const struct HashTable *table, const char *strkey)
Find the HashElem in a Hash Table element using a key.
void(* hash_hdata_free_t)(int type, void *obj, intptr_t data)
Prototype for Hash Destructor callback function.
unsigned int intkey
Integer key.
size_t num_elems
Number of elements in the Hash Table.
union HashKey key
Key representing the data.
uint8_t HashFlags
Flags for mutt_hash_new(), e.g. MUTT_HASH_STRCASECMP.
hash_gen_hash_t gen_hash
Function to generate hash id from the key.
bool strdup_keys
if set, the key->strkey is strdup()'d
void * data
User-supplied data.
struct HashElem * next
Linked List.
struct HashElem * mutt_hash_find_elem(const struct HashTable *table, const char *strkey)
Find the HashElem in a Hash Table element using a key.
struct HashElem ** table
Array of Hash keys.
void mutt_hash_delete(struct HashTable *table, const char *strkey, const void *data)
Remove an element from a Hash Table.
bool allow_dups
if set, duplicate keys are allowed
intptr_t hdata
Data to pass to the hdata_free() function.
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
const char * strkey
String key.
The data item stored in a HashElem.
hash_hdata_free_t hdata_free
Function to free a Hash element.
struct HashTable * mutt_hash_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with string keys)
struct HashTable * mutt_hash_int_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with integer keys)
void mutt_hash_set_destructor(struct HashTable *table, hash_hdata_free_t fn, intptr_t fn_data)
Set the destructor for a Hash Table.
size_t(* hash_gen_hash_t)(union HashKey key, size_t num_elems)
Prototype for a Key hashing function.
int type
Type of data stored in Hash Table, e.g. DT_STRING.
struct HashElem * mutt_hash_typed_insert(struct HashTable *table, const char *strkey, int type, void *data)
Insert a string with type info into a Hash Table.
Cursor to iterate through a Hash Table.
size_t index
Current position in table.
hash_cmp_key_t cmp_key
Function to compare two Hash keys.
The item stored in a Hash Table.
int(* hash_cmp_key_t)(union HashKey a, union HashKey b)
Prototype for a function to compare two Hash keys.
void * mutt_hash_int_find(const struct HashTable *table, unsigned int intkey)
Find the HashElem data in a Hash Table element using a key.
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
void mutt_hash_int_delete(struct HashTable *table, unsigned int intkey, const void *data)
Remove an element from a Hash Table.
struct HashElem * mutt_hash_int_insert(struct HashTable *table, unsigned int intkey, void *data)
Add a new element to the Hash Table (with integer keys)
struct HashElem * mutt_hash_walk(const struct HashTable *table, struct HashWalkState *state)
Iterate through all the HashElem's in a Hash Table.
struct HashElem * last
Current element in linked list.