Add iterator to hashtable and hashtable unit tests
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include<stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef size_t hash_size_t;
|
||||
typedef uint64_t hash_key_t;
|
||||
@@ -54,6 +55,12 @@ typedef struct hash_table_s {
|
||||
void (*freefunc)(void *);
|
||||
} hash_table_t;
|
||||
|
||||
typedef struct hash_table_iterator_s {
|
||||
int index;
|
||||
hash_node_t* node;
|
||||
const hash_table_t* const hashtbl;
|
||||
} hash_table_iterator_s;
|
||||
|
||||
char *hashtable_rc_code2string(hashtable_rc_t rcP);
|
||||
void hash_free_int_func(void *memoryP);
|
||||
hash_table_t *hashtable_create (const hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void *));
|
||||
@@ -63,8 +70,8 @@ hashtable_rc_t hashtable_dump_content (const hash_table_t *const hashtblP, char
|
||||
hashtable_rc_t hashtable_insert (hash_table_t *const hashtbl, const hash_key_t key, void *data);
|
||||
hashtable_rc_t hashtable_remove (hash_table_t *const hashtbl, const hash_key_t key);
|
||||
hashtable_rc_t hashtable_get (const hash_table_t *const hashtbl, const hash_key_t key, void **dataP);
|
||||
|
||||
|
||||
hash_table_iterator_s hashtable_get_iterator(const hash_table_t *const hashtbl);
|
||||
bool hashtable_iterator_getnext(hash_table_iterator_s* iterator, void **dataP);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user