00001 #ifdef __cplusplus
00002 extern "C" {
00003 #endif
00004
00005 #ifndef CDSA_HASHTABLE_H
00006 #define CDSA_HASHTABLE_H
00007
00008 #include <stdlib.h>
00009 #include <stdbool.h>
00010
00011 #include "cdsa_types.h"
00012
00038 #define DEFAULT_HASHTABLE_CAPACITY 16
00039
00047 #define DEFAULT_LOAD_FACTOR 0.75
00048
00054 typedef struct HashTable HashTable;
00055 struct HashTable;
00056
00076 cdsa_status_t ht_new(HashTable **new_ht, size_t initial_capacity, float load_factor,
00077 size_t key_size, cdsa_compare_func_t compare,
00078 cdsa_destroy_map_func_t destroy);
00079
00087 cdsa_status_t ht_destroy(HashTable **ht);
00088
00098 cdsa_status_t ht_is_empty(const HashTable *const ht, bool *is_empty);
00099
00109 cdsa_status_t ht_size(const HashTable *const ht, size_t *size);
00110
00120 cdsa_status_t ht_capacity(const HashTable *const ht, size_t *capacity);
00121
00133 cdsa_status_t ht_has_key(const HashTable *const ht, const void *const key, bool *has_key);
00134
00150 cdsa_status_t ht_get(const HashTable *const ht, const void *const key, void *ptr);
00151
00168 cdsa_status_t ht_put(HashTable *const ht, const void *const key, void *const value, void *prev_val);
00169
00186 cdsa_status_t ht_remove(HashTable *const ht, const void *const key, void *prev_val);
00187
00188
00189 #ifdef __cplusplus
00190 }
00191 #endif
00192
00193 #endif