Hash Table data structure. More...
Include dependency graph for hash.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| union | HashKey |
| The data item stored in a HashElem. More... | |
| struct | HashElem |
| The item stored in a Hash Table. More... | |
| struct | HashTable |
| A Hash Table. More... | |
| struct | HashWalkState |
| Cursor to iterate through a Hash Table. More... | |
Macros | |
| #define | MUTT_HASH_NO_FLAGS 0 |
| No flags are set. | |
| #define | MUTT_HASH_STRCASECMP (1 << 0) |
| use strcasecmp() to compare keys | |
| #define | MUTT_HASH_STRDUP_KEYS (1 << 1) |
| make a copy of the keys | |
| #define | MUTT_HASH_ALLOW_DUPS (1 << 2) |
| allow duplicate keys to be inserted | |
Typedefs | |
| typedef void(* | hash_hdata_free_t) (int type, void *obj, intptr_t data) |
| typedef size_t(* | hash_gen_hash_t) (union HashKey key, size_t num_elems) |
| typedef int(* | hash_cmp_key_t) (union HashKey a, union HashKey b) |
| typedef uint8_t | HashFlags |
| Flags for mutt_hash_new(), e.g. MUTT_HASH_STRCASECMP. | |
Functions | |
| ARRAY_HEAD (HashElemArray, struct HashElem *) | |
| void | mutt_hash_delete (struct HashTable *table, const char *strkey, 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. | |
| 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_find_elem (const struct HashTable *table, const char *strkey) |
| Find the HashElem in a Hash Table element using a key. | |
| void | mutt_hash_free (struct HashTable **ptr) |
| Free a hash table. | |
| 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. | |
| 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) | |
| struct HashTable * | mutt_hash_int_new (size_t num_elems, HashFlags flags) |
| Create a new Hash Table (with integer keys) | |
| struct HashTable * | mutt_hash_new (size_t num_elems, HashFlags flags) |
| Create a new Hash Table (with string 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. | |
| 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. | |
Hash Table data structure.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file hash.h.
| #define MUTT_HASH_STRCASECMP (1 << 0) |
| #define MUTT_HASH_STRDUP_KEYS (1 << 1) |
| #define MUTT_HASH_ALLOW_DUPS (1 << 2) |
| typedef void(* hash_hdata_free_t) (int type, void *obj, intptr_t data) |
| typedef size_t(* hash_gen_hash_t) (union HashKey key, size_t num_elems) |
| typedef uint8_t HashFlags |
Flags for mutt_hash_new(), e.g. MUTT_HASH_STRCASECMP.
| ARRAY_HEAD | ( | HashElemArray | , |
| struct HashElem * | ) |
| void mutt_hash_delete | ( | struct HashTable * | table, |
| const char * | strkey, | ||
| const void * | data ) |
Remove an element from a Hash Table.
| table | Hash Table to use |
| strkey | String key to match |
| data | Private data to match (or NULL for any match) |
Definition at line 427 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:Find the HashElem in a Hash Table element using a key.
| table | Hash Table to search |
| strkey | String key to search for |
| ptr | HashElem matching the key |
Unlike mutt_hash_find_elem(), this will return the first matching entry.
Definition at line 409 of file hash.c.
Here is the caller graph for this function:| void * mutt_hash_find | ( | const struct HashTable * | table, |
| const char * | strkey ) |
Find the HashElem data in a Hash Table element using a key.
| table | Hash Table to search |
| strkey | String key to search for |
| ptr | Data attached to the HashElem matching the key |
Definition at line 362 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:Find the HashElem in a Hash Table element using a key.
| table | Hash Table to search |
| strkey | String key to search for |
| ptr | HashElem matching the key |
Definition at line 377 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_hash_free | ( | struct HashTable ** | ptr | ) |
Free a hash table.
| [out] | ptr | Hash Table to be freed |
Definition at line 457 of file hash.c.
Here is the caller graph for this function:Add a new element to the Hash Table (with string keys)
| table | Hash Table (with string keys) |
| strkey | String key |
| data | Private data associated with the key |
| ptr | Newly inserted HashElem |
Definition at line 335 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_hash_int_delete | ( | struct HashTable * | table, |
| unsigned int | intkey, | ||
| const void * | data ) |
Remove an element from a Hash Table.
| table | Hash Table to use |
| intkey | Integer key to match |
| data | Private data to match (or NULL for any match) |
Definition at line 444 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void * mutt_hash_int_find | ( | const struct HashTable * | table, |
| unsigned int | intkey ) |
Find the HashElem data in a Hash Table element using a key.
| table | Hash Table to search |
| intkey | Integer key |
| ptr | Data attached to the HashElem matching the key |
Definition at line 392 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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)
| table | Hash Table (with integer keys) |
| intkey | Integer key |
| data | Private data associated with the key |
| ptr | Newly inserted HashElem |
Definition at line 347 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:Create a new Hash Table (with integer keys)
| num_elems | Number of elements it should contain |
| flags | Flags, see HashFlags |
| ptr | New Hash Table |
Definition at line 285 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:Create a new Hash Table (with string keys)
| num_elems | Number of elements it should contain |
| flags | Flags, see HashFlags |
| ptr | New Hash Table |
Definition at line 259 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_hash_set_destructor | ( | struct HashTable * | table, |
| hash_hdata_free_t | fn, | ||
| intptr_t | fn_data ) |
| 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.
| table | Hash Table to use |
| strkey | String key |
| type | Type to associate with the key |
| data | Private data associated with the key |
| ptr | Newly inserted HashElem |
Definition at line 317 of file hash.c.
Here is the call graph for this function:
Here is the caller graph for this function:| struct HashElem * mutt_hash_walk | ( | const struct HashTable * | table, |
| struct HashWalkState * | state ) |
Iterate through all the HashElem's in a Hash Table.
| table | Hash Table to search |
| state | Cursor to keep track |
Definition at line 489 of file hash.c.
Here is the caller graph for this function: