VSF Documented
Functions | Variables
arg_hashtable.c File Reference
#include "argtable3_private.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Functions

arg_hashtable_targ_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_targ_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
 

Function Documentation

◆ arg_hashtable_create()

arg_hashtable_t * arg_hashtable_create ( unsigned int  minsize,
unsigned int(*)(const void *)  hashfn,
int(*)(const void *, const void *)  eqfn 
)

Create a hash table.

Parameters
minsizeminimum initial size of hash table
hashfnfunction for hashing keys
eqfnfunction for determining key equality
Returns
newly created hash table or NULL on failure

◆ arg_hashtable_count()

unsigned int arg_hashtable_count ( arg_hashtable_t h)

Return the number of keys in the hash table.

Parameters
hthe hash table
Returns
the number of items stored in the hash table

◆ arg_hashtable_insert()

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.

Parameters
hthe hash table to insert into
kthe key - hash table claims ownership and will free on removal
vthe value - does not claim ownership
Returns
non-zero for successful insertion

◆ arg_hashtable_search()

void * arg_hashtable_search ( arg_hashtable_t h,
const void *  k 
)

Search the specified key in the hash table.

Parameters
hthe hash table to search
kthe key to search for - does not claim ownership
Returns
the value associated with the key, or NULL if none found

◆ arg_hashtable_remove()

void arg_hashtable_remove ( arg_hashtable_t h,
const void *  k 
)

Remove the specified key from the hash table.

Parameters
hthe hash table to remove the item from
kthe key to search for - does not claim ownership

◆ arg_hashtable_destroy()

void arg_hashtable_destroy ( arg_hashtable_t h,
int  free_values 
)

Free the hash table and the memory allocated for each key-value pair.

Parameters
hthe hash table
free_valueswhether to call 'free' on the remaining values

◆ arg_hashtable_itr_create()

arg_hashtable_itr_t * arg_hashtable_itr_create ( arg_hashtable_t h)

◆ arg_hashtable_itr_destroy()

void arg_hashtable_itr_destroy ( arg_hashtable_itr_t itr)

◆ arg_hashtable_itr_key()

void * arg_hashtable_itr_key ( arg_hashtable_itr_t i)

Return the value of the (key,value) pair at the current position.

◆ arg_hashtable_itr_value()

void * arg_hashtable_itr_value ( arg_hashtable_itr_t i)

Return the value of the (key,value) pair at the current position.

◆ arg_hashtable_itr_advance()

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.

◆ arg_hashtable_itr_remove()

int arg_hashtable_itr_remove ( arg_hashtable_itr_t itr)

Remove current element and advance the iterator to the next element.

◆ arg_hashtable_itr_search()

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.

Returns
Zero if not found.

◆ arg_hashtable_change()

int arg_hashtable_change ( arg_hashtable_t h,
void *  k,
void *  v 
)

Variable Documentation

◆ prime_table_length

const unsigned int prime_table_length = sizeof(primes) / sizeof(primes[0])

◆ max_load_factor

const float max_load_factor = (float)0.65
Generated from commit: vsfteam/vsf@c3767bf