Dependency-free hash table.
More...
Go to the source code of this file.
|
#define | icl_hash_foreach(ht, tmpint, tmpent, kp, dp) |
|
|
icl_hash_t * | icl_hash_create (int nbuckets, unsigned int(*hash_function)(void *), int(*hash_key_compare)(void *, void *)) |
| Creates a new hash table. More...
|
|
void * | icl_hash_find (icl_hash_t *, void *) |
| Searches for an entry in a hash table. More...
|
|
icl_entry_t * | icl_hash_insert (icl_hash_t *, void *, void *) |
| Inserts an item into a hash table. More...
|
|
icl_entry_t * | icl_hash_update_insert (icl_hash_t *, void *, void *, void **) |
| Replaces an entry in a hash table with a given entry. More...
|
|
int | icl_hash_destroy (icl_hash_t *, void(*)(void *), void(*)(void *)) |
| Destroys a hash table. Keys and data are freed using functions. More...
|
|
int | icl_hash_dump (FILE *, icl_hash_t *) |
| Dumps the hash table's contents to the given file pointer. More...
|
|
int | icl_hash_delete (icl_hash_t *, void *, void(*)(void *), void(*)(void *)) |
| Frees one hash table entry located by a key. Key and data are freed using functions. More...
|
|
Dependency-free hash table.
- Author
- Keith Seymour
PULSAR Runtime http://icl.utk.edu/pulsar/ Copyright (C) 2012-2015 University of Tennessee.
Definition in file icl_hash.h.
#define icl_hash_foreach |
( |
|
ht, |
|
|
|
tmpint, |
|
|
|
tmpent, |
|
|
|
kp, |
|
|
|
dp |
|
) |
| |
Value:for (tmpint=0;tmpint<ht->nbuckets; tmpint++) \
for (tmpent=ht->buckets[tmpint]; \
tmpent!=NULL&&((kp=tmpent->key)!=NULL)&&((dp=tmpent->data)!=NULL); \
tmpent=tmpent->next)
Definition at line 43 of file icl_hash.h.
icl_hash_t* icl_hash_create |
( |
int |
nbuckets, |
|
|
unsigned int(*)(void *) |
hash_function, |
|
|
int(*)(void *, void *) |
hash_key_compare |
|
) |
| |
Creates a new hash table.
- Parameters
-
nbuckets | – The number of buckets to create. |
hash_function | – The pointer to the hashing function. |
hash_key_compare | – The pointer to the hash key comparison function. |
- Returns
- A pointer to new hash table.
Definition at line 71 of file icl_hash.c.
int icl_hash_delete |
( |
icl_hash_t * |
ht, |
|
|
void * |
key, |
|
|
void(*)(void *) |
free_key, |
|
|
void(*)(void *) |
free_data |
|
) |
| |
Frees one hash table entry located by a key. Key and data are freed using functions.
- Parameters
-
ht | – The hash table. |
key | – The key of the item to be deleted. |
free_key | – The pointer to the function that frees the key. |
free_data | – The pointer to the function that frees the data. |
- Return values
-
0 | on success. |
-1 | on failure. |
Definition at line 234 of file icl_hash.c.
int icl_hash_destroy |
( |
icl_hash_t * |
ht, |
|
|
void(*)(void *) |
free_key, |
|
|
void(*)(void *) |
free_data |
|
) |
| |
Destroys a hash table. Keys and data are freed using functions.
- Parameters
-
ht | – The hash table to destroy. |
free_key | – The pointer to function that frees the keys. |
free_data | – The pointer to function that frees the data. |
- Return values
-
0 | on success. |
-1 | on failure. |
Definition at line 282 of file icl_hash.c.
int icl_hash_dump |
( |
FILE * |
stream, |
|
|
icl_hash_t * |
ht |
|
) |
| |
Dumps the hash table's contents to the given file pointer.
- Parameters
-
stream | – The file to dump the hash table to. |
ht | – The hash table to be dumped. |
- Return values
-
0 | on success. |
-1 | on failure. |
Definition at line 323 of file icl_hash.c.
void* icl_hash_find |
( |
icl_hash_t * |
ht, |
|
|
void * |
key |
|
) |
| |
Searches for an entry in a hash table.
- Parameters
-
ht | – The hash table to be searched. |
key | – The key of the item to search for. |
- Returns
- A pointer to the data corresponding to the key. NULL if the key is not found.
Definition at line 109 of file icl_hash.c.
Inserts an item into a hash table.
- Parameters
-
ht | – The hash table. |
key | – The key of the new item. |
data | – The pointer to the new item's data. |
- Returns
- A pointer to the new item. NULL on error.
Definition at line 135 of file icl_hash.c.
Replaces an entry in a hash table with a given entry.
- Parameters
-
ht | – The hash table. |
key | – The key of the new item. |
data | – The pointer to the new item's data. |
olddata | – The pointer to the old item's data (set upon return). |
- Returns
- A pointer to the new item. NULL on error.
Definition at line 174 of file icl_hash.c.