74 for(
int i = 0; i < 30; i++) {
84 assert_ptr_not_equal(
it, NULL);
85 assert_ptr_not_equal((
char*) key, NULL);
86 assert_ptr_equal(
it->
key, NULL);
87 assert_ptr_equal(
it->
ait, NULL);
88 assert_ptr_equal(
it->
next, NULL);
104 assert_ptr_not_equal(
htable, NULL);
111 assert_ptr_equal(
htable, NULL);
119 for(
int i = 0; i < 30; i++) {
120 sprintf(key,
"key%d", i);
234 assert_ptr_not_equal(
it[0].ait, NULL);
236 assert_string_equal(
it[0].key,
"TestKey");
238 assert_ptr_equal(
it[0].next, NULL);
246 assert_ptr_not_equal(
it[0].ait, NULL);
248 assert_string_equal(
it[0].key,
"TestKey");
250 assert_ptr_equal(
it[0].next, NULL);
254 assert_ptr_not_equal(
it[1].ait, NULL);
256 assert_string_equal(
it[1].key,
"TestKey");
258 assert_ptr_equal(
it[1].next, &
it[0]);
261 assert_ptr_equal(
it[0].ait,
it[1].ait);
271 assert_ptr_not_equal(
it[0].ait, NULL);
272 assert_string_equal(
it[0].key,
"AnotherKey");
276 assert_ptr_not_equal(
it[0].ait, NULL);
277 assert_string_equal(
it[0].key,
"AnotherKey");
288 for(
int i = 0; i < 30; i++) {
289 sprintf(key,
"key%d", i);
291 assert_ptr_not_equal(
it[i].ait, NULL);
292 assert_string_equal(
it[i].key, key);
312 for(
int i = 0; i < 2000; i++) {
313 sprintf(key,
"key%d", i);
315 assert_ptr_not_equal(
it[i].ait, NULL);
316 assert_string_equal(
it[i].key, key);
402 assert_string_equal(
it[2].key,
"Key3");
403 assert_ptr_not_equal(
it[2].ait, NULL);
406 assert_string_equal(
it[0].key,
"Key1");
407 assert_ptr_not_equal(
it[0].ait, NULL);
410 assert_string_equal(
it[3].key,
"Key4");
411 assert_ptr_not_equal(
it[3].ait, NULL);
414 assert_string_equal(
it[1].key,
"Key2");
415 assert_ptr_not_equal(
it[1].ait, NULL);
418 assert_string_equal(
it[4].key,
"Key5");
419 assert_ptr_not_equal(
it[4].ait, NULL);
435 assert_string_equal(
it[1].key,
"Key610");
436 assert_ptr_not_equal(
it[1].ait, NULL);
437 assert_ptr_equal(
it[1].next, &
it[0]);
440 assert_string_equal(
it[0].key,
"Key1");
441 assert_ptr_not_equal(
it[0].ait, NULL);
458 assert_string_equal(
it[0].key,
"Key1");
459 assert_ptr_not_equal(
it[0].ait, NULL);
480 assert_string_equal(
it[0].key,
"Key1");
481 assert_ptr_not_equal(
it[0].ait, NULL);
507 assert_string_equal(
it[2].key,
"Key3");
508 assert_ptr_equal(
it[2].ait, NULL);
512 assert_string_equal(
it[0].key,
"Key1");
513 assert_ptr_equal(
it[0].ait, NULL);
517 assert_string_equal(
it[3].key,
"Key4");
518 assert_ptr_equal(
it[3].ait, NULL);
522 assert_string_equal(
it[1].key,
"Key2");
523 assert_ptr_equal(
it[1].ait, NULL);
527 assert_string_equal(
it[4].key,
"Key5");
528 assert_ptr_equal(
it[4].ait, NULL);
545 assert_string_equal(
it[1].key,
"Key610");
546 assert_ptr_equal(
it[1].ait, NULL);
547 assert_ptr_equal(
it[1].next, NULL);
551 assert_string_equal(
it[0].key,
"Key1");
552 assert_ptr_equal(
it[0].ait, NULL);
575 assert_string_equal(
it[0].key,
"Key1");
576 assert_ptr_equal(
it[0].ait, NULL);
621 unsigned int count = 0;
628 assert_int_equal(count, 5);
641 unsigned int count = 0;
644 assert_ptr_equal(
it->
ait, ait);
649 assert_int_equal(count, 5);
675 unsigned int count = 0;
679 assert_ptr_equal(iter->
ait, ait);
684 assert_int_equal(count, 3);
690 assert_ptr_equal(iter->
ait, ait);
695 assert_int_equal(count, 3);
704 assert_int_equal(count, 1);
723 unsigned int count = 0;
730 assert_int_equal(count, 5);
743 unsigned int count = 0;
746 assert_ptr_equal(
it->
ait, ait);
751 assert_int_equal(count, 5);
777 unsigned int count = 0;
781 assert_ptr_equal(iter->
ait, ait);
786 assert_int_equal(count, 3);
792 assert_ptr_equal(iter->
ait, ait);
797 assert_int_equal(count, 3);
806 assert_int_equal(count, 1);
827 assert_string_equal(
it[3].key,
"Key4");
828 assert_ptr_equal(
it[3].ait, NULL);
829 assert_ptr_equal(
it[3].next, NULL);
833 assert_string_equal(
it[4].key,
"Key5");
834 assert_ptr_equal(
it[4].ait, NULL);
835 assert_ptr_equal(
it[4].next, NULL);
852 assert_string_equal(
it[2].key,
"Key");
853 assert_ptr_equal(
it[2].ait, NULL);
854 assert_ptr_equal(
it[2].next, NULL);
858 assert_string_equal(
it[0].key,
"Key");
859 assert_ptr_equal(
it[0].ait, NULL);
860 assert_ptr_equal(
it[0].next, NULL);
864 assert_string_equal(
it[4].key,
"Key");
865 assert_ptr_equal(
it[4].ait, NULL);
866 assert_ptr_equal(
it[4].next, NULL);
904 assert_string_equal(
it[0].key,
"SomeKey");
917 for(
int i = 0; i < 2000; i++) {
918 sprintf(key,
"key%4d", i);
920 assert_ptr_not_equal(
it[i].ait, NULL);
921 assert_string_equal(
it[i].key, key);
927 assert_non_null(
array);
930 for(
int i = 0; i < 2000; i++) {
932 sprintf(key,
"key%4d", i);
933 assert_string_equal(ak, key);
956 for(
int i = 0; i < 2000; i++) {
957 sprintf(key,
"key%4d", i);
959 assert_ptr_not_equal(
it[i].ait, NULL);
960 assert_string_equal(
it[i].key, key);
964 for(
int i = 0; i < 2000; i++) {
965 sprintf(key,
"key%4d", i);
974 for(
int i = 0; i < 2000; i++) {
975 sprintf(key,
"key%4d", i);
Ambiorix string hash functions header file.
Ambiorix hash table API header file.
AMXC_INLINE size_t amxc_array_capacity(const amxc_array_t *const array)
Gets the capacity of the array.
size_t amxc_array_size(const amxc_array_t *const array)
Calculates the number of used items in the array.
AMXC_INLINE void * amxc_array_get_data_at(const amxc_array_t *const array, const unsigned int index)
Gets the data pointer of the item at the given index.
void amxc_array_delete(amxc_array_t **array, const amxc_array_it_delete_t func)
Frees the previously allocated array.
unsigned int amxc_BKDR_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_DJB_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
amxc_htable_it_t * amxc_htable_it_get_next(const amxc_htable_it_t *const reference)
Gets the next iterator in the hash table.
int amxc_htable_it_init(amxc_htable_it_t *const it)
Initializes a hash table.iterator.
void amxc_htable_it_clean(amxc_htable_it_t *const it, amxc_htable_it_delete_t func)
Removes the iterator from the htable and frees allocated memory.
amxc_htable_it_t * amxc_htable_it_get_next_key(const amxc_htable_it_t *const reference)
Gets the next iterator in the hash table with the same key.
void amxc_htable_it_take(amxc_htable_it_t *const it)
Removes the iterator from the hash table.
amxc_htable_it_t * amxc_htable_it_get_previous(const amxc_htable_it_t *const reference)
Gets the previous iterator in 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.
amxc_htable_it_t * amxc_htable_it_get_previous_key(const amxc_htable_it_t *const reference)
Gets the previous iterator in the hash table with the same key.
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.
AMXC_INLINE bool amxc_htable_contains(const amxc_htable_t *const htable, const char *const key)
Verifies that a key is in the hash table.
AMXC_INLINE bool amxc_htable_is_empty(const amxc_htable_t *const htable)
Checks that the hash table is empty.
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.
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.
AMXC_INLINE amxc_htable_it_t * amxc_htable_take_first(const amxc_htable_t *const htable)
Removes the first item stored in the 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.
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
static unsigned int array[2006]
void amxc_htable_init_reserve_check(UNUSED void **state)
void amxc_htable_it_get_previous_key_check(UNUSED void **state)
void amxc_htable_take_first_null_check(UNUSED void **state)
void amxc_htable_insert_null_check(UNUSED void **state)
static unsigned int deletes
void amxc_htable_get_last_check(UNUSED void **state)
void amxc_htable_init_clean_null_check(UNUSED void **state)
void amxc_htable_check_null_ptr(UNUSED void **state)
void amxc_htable_key2index_null_check(UNUSED void **state)
void amxc_htable_size_null_check(UNUSED void **state)
void amxc_htable_init_clean_check(UNUSED void **state)
void amxc_htable_it_get_previous_check(UNUSED void **state)
void amxc_htable_move_check(UNUSED void **state)
void amxc_htable_it_take_null_check(UNUSED void **state)
void amxc_htable_it_get_previous_null_check(UNUSED void **state)
void amxc_htable_get_null_check(UNUSED void **state)
static amxc_htable_it_t it[2000]
void amxc_htable_set_hash_func_check(UNUSED void **state)
void amxc_htable_it_clean_null_check(UNUSED void **state)
void amxc_htable_insert_grow_check(UNUSED void **state)
void amxc_htable_delete_func_check(UNUSED void **state)
void amxc_htable_it_get_next_key_check(UNUSED void **state)
void amxc_htable_capacity_null_check(UNUSED void **state)
void amxc_htable_get_check(UNUSED void **state)
void amxc_htable_new_delete_check(UNUSED void **state)
void amxc_htable_contains_check(UNUSED void **state)
void amxc_htable_it_get_next_key_null_check(UNUSED void **state)
void amxc_htable_new_delete_null_check(UNUSED void **state)
void amxc_htable_insert_same_key_check(UNUSED void **state)
void amxc_htable_size_check(UNUSED void **state)
void amxc_htable_get_first_check(UNUSED void **state)
void amxc_htable_insert_same_it_check(UNUSED void **state)
void amxc_htable_key2index_check(UNUSED void **state)
void amxc_htable_take_check(UNUSED void **state)
void amxc_htable_get_first_null_check(UNUSED void **state)
void amxc_htable_contains_null_check(UNUSED void **state)
void amxc_htable_it_get_next_chained_check(UNUSED void **state)
void amxc_htable_it_get_key_check(UNUSED void **state)
void amxc_htable_insert_check(UNUSED void **state)
void amxc_htable_it_take_check(UNUSED void **state)
void amxc_htable_it_get_previous_chained_check(UNUSED void **state)
void amxc_htable_it_get_previous_key_null_check(UNUSED void **state)
void amxc_htable_is_empty_null_check(UNUSED void **state)
void amxc_htable_get_sorted_keys_check(UNUSED void **state)
void amxc_htable_take_null_check(UNUSED void **state)
void amxc_htable_get_chained_check(UNUSED void **state)
void amxc_htable_insert_grow_big_check(UNUSED void **state)
void amxc_htable_it_clean_func_check(UNUSED void **state)
static amxc_htable_t * htable
void amxc_htable_get_last_null_check(UNUSED void **state)
static void amxc_delete_it_func(const char *key, amxc_htable_it_t *it)
static void amxc_htable_setup(void)
static void amxc_htable_teardown(void)
void amxc_htable_it_init_null_check(UNUSED void **state)
void amxc_htable_take_chained_check(UNUSED void **state)
void amxc_htable_take_first_check(UNUSED void **state)
void amxc_htable_it_get_next_null_check(UNUSED void **state)
void amxc_htable_it_take_chained_check(UNUSED void **state)
void amxc_htable_capacity_check(UNUSED void **state)
void amxc_htable_it_get_next_check(UNUSED void **state)
void amxc_htable_is_empty_check(UNUSED void **state)