24#define HASH_MAP_DUPLICATE_KEY 1 
   26#define HASH_MAP_ERROR -1 
   38    unsigned int (*hash_func)(
void *);
 
   39    int (*key_cmp_func)(
void *, 
void *);
 
   40    void (*key_free_func)(
void *);
 
   41    void (*value_free_func)(
void *);
 
 
   76                              unsigned int (*hash_func)(
void *),
 
   77                              int (*key_cmp_func)(
void *, 
void *),
 
   78                              void (*key_free_func)(
void *),
 
   79                              void (*value_free_func)(
void *));
 
  127                       void (*fn)(
void *key, 
void *value, 
void *ptr),
 
  137unsigned int hash(
const char *data, 
size_t n);
 
  139unsigned int sstr_key_hash(
void *key);
 
  140int sstr_key_cmp(
void *a, 
void *b);
 
  141void sstr_key_free(
void *key);
 
int hash_map_find(struct hash_map *map, void *key, void **value)
find a entry in hash_map.
Definition hash_map.c:138
 
struct hash_map_entry * hash_map_entry_new(void *key, void *value)
create a new hash_map_entry with key and value.
Definition hash_map.c:9
 
void hash_map_free(struct hash_map *map)
free a hash_map.
Definition hash_map.c:54
 
void hash_map_for_each(struct hash_map *map, void(*fn)(void *key, void *value, void *ptr), void *ptr)
for each key-value pair in hash_map, call fn(key, value).
Definition hash_map.c:172
 
int hash_map_delete(struct hash_map *map, void *key)
remove a entry from hash_map.
Definition hash_map.c:151
 
int hash_map_insert(struct hash_map *map, void *key, void *value)
insert a new entry into hash_map.
Definition hash_map.c:102
 
unsigned int hash(const char *data, size_t n)
calculate the hash value of a key.
Definition hash_map.c:184
 
void hash_map_entry_free(struct hash_map *map, struct hash_map_entry *entry)
free a hash_map_entry. the key and value will be freed by key_free_func and value_free_func of map.
Definition hash_map.c:21
 
struct hash_map * hash_map_new(int bucket_count, unsigned int(*hash_func)(void *), int(*key_cmp_func)(void *, void *), void(*key_free_func)(void *), void(*value_free_func)(void *))
create a new hash_map.
Definition hash_map.c:29
 
sstr_t are objects that represent sequences of characters.