23#ifndef MUTT_MUTT_HASH_H
24#define MUTT_MUTT_HASH_H
109#define MUTT_HASH_NO_FLAGS 0
110#define MUTT_HASH_STRCASECMP (1 << 0)
111#define MUTT_HASH_STRDUP_KEYS (1 << 1)
112#define MUTT_HASH_ALLOW_DUPS (1 << 2)
uint8_t HashFlags
Flags for mutt_hash_new(), e.g. MUTT_HASH_STRCASECMP.
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_delete(struct HashTable *table, const char *strkey, const void *data)
Remove an element from a Hash Table.
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
int(* hash_cmp_key_t)(union HashKey a, union HashKey b)
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_find_bucket(const struct HashTable *table, const char *strkey)
Find the HashElem in a Hash Table element using a key.
struct HashTable * mutt_hash_int_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with integer keys)
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.
struct HashElem * mutt_hash_walk(const struct HashTable *table, struct HashWalkState *state)
Iterate through all the HashElem's in a Hash Table.
struct HashTable * mutt_hash_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with string keys)
struct HashElem * mutt_hash_find_elem(const struct HashTable *table, const char *strkey)
Find the HashElem in a Hash Table element using a key.
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)
void(* hash_hdata_free_t)(int type, void *obj, intptr_t data)
void * mutt_hash_int_find(const struct HashTable *table, unsigned int intkey)
Find the HashElem data in a Hash Table element using a key.
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)
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
The item stored in a Hash Table.
struct HashElem * next
Linked List.
union HashKey key
Key representing the data.
int type
Type of data stored in Hash Table, e.g. DT_STRING.
void * data
User-supplied data.
hash_gen_hash_t gen_hash
Function to generate hash id from the key.
struct HashElem ** table
Array of Hash keys.
hash_cmp_key_t cmp_key
Function to compare two Hash keys.
bool allow_dups
if set, duplicate keys are allowed
size_t num_elems
Number of buckets in the Hash Table.
bool strdup_keys
if set, the key->strkey is strdup()'d
intptr_t hdata
Data to pass to the hdata_free() function.
hash_hdata_free_t hdata_free
Function to free a Hash element.
Cursor to iterate through a Hash Table.
size_t index
Current position in table.
struct HashElem * last
Current element in linked list.
The data item stored in a HashElem.
const char * strkey
String key.
unsigned int intkey
Integer key.