hash map where the same key may be present multiple times More...
Go to the source code of this file.
| Data Structures | |
| struct | BigMapEntry | 
| An entry in the hash map with the full key.  More... | |
| struct | SmallMapEntry | 
| An entry in the hash map with just a pointer to the key.  More... | |
| union | MapEntry | 
| Entry in the map.  More... | |
| struct | GNUNET_CONTAINER_MultiHashMap | 
| Internal representation of the hash map.  More... | |
| struct | GNUNET_CONTAINER_MultiHashMapIterator | 
| Cursor into a multihashmap.  More... | |
| Macros | |
| #define | LOG(kind, ...) GNUNET_log_from (kind, "util-container-multihashmap", __VA_ARGS__) | 
| #define | NEXT_CACHE_SIZE 16 | 
| Maximum recursion depth for callbacks of GNUNET_CONTAINER_multihashmap_get_multiple() themselves s again calling GNUNET_CONTAINER_multihashmap_get_multiple(). | |
| Functions | |
| struct GNUNET_CONTAINER_MultiHashMap * | GNUNET_CONTAINER_multihashmap_create (unsigned int len, int do_not_copy_keys) | 
| Create a multi hash map. | |
| void | GNUNET_CONTAINER_multihashmap_destroy (struct GNUNET_CONTAINER_MultiHashMap *map) | 
| Destroy a hash map. | |
| static unsigned int | idx_of (const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key) | 
| Compute the index of the bucket for the given key. | |
| unsigned int | GNUNET_CONTAINER_multihashmap_size (const struct GNUNET_CONTAINER_MultiHashMap *map) | 
| Get the number of key-value pairs in the map. | |
| void * | GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key) | 
| Given a key find a value in the map matching the key. | |
| int | GNUNET_CONTAINER_multihashmap_iterate (struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls) | 
| Iterate over all entries in the map. | |
| static void | update_next_cache_bme (struct GNUNET_CONTAINER_MultiHashMap *map, const struct BigMapEntry *bme) | 
| We are about to free() the bme, make sure it is not in the list of next values for any iterator in the map's next_cache. | |
| static void | update_next_cache_sme (struct GNUNET_CONTAINER_MultiHashMap *map, const struct SmallMapEntry *sme) | 
| We are about to free() the sme, make sure it is not in the list of next values for any iterator in the map's next_cache. | |
| enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value) | 
| Remove the given key-value pair from the map. | |
| int | GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key) | 
| Remove all entries for the given key from the map. | |
| static int | remove_all (void *cls, const struct GNUNET_HashCode *key, void *value) | 
| Callback used to remove all entries from the map. | |
| unsigned int | GNUNET_CONTAINER_multihashmap_clear (struct GNUNET_CONTAINER_MultiHashMap *map) | 
| Remove all entries from the map. | |
| enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_multihashmap_contains (const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key) | 
| Check if the map contains any value under the given key (including values that are NULL). | |
| enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_multihashmap_contains_value (const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value) | 
| Check if the map contains the given value under the given key. | |
| static void | grow (struct GNUNET_CONTAINER_MultiHashMap *map) | 
| Grow the given map to a more appropriate size. | |
| enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt) | 
| Store a key-value pair in the map. | |
| enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_multihashmap_get_multiple (struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls) | 
| Iterate over all entries in the map that match a particular key. | |
| unsigned int | GNUNET_CONTAINER_multihashmap_get_random (const struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls) | 
| Call it on a random value from the map, or not at all if the map is empty. | |
| struct GNUNET_CONTAINER_MultiHashMapIterator * | GNUNET_CONTAINER_multihashmap_iterator_create (const struct GNUNET_CONTAINER_MultiHashMap *map) | 
| Create an iterator for a multihashmap. | |
| enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_multihashmap_iterator_next (struct GNUNET_CONTAINER_MultiHashMapIterator *iter, struct GNUNET_HashCode *key, const void **value) | 
| Retrieve the next element from the hash map at the iterator's position. | |
| void | GNUNET_CONTAINER_multihashmap_iterator_destroy (struct GNUNET_CONTAINER_MultiHashMapIterator *iter) | 
| Destroy a multihashmap iterator. | |
hash map where the same key may be present multiple times
Definition in file container_multihashmap.c.
| #define LOG | ( | kind, | |
| ... | |||
| ) | GNUNET_log_from (kind, "util-container-multihashmap", __VA_ARGS__) | 
Definition at line 30 of file container_multihashmap.c.
| #define NEXT_CACHE_SIZE 16 | 
Maximum recursion depth for callbacks of GNUNET_CONTAINER_multihashmap_get_multiple() themselves s again calling GNUNET_CONTAINER_multihashmap_get_multiple().
Should be totally excessive, but if violated we die.
Definition at line 39 of file container_multihashmap.c.
| 
 | static | 
Compute the index of the bucket for the given key.
| map | hash map for which to compute the index | 
| key | what key should the index be computed for | 
Definition at line 264 of file container_multihashmap.c.
References GNUNET_assert, key, map, and GNUNET_CONTAINER_MultiPeerMap::map_length.
Referenced by GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_contains_value(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_remove_all(), and grow().
| 
 | static | 
We are about to free() the bme, make sure it is not in the list of next values for any iterator in the map's next_cache.
| map | the map to check | 
| bme | the entry that is about to be free'd | 
Definition at line 379 of file container_multihashmap.c.
References MapEntry::bme, map, BigMapEntry::next, GNUNET_CONTAINER_MultiPeerMap::next_cache, and GNUNET_CONTAINER_MultiPeerMap::next_cache_off.
Referenced by GNUNET_CONTAINER_multihashmap_remove(), and GNUNET_CONTAINER_multihashmap_remove_all().
| 
 | static | 
We are about to free() the sme, make sure it is not in the list of next values for any iterator in the map's next_cache.
| map | the map to check | 
| sme | the entry that is about to be free'd | 
Definition at line 396 of file container_multihashmap.c.
References map, SmallMapEntry::next, GNUNET_CONTAINER_MultiPeerMap::next_cache, GNUNET_CONTAINER_MultiPeerMap::next_cache_off, and MapEntry::sme.
Referenced by GNUNET_CONTAINER_multihashmap_remove(), and GNUNET_CONTAINER_multihashmap_remove_all().
| 
 | static | 
Callback used to remove all entries from the map.
| cls | the struct GNUNET_CONTAINER_MultiHashMap | 
| key | the key | 
| value | the value | 
Definition at line 552 of file container_multihashmap.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_OK, GNUNET_YES, key, map, and value.
Referenced by GNUNET_CONTAINER_multihashmap_clear().
| 
 | static | 
Grow the given map to a more appropriate size.
| map | the hash map to grow | 
Definition at line 644 of file container_multihashmap.c.
References MapEntry::bme, GNUNET_assert, GNUNET_free, GNUNET_malloc_large, idx_of(), BigMapEntry::key, SmallMapEntry::key, GNUNET_CONTAINER_MultiPeerMap::map, map, GNUNET_CONTAINER_MultiPeerMap::map_length, GNUNET_CONTAINER_MultiPeerMap::modification_counter, BigMapEntry::next, SmallMapEntry::next, MapEntry::sme, and GNUNET_CONTAINER_MultiPeerMap::use_small_entries.
Referenced by GNUNET_CONTAINER_multihashmap_put().