70 unsigned int index = 0;
77 if((ait != NULL) && (ait->
data != NULL)) {
107 for(
size_t i = start_bucket; i <= end_bucket; i++) {
135 while(current != NULL) {
137 char* key = current->
key;
168 return strcmp(key1 == NULL?
"":key1, key2 == NULL?
"":key2);
176 (*htable)->it_del = func;
226 const char*
const key) {
238 const char*
const key,
251 if((
it->
key != NULL) && (strcmp(
it->
key, key) != 0)) {
263 if(
it->
key == NULL) {
264 size_t length = strlen(key);
265 it->
key = (
char*) calloc(length + 1,
sizeof(
char));
267 memcpy(
it->
key, key, length);
279 const char*
const key) {
281 unsigned int index = 0;
296 while(
it != NULL && strcmp(key,
it->
key) != 0) {
305 const char*
const key) {
365 size_t needed_items = 0;
366 size_t needed_cap = 0;
373 needed_cap = ((needed_items + 1) * 100) / 75;
377 if(dest_cap < needed_cap) {
Ambiorix string hash functions header file.
static void amxc_htable_insert_it(amxc_htable_t *const htable, amxc_htable_it_t *const it)
static int amxc_htable_cmp_keys(amxc_array_it_t *it1, amxc_array_it_t *it2)
static void amxc_htable_it_delete_func(amxc_array_it_t *const it)
static int amxc_htable_grow(amxc_htable_t *const htable, size_t hint)
Ambiorix hash table API header file.
#define when_failed(x, l)
int amxc_array_it_set_data(amxc_array_it_t *const it, void *data)
Sets the data pointer of an array iterator.
AMXC_INLINE void * amxc_array_it_get_data(const amxc_array_it_t *const it)
Gets the data pointer of array iterator.
amxc_array_it_t * amxc_array_get_last(const amxc_array_t *const array)
Gets the item iterator of the last used item in the array.
amxc_array_it_t * amxc_array_set_data_at(amxc_array_t *const array, const unsigned int index, void *data)
Sets data at the given index.
int amxc_array_init(amxc_array_t *const array, const size_t items)
Initializes an array.
amxc_array_it_t * amxc_array_get_at(const amxc_array_t *const array, const unsigned int index)
Gets the item iterator for the given index.
amxc_array_it_t * amxc_array_get_first(const amxc_array_t *const array)
Gets the item iterator of the first used item in the array.
int8_t amxc_array_new(amxc_array_t **array, const size_t items)
Allocates an array.
void amxc_array_clean(amxc_array_t *const array, amxc_array_it_delete_t func)
Removes all items from the array.
int amxc_array_sort(amxc_array_t *const array, amxc_array_it_cmp_t cmp)
Sorts the content of the array.
int amxc_array_grow(amxc_array_t *const array, const size_t items)
Expands the array.
unsigned int amxc_BKDR_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
void amxc_htable_it_take(amxc_htable_it_t *const it)
Removes the iterator from the hash table.
AMXC_INLINE const char * amxc_htable_it_get_key(const amxc_htable_it_t *const it)
Gets the key from the iterator.
int amxc_htable_init(amxc_htable_t *const htable, const size_t reserve)
Initializes a hash table.
void amxc_htable_delete(amxc_htable_t **htable, amxc_htable_it_delete_t func)
Frees the previously allocated hash table.
amxc_array_t * amxc_htable_get_sorted_keys(const amxc_htable_t *const htable)
Creates an array containing all keys of the hash table.
amxc_htable_it_t * amxc_htable_get_first(const amxc_htable_t *const htable)
Gets the first item stored in the table.
int amxc_htable_new(amxc_htable_t **htable, const size_t reserve)
Allocates a hash table.
AMXC_INLINE size_t amxc_htable_size(const amxc_htable_t *const htable)
Calculates the size of the hash table.
unsigned int(* amxc_htable_hash_func_t)(const char *key, const unsigned int len)
Definition of the hash function.
int amxc_htable_move(amxc_htable_t *const dest, amxc_htable_t *const src)
Moves all items from one hash table to another hash table.
unsigned int amxc_htable_key2index(const amxc_htable_t *const htable, const char *const key)
Converts a key into an index.
amxc_htable_it_t * amxc_htable_take(amxc_htable_t *const htable, const char *const key)
Removes a hash table iterator from the hash table.
void(* amxc_htable_it_delete_t)(const char *key, amxc_htable_it_t *it)
Definition of the hash table item delete function.
amxc_htable_it_t * amxc_htable_get_last(const amxc_htable_t *const htable)
Gets the last item stored in the table.
amxc_htable_it_t * amxc_htable_get(const amxc_htable_t *const htable, const char *const key)
Gets a hash table iterator from the hash table.
AMXC_INLINE size_t amxc_htable_capacity(const amxc_htable_t *const htable)
Calculates the capacity of the hash table.
int amxc_htable_insert(amxc_htable_t *const htable, const char *const key, amxc_htable_it_t *const it)
Inserts an item in the hash table.
#define amxc_htable_for_each(it, htable)
Loops over items in the hash table.
void amxc_htable_clean(amxc_htable_t *const htable, amxc_htable_it_delete_t func)
Removes all items from the hash table.
#define AMXC_HTABLE_RANGE
Out of range indicator.
void amxc_htable_set_hash_func(amxc_htable_t *const htable, amxc_htable_hash_func_t func)
Sets the hash function for the hash table.
The array iterator structure.
struct _amxc_array_it * buffer
The hash table iterator structure.
The hash table structure.
amxc_htable_hash_func_t hfunc
amxc_htable_it_delete_t it_del
static amxc_htable_it_t it[2000]
static amxc_htable_t * htable
static amxc_llist_it_t it2
static amxc_llist_it_t it1