![]() |
GNUnet
0.11.x
|
a version of hash map implemented in container_multihashmap.c but with uint32_t as keys More...
Go to the source code of this file.
Data Structures | |
union | MapEntry |
Entry in the map. More... | |
struct | GNUNET_CONTAINER_MultiHashMap32 |
Internal representation of the hash map. More... | |
struct | GNUNET_CONTAINER_MultiHashMap32Iterator |
Cursor into a multihashmap. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util-container-multihashmap32", __VA_ARGS__) |
#define | NEXT_CACHE_SIZE 16 |
Maximum recursion depth for callbacks of GNUNET_CONTAINER_multihashmap_get_multiple() themselves again calling GNUNET_CONTAINER_multihashmap_get_multiple(). More... | |
Functions | |
struct GNUNET_CONTAINER_MultiHashMap32 * | GNUNET_CONTAINER_multihashmap32_create (unsigned int len) |
Create a multi hash map. More... | |
void | GNUNET_CONTAINER_multihashmap32_destroy (struct GNUNET_CONTAINER_MultiHashMap32 *map) |
Destroy a hash map. More... | |
static unsigned int | idx_of (const struct GNUNET_CONTAINER_MultiHashMap32 *m, const uint32_t key) |
Compute the index of the bucket for the given key. More... | |
unsigned int | GNUNET_CONTAINER_multihashmap32_size (const struct GNUNET_CONTAINER_MultiHashMap32 *map) |
Get the number of key-value pairs in the map. More... | |
void * | GNUNET_CONTAINER_multihashmap32_get (const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key) |
Given a key find a value in the map matching the key. More... | |
int | GNUNET_CONTAINER_multihashmap32_iterate (struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls) |
Iterate over all entries in the map. More... | |
static void | update_next_cache (struct GNUNET_CONTAINER_MultiHashMap32 *map, const struct MapEntry *me) |
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... | |
int | GNUNET_CONTAINER_multihashmap32_remove (struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value) |
Remove the given key-value pair from the map. More... | |
int | GNUNET_CONTAINER_multihashmap32_remove_all (struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key) |
Remove all entries for the given key from the map. More... | |
int | GNUNET_CONTAINER_multihashmap32_contains (const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key) |
Check if the map contains any value under the given key (including values that are NULL). More... | |
int | GNUNET_CONTAINER_multihashmap32_contains_value (const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value) |
Check if the map contains the given value under the given key. More... | |
static void | grow (struct GNUNET_CONTAINER_MultiHashMap32 *map) |
Grow the given map to a more appropriate size. More... | |
int | GNUNET_CONTAINER_multihashmap32_put (struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt) |
Store a key-value pair in the map. More... | |
int | GNUNET_CONTAINER_multihashmap32_get_multiple (struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls) |
Iterate over all entries in the map that match a particular key. More... | |
struct GNUNET_CONTAINER_MultiHashMap32Iterator * | GNUNET_CONTAINER_multihashmap32_iterator_create (const struct GNUNET_CONTAINER_MultiHashMap32 *map) |
Create an iterator for a multihashmap. More... | |
int | GNUNET_CONTAINER_multihashmap32_iterator_next (struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter, uint32_t *key, const void **value) |
Retrieve the next element from the hash map at the iterator's position. More... | |
void | GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiHashMapIterator *iter) |
Destroy a multihashmap iterator. More... | |
a version of hash map implemented in container_multihashmap.c but with uint32_t as keys
Definition in file container_multihashmap32.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util-container-multihashmap32", __VA_ARGS__) |
Definition at line 31 of file container_multihashmap32.c.
#define NEXT_CACHE_SIZE 16 |
Maximum recursion depth for callbacks of GNUNET_CONTAINER_multihashmap_get_multiple() themselves again calling GNUNET_CONTAINER_multihashmap_get_multiple().
Should be totally excessive, but if violated we die.
Definition at line 41 of file container_multihashmap32.c.
|
static |
Compute the index of the bucket for the given key.
m | hash map for which to compute the index |
key | what key should the index be computed for |
Definition at line 191 of file container_multihashmap32.c.
References GNUNET_assert, key, and m.
Referenced by GNUNET_CONTAINER_multihashmap32_contains(), GNUNET_CONTAINER_multihashmap32_contains_value(), GNUNET_CONTAINER_multihashmap32_get(), GNUNET_CONTAINER_multihashmap32_get_multiple(), GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_CONTAINER_multihashmap32_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 294 of file container_multihashmap32.c.
References map, me, GNUNET_CONTAINER_MultiPeerMap::next_cache, and GNUNET_CONTAINER_MultiPeerMap::next_cache_off.
Referenced by GNUNET_CONTAINER_multihashmap32_remove(), and GNUNET_CONTAINER_multihashmap32_remove_all().
|
static |
Grow the given map to a more appropriate size.
map | the hash map to grow |
Definition at line 462 of file container_multihashmap32.c.
References e, GNUNET_free, GNUNET_malloc_large, idx_of(), map, GNUNET_CONTAINER_MultiPeerMap::map, GNUNET_CONTAINER_MultiPeerMap::map_length, and GNUNET_CONTAINER_MultiPeerMap::modification_counter.
Referenced by GNUNET_CONTAINER_multihashmap32_put().
struct GNUNET_CONTAINER_MultiHashMap32Iterator* GNUNET_CONTAINER_multihashmap32_iterator_create | ( | const struct GNUNET_CONTAINER_MultiHashMap32 * | map | ) |
Create an iterator for a multihashmap.
Create an iterator for a 32-bit multihashmap.
The iterator can be used to retrieve all the elements in the multihashmap one by one, without having to handle all elements at once (in contrast to GNUNET_CONTAINER_multihashmap_iterate()). Note that the iterator can not be used anymore if elements have been removed from 'map' after the creation of the iterator, or 'map' has been destroyed. Adding elements to 'map' may result in skipped or repeated elements.
map | the map to create an iterator for |
Definition at line 608 of file container_multihashmap32.c.
References GNUNET_new, map, GNUNET_CONTAINER_MultiHashMap32Iterator::map, GNUNET_CONTAINER_MultiPeerMap::map, GNUNET_CONTAINER_MultiHashMap32Iterator::me, GNUNET_CONTAINER_MultiHashMap32Iterator::modification_counter, and GNUNET_CONTAINER_MultiPeerMap::modification_counter.
int GNUNET_CONTAINER_multihashmap32_iterator_next | ( | struct GNUNET_CONTAINER_MultiHashMap32Iterator * | iter, |
uint32_t * | key, | ||
const void ** | value | ||
) |
Retrieve the next element from the hash map at the iterator's position.
If there are no elements left, GNUNET_NO is returned, and 'key' and 'value' are not modified. This operation is only allowed if no elements have been removed from the multihashmap since the creation of 'iter', and the map has not been destroyed. Adding elements may result in repeating or skipping elements.
iter | the iterator to get the next element from |
key | pointer to store the key in, can be NULL |
value | pointer to store the value in, can be NULL |
Definition at line 636 of file container_multihashmap32.c.
References GNUNET_assert, GNUNET_NO, GNUNET_YES, GNUNET_CONTAINER_MultiHashMap32Iterator::idx, key, MapEntry::key, GNUNET_CONTAINER_MultiHashMap32::map, GNUNET_CONTAINER_MultiHashMap32Iterator::map, GNUNET_CONTAINER_MultiHashMap32::map_length, GNUNET_CONTAINER_MultiHashMap32Iterator::me, GNUNET_CONTAINER_MultiHashMap32::modification_counter, GNUNET_CONTAINER_MultiHashMap32Iterator::modification_counter, MapEntry::next, value, and MapEntry::value.
void GNUNET_CONTAINER_multihashmap32_iterator_destroy | ( | struct GNUNET_CONTAINER_MultiHashMapIterator * | iter | ) |
Destroy a multihashmap iterator.
Destroy a 32-bit multihashmap iterator.
iter | the iterator to destroy |
Definition at line 671 of file container_multihashmap32.c.
References GNUNET_free.