|
VSF Documented
|
#include "argtable3_private.h"#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>Functions | |
| arg_hashtable_t * | arg_hashtable_create (unsigned int minsize, unsigned int(*hashfn)(const void *), int(*eqfn)(const void *, const void *)) |
| Create a hash table. | |
| unsigned int | arg_hashtable_count (arg_hashtable_t *h) |
| Return the number of keys in the hash table. | |
| void | arg_hashtable_insert (arg_hashtable_t *h, void *k, void *v) |
| This function will cause the table to expand if the insertion would take the ratio of entries to table size over the maximum load factor. | |
| void * | arg_hashtable_search (arg_hashtable_t *h, const void *k) |
| Search the specified key in the hash table. | |
| void | arg_hashtable_remove (arg_hashtable_t *h, const void *k) |
| Remove the specified key from the hash table. | |
| void | arg_hashtable_destroy (arg_hashtable_t *h, int free_values) |
| Free the hash table and the memory allocated for each key-value pair. | |
| arg_hashtable_itr_t * | arg_hashtable_itr_create (arg_hashtable_t *h) |
| void | arg_hashtable_itr_destroy (arg_hashtable_itr_t *itr) |
| void * | arg_hashtable_itr_key (arg_hashtable_itr_t *i) |
| Return the value of the (key,value) pair at the current position. | |
| void * | arg_hashtable_itr_value (arg_hashtable_itr_t *i) |
| Return the value of the (key,value) pair at the current position. | |
| int | arg_hashtable_itr_advance (arg_hashtable_itr_t *itr) |
| Advance the iterator to the next element. Returns zero if advanced to end of table. | |
| int | arg_hashtable_itr_remove (arg_hashtable_itr_t *itr) |
| Remove current element and advance the iterator to the next element. | |
| int | arg_hashtable_itr_search (arg_hashtable_itr_t *itr, arg_hashtable_t *h, void *k) |
| Search and overwrite the supplied iterator, to point to the entry matching the supplied key. | |
| int | arg_hashtable_change (arg_hashtable_t *h, void *k, void *v) |
Variables | |
| const unsigned int | prime_table_length = sizeof(primes) / sizeof(primes[0]) |
| const float | max_load_factor = (float)0.65 |
| arg_hashtable_t * arg_hashtable_create | ( | unsigned int | minsize, |
| unsigned int(*)(const void *) | hashfn, | ||
| int(*)(const void *, const void *) | eqfn | ||
| ) |
Create a hash table.
| minsize | minimum initial size of hash table |
| hashfn | function for hashing keys |
| eqfn | function for determining key equality |
| unsigned int arg_hashtable_count | ( | arg_hashtable_t * | h | ) |
Return the number of keys in the hash table.
| h | the hash table |
| void arg_hashtable_insert | ( | arg_hashtable_t * | h, |
| void * | k, | ||
| void * | v | ||
| ) |
This function will cause the table to expand if the insertion would take the ratio of entries to table size over the maximum load factor.
This function does not check for repeated insertions with a duplicate key. The value returned when using a duplicate key is undefined – when the hash table changes size, the order of retrieval of duplicate key entries is reversed. If in doubt, remove before insert.
| h | the hash table to insert into |
| k | the key - hash table claims ownership and will free on removal |
| v | the value - does not claim ownership |
| void * arg_hashtable_search | ( | arg_hashtable_t * | h, |
| const void * | k | ||
| ) |
Search the specified key in the hash table.
| h | the hash table to search |
| k | the key to search for - does not claim ownership |
| void arg_hashtable_remove | ( | arg_hashtable_t * | h, |
| const void * | k | ||
| ) |
Remove the specified key from the hash table.
| h | the hash table to remove the item from |
| k | the key to search for - does not claim ownership |
| void arg_hashtable_destroy | ( | arg_hashtable_t * | h, |
| int | free_values | ||
| ) |
Free the hash table and the memory allocated for each key-value pair.
| h | the hash table |
| free_values | whether to call 'free' on the remaining values |
| arg_hashtable_itr_t * arg_hashtable_itr_create | ( | arg_hashtable_t * | h | ) |
| void arg_hashtable_itr_destroy | ( | arg_hashtable_itr_t * | itr | ) |
| void * arg_hashtable_itr_key | ( | arg_hashtable_itr_t * | i | ) |
Return the value of the (key,value) pair at the current position.
| void * arg_hashtable_itr_value | ( | arg_hashtable_itr_t * | i | ) |
Return the value of the (key,value) pair at the current position.
| int arg_hashtable_itr_advance | ( | arg_hashtable_itr_t * | itr | ) |
Advance the iterator to the next element. Returns zero if advanced to end of table.
| int arg_hashtable_itr_remove | ( | arg_hashtable_itr_t * | itr | ) |
Remove current element and advance the iterator to the next element.
| int arg_hashtable_itr_search | ( | arg_hashtable_itr_t * | itr, |
| arg_hashtable_t * | h, | ||
| void * | k | ||
| ) |
Search and overwrite the supplied iterator, to point to the entry matching the supplied key.
| int arg_hashtable_change | ( | arg_hashtable_t * | h, |
| void * | k, | ||
| void * | v | ||
| ) |
| const unsigned int prime_table_length = sizeof(primes) / sizeof(primes[0]) |
| const float max_load_factor = (float)0.65 |