X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=hashmap.h;h=ae7f74bc0494b9a6dc4b3aaf35387db2b0d24741;hp=4c946e35b9d53972df6f3bef996a1f0b39b34a99;hb=3158713e0094fd32f58ee80c50ff54210c2dc411;hpb=6091827530d6dd43479d6709fb6e9f745c11e900 diff --git a/hashmap.h b/hashmap.h index 4c946e35b..ae7f74bc0 100644 --- a/hashmap.h +++ b/hashmap.h @@ -22,11 +22,16 @@ unsigned trivial_hash_func(const void *p); int trivial_compare_func(const void *a, const void *b); Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func); -void hashmap_free(Hashmap*); +void hashmap_free(Hashmap *h); +Hashmap *hashmap_copy(Hashmap *h); int hashmap_put(Hashmap *h, const void *key, void *value); +int hashmap_replace(Hashmap *h, const void *key, void *value); void* hashmap_get(Hashmap *h, const void *key); void* hashmap_remove(Hashmap *h, const void *key); +void* hashmap_remove_value(Hashmap *h, const void *key, void *value); + +int hashmap_merge(Hashmap *h, Hashmap *other); unsigned hashmap_size(Hashmap *h); bool hashmap_isempty(Hashmap *h); @@ -34,6 +39,7 @@ bool hashmap_isempty(Hashmap *h); void *hashmap_iterate(Hashmap *h, void **state, const void **key); void *hashmap_iterate_backwards(Hashmap *h, void **state, const void **key); +void hashmap_clear(Hashmap *h); void *hashmap_steal_first(Hashmap *h); void* hashmap_first(Hashmap *h); void* hashmap_last(Hashmap *h); @@ -41,6 +47,9 @@ void* hashmap_last(Hashmap *h); #define HASHMAP_FOREACH(e, h, state) \ for ((state) = NULL, (e) = hashmap_iterate((h), &(state), NULL); (e); (e) = hashmap_iterate((h), &(state), NULL)) +#define HASHMAP_FOREACH_KEY(e, k, h, state) \ + for ((state) = NULL, (e) = hashmap_iterate((h), &(state), (const void**) &(k)); (e); (e) = hashmap_iterate((h), &(state), (const void**) &(k))) + #define HASHMAP_FOREACH_BACKWARDS(e, h, state) \ for ((state) = NULL, (e) = hashmap_iterate_backwards((h), &(state), NULL); (e); (e) = hashmap_iterate_backwards((h), &(state), NULL))