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_MultiShortmap |
Internal representation of the hash map. More... | |
struct | GNUNET_CONTAINER_MultiShortmapIterator |
Cursor into a multishortmap. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util-container-multishortmap", __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(). More... | |
Functions | |
struct GNUNET_CONTAINER_MultiShortmap * | GNUNET_CONTAINER_multishortmap_create (unsigned int len, int do_not_copy_keys) |
Create a multi hash map. More... | |
void | GNUNET_CONTAINER_multishortmap_destroy (struct GNUNET_CONTAINER_MultiShortmap *map) |
Destroy a hash map. More... | |
static unsigned int | idx_of (const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key) |
Compute the index of the bucket for the given key. More... | |
unsigned int | GNUNET_CONTAINER_multishortmap_size (const struct GNUNET_CONTAINER_MultiShortmap *map) |
Get the number of key-value pairs in the map. More... | |
void * | GNUNET_CONTAINER_multishortmap_get (const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key) |
Given a key find a value in the map matching the key. More... | |
int | GNUNET_CONTAINER_multishortmap_iterate (struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls) |
Iterate over all entries in the map. More... | |
static void | update_next_cache_bme (struct GNUNET_CONTAINER_MultiShortmap *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. More... | |
static void | update_next_cache_sme (struct GNUNET_CONTAINER_MultiShortmap *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. More... | |
int | GNUNET_CONTAINER_multishortmap_remove (struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value) |
Remove the given key-value pair from the map. More... | |
int | GNUNET_CONTAINER_multishortmap_remove_all (struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key) |
Remove all entries for the given key from the map. More... | |
int | GNUNET_CONTAINER_multishortmap_contains (const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key) |
Check if the map contains any value under the given key (including values that are NULL). More... | |
int | GNUNET_CONTAINER_multishortmap_contains_value (const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value) |
Check if the map contains the given value under the given key. More... | |
static void | grow (struct GNUNET_CONTAINER_MultiShortmap *map) |
Grow the given map to a more appropriate size. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_multishortmap_put (struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt) |
Store a key-value pair in the map. More... | |
int | GNUNET_CONTAINER_multishortmap_get_multiple (struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls) |
Iterate over all entries in the map that match a particular key. More... | |
unsigned int | GNUNET_CONTAINER_multishortmap_get_random (const struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls) |
Call it on a random value from the map, or not at all if the map is empty. More... | |
struct GNUNET_CONTAINER_MultiShortmapIterator * | GNUNET_CONTAINER_multishortmap_iterator_create (const struct GNUNET_CONTAINER_MultiShortmap *map) |
Create an iterator for a multihashmap. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_multishortmap_iterator_next (struct GNUNET_CONTAINER_MultiShortmapIterator *iter, struct GNUNET_ShortHashCode *key, const void **value) |
Retrieve the next element from the hash map at the iterator's position. More... | |
void | GNUNET_CONTAINER_multishortmap_iterator_destroy (struct GNUNET_CONTAINER_MultiShortmapIterator *iter) |
Destroy a multishortmap iterator. More... | |
hash map where the same key may be present multiple times
Definition in file container_multishortmap.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util-container-multishortmap", __VA_ARGS__) |
Definition at line 30 of file container_multishortmap.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_multishortmap.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 263 of file container_multishortmap.c.
References GNUNET_assert, GNUNET_memcpy, key, map, and GNUNET_CONTAINER_MultiPeerMap::map_length.
Referenced by GNUNET_CONTAINER_multishortmap_contains(), GNUNET_CONTAINER_multishortmap_contains_value(), GNUNET_CONTAINER_multishortmap_get(), GNUNET_CONTAINER_multishortmap_get_multiple(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_CONTAINER_multishortmap_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 374 of file container_multishortmap.c.
References MapEntry::bme, map, BigMapEntry::next, GNUNET_CONTAINER_MultiPeerMap::next_cache, and GNUNET_CONTAINER_MultiPeerMap::next_cache_off.
Referenced by GNUNET_CONTAINER_multishortmap_remove(), and GNUNET_CONTAINER_multishortmap_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 391 of file container_multishortmap.c.
References map, SmallMapEntry::next, GNUNET_CONTAINER_MultiPeerMap::next_cache, GNUNET_CONTAINER_MultiPeerMap::next_cache_off, and MapEntry::sme.
Referenced by GNUNET_CONTAINER_multishortmap_remove(), and GNUNET_CONTAINER_multishortmap_remove_all().
|
static |
Grow the given map to a more appropriate size.
map | the hash map to grow |
Definition at line 591 of file container_multishortmap.c.
References MapEntry::bme, 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_multishortmap_put().