More W32 resolver workarounds
[oweals/gnunet.git] / src / include / gnunet_container_lib.h
index ad7bb8cc0cca8ce8cffd5e8bdbf2f2dc2d1150cd..4d1f194a3529aa53a15a9a2b879cb42a2a4fa608 100644 (file)
@@ -68,7 +68,8 @@ struct GNUNET_CONTAINER_BloomFilter;
  * @return #GNUNET_YES if next was updated
  *         #GNUNET_NO if there are no more entries
  */
-typedef int (*GNUNET_HashCodeIterator) (void *cls, struct GNUNET_HashCode * next);
+typedef int (*GNUNET_HashCodeIterator) (void *cls,
+                                        struct GNUNET_HashCode *next);
 
 
 /**
@@ -84,7 +85,8 @@ typedef int (*GNUNET_HashCodeIterator) (void *cls, struct GNUNET_HashCode * next
  * @return the bloomfilter
  */
 struct GNUNET_CONTAINER_BloomFilter *
-GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
+GNUNET_CONTAINER_bloomfilter_load (const char *filename,
+                                   size_t size,
                                    unsigned int k);
 
 
@@ -103,7 +105,8 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
  * @return the bloomfilter
  */
 struct GNUNET_CONTAINER_BloomFilter *
-GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size,
+GNUNET_CONTAINER_bloomfilter_init (const char *data,
+                                   size_t size,
                                    unsigned int k);
 
 
@@ -117,8 +120,7 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size,
  * @return #GNUNET_SYSERR if the data array of the wrong size
  */
 int
-GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct
-                                           GNUNET_CONTAINER_BloomFilter *bf,
+GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct GNUNET_CONTAINER_BloomFilter *bf,
                                            char *data, size_t size);
 
 
@@ -131,8 +133,8 @@ GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct
  * @return #GNUNET_YES if the element is in the filter, #GNUNET_NO if not
  */
 int
-GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilter
-                                   *bf, const struct GNUNET_HashCode * e);
+GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilter *bf,
+                                   const struct GNUNET_HashCode *e);
 
 
 /**
@@ -144,7 +146,7 @@ GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilter
  */
 void
 GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter *bf,
-                                  const struct GNUNET_HashCode * e);
+                                  const struct GNUNET_HashCode *e);
 
 
 /**
@@ -156,7 +158,7 @@ GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter *bf,
  */
 void
 GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *bf,
-                                     const struct GNUNET_HashCode * e);
+                                     const struct GNUNET_HashCode *e);
 
 
 /**
@@ -167,8 +169,7 @@ GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *bf,
  * @return copy of bf
  */
 struct GNUNET_CONTAINER_BloomFilter *
-GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter
-                                   *bf);
+GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter *bf);
 
 
 
@@ -184,6 +185,15 @@ void
 GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter *bf);
 
 
+/**
+ * Get the number of the addresses set per element in the bloom filter.
+ *
+ * @param bf the filter
+ * @return addresses set per element in the bf
+ */
+size_t
+GNUNET_CONTAINER_bloomfilter_get_element_addresses (const struct GNUNET_CONTAINER_BloomFilter *bf);
+
 /**
  * @ingroup bloomfilter
  * Get size of the bloom filter.
@@ -192,8 +202,7 @@ GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter *bf);
  * @return number of bytes used for the data of the bloom filter
  */
 size_t
-GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter
-                                       *bf);
+GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter *bf);
 
 
 /**
@@ -235,8 +244,7 @@ GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
  */
 int
 GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf,
-                                  const struct GNUNET_CONTAINER_BloomFilter
-                                  *to_or);
+                                  const struct GNUNET_CONTAINER_BloomFilter *to_or);
 
 /**
  * @ingroup bloomfilter
@@ -308,10 +316,8 @@ GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md);
  * @return #GNUNET_YES if they are equal
  */
 int
-GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData
-                                       *md1,
-                                       const struct GNUNET_CONTAINER_MetaData
-                                       *md2);
+GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData *md1,
+                                       const struct GNUNET_CONTAINER_MetaData *md2);
 
 
 /**
@@ -612,10 +618,10 @@ typedef int (*GNUNET_CONTAINER_HashMapIterator) (void *cls,
  * @param len initial size (map will grow as needed)
  * @param do_not_copy_keys #GNUNET_NO is always safe and should be used by default;
  *                         #GNUNET_YES means that on 'put', the 'key' does not have
- *                         to be copied as the destination of the pointer is 
+ *                         to be copied as the destination of the pointer is
  *                         guaranteed to be life as long as the value is stored in
- *                         the hashmap.  This can significantly reduce memory 
- *                         consumption, but of course is also a recipie for 
+ *                         the hashmap.  This can significantly reduce memory
+ *                         consumption, but of course is also a recipie for
  *                         heap corruption if the assumption is not true.  Only
  *                         use this if (1) memory use is important in this case and
  *                         (2) you have triple-checked that the invariant holds
@@ -634,8 +640,7 @@ GNUNET_CONTAINER_multihashmap_create (unsigned int len,
  * @param map the map
  */
 void
-GNUNET_CONTAINER_multihashmap_destroy (struct GNUNET_CONTAINER_MultiHashMap
-                                       *map);
+GNUNET_CONTAINER_multihashmap_destroy (struct GNUNET_CONTAINER_MultiHashMap *map);
 
 
 /**
@@ -650,8 +655,8 @@ GNUNET_CONTAINER_multihashmap_destroy (struct GNUNET_CONTAINER_MultiHashMap
  *   key-value pairs with value NULL
  */
 void *
-GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap
-                                   *map, const struct GNUNET_HashCode * key);
+GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap *map,
+                                   const struct GNUNET_HashCode *key);
 
 
 /**
@@ -668,7 +673,7 @@ GNUNET_CONTAINER_multihashmap_get (const struct GNUNET_CONTAINER_MultiHashMap
  */
 int
 GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map,
-                                      const struct GNUNET_HashCode * key, 
+                                      const struct GNUNET_HashCode *key,
                                      const void *value);
 
 /**
@@ -681,8 +686,8 @@ GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map,
  * @return number of values removed
  */
 int
-GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap
-                                          *map, const struct GNUNET_HashCode * key);
+GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap *map,
+                                          const struct GNUNET_HashCode *key);
 
 
 /**
@@ -696,8 +701,7 @@ GNUNET_CONTAINER_multihashmap_remove_all (struct GNUNET_CONTAINER_MultiHashMap
  *         #GNUNET_NO if not
  */
 int
-GNUNET_CONTAINER_multihashmap_contains (const struct
-                                        GNUNET_CONTAINER_MultiHashMap *map,
+GNUNET_CONTAINER_multihashmap_contains (const struct GNUNET_CONTAINER_MultiHashMap *map,
                                         const struct GNUNET_HashCode * key);
 
 
@@ -713,9 +717,8 @@ GNUNET_CONTAINER_multihashmap_contains (const struct
  *         #GNUNET_NO if not
  */
 int
-GNUNET_CONTAINER_multihashmap_contains_value (const struct
-                                              GNUNET_CONTAINER_MultiHashMap
-                                              *map, const struct GNUNET_HashCode * key,
+GNUNET_CONTAINER_multihashmap_contains_value (const struct GNUNET_CONTAINER_MultiHashMap *map,
+                                              const struct GNUNET_HashCode *key,
                                               const void *value);
 
 
@@ -729,12 +732,13 @@ GNUNET_CONTAINER_multihashmap_contains_value (const struct
  * @param opt options for put
  * @return #GNUNET_OK on success,
  *         #GNUNET_NO if a value was replaced (with REPLACE)
- *         #GNUNET_SYSERR if UNIQUE_ONLY was the option and the
+ *         #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the
  *                       value already exists
  */
 int
 GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map,
-                                   const struct GNUNET_HashCode * key, void *value,
+                                   const struct GNUNET_HashCode *key,
+                                   void *value,
                                    enum GNUNET_CONTAINER_MultiHashMapOption
                                    opt);
 
@@ -772,7 +776,7 @@ GNUNET_CONTAINER_multihashmap_iterate (const struct
  * Create an iterator for a 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
+ * #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.
@@ -785,7 +789,7 @@ GNUNET_CONTAINER_multihashmap_iterator_create (const struct GNUNET_CONTAINER_Mul
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Retrieve the next element from the hash map at the iterator's
  * position.  If there are no elements left, #GNUNET_NO is returned,
  * and @a key and @a value are not modified.  This operation is only
@@ -801,11 +805,12 @@ GNUNET_CONTAINER_multihashmap_iterator_create (const struct GNUNET_CONTAINER_Mul
  */
 int
 GNUNET_CONTAINER_multihashmap_iterator_next (struct GNUNET_CONTAINER_MultiHashMapIterator *iter,
-                                             struct GNUNET_HashCode *key, const void **value);
+                                             struct GNUNET_HashCode *key,
+                                             const void **value);
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Destroy a multihashmap iterator.
  *
  * @param iter the iterator to destroy
@@ -815,7 +820,7 @@ GNUNET_CONTAINER_multihashmap_iterator_destroy (struct GNUNET_CONTAINER_MultiHas
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Iterate over all entries in the map that match a particular key.
  *
  * @param map the map
@@ -832,17 +837,269 @@ GNUNET_CONTAINER_multihashmap_get_multiple (const struct
                                             GNUNET_CONTAINER_HashMapIterator it,
                                             void *it_cls);
 
+
+/* ***************** Version of Multihashmap for peer identities ****************** */
+
+/**
+ * @ingroup hashmap
+ * Iterator over hash map entries.
+ *
+ * @param cls closure
+ * @param key current public key
+ * @param value value in the hash map
+ * @return #GNUNET_YES if we should continue to
+ *         iterate,
+ *         #GNUNET_NO if not.
+ */
+typedef int (*GNUNET_CONTAINER_PeerMapIterator) (void *cls,
+                                                 const struct GNUNET_PeerIdentity *key,
+                                                 void *value);
+
+
+/**
+ * @ingroup hashmap
+ * Create a multi peer map (hash map for public keys of peers).
+ *
+ * @param len initial size (map will grow as needed)
+ * @param do_not_copy_keys #GNUNET_NO is always safe and should be used by default;
+ *                         #GNUNET_YES means that on 'put', the 'key' does not have
+ *                         to be copied as the destination of the pointer is
+ *                         guaranteed to be life as long as the value is stored in
+ *                         the hashmap.  This can significantly reduce memory
+ *                         consumption, but of course is also a recipie for
+ *                         heap corruption if the assumption is not true.  Only
+ *                         use this if (1) memory use is important in this case and
+ *                         (2) you have triple-checked that the invariant holds
+ * @return NULL on error
+ */
+struct GNUNET_CONTAINER_MultiPeerMap *
+GNUNET_CONTAINER_multipeermap_create (unsigned int len,
+                                     int do_not_copy_keys);
+
+
+/**
+ * @ingroup hashmap
+ * Destroy a hash map.  Will not free any values
+ * stored in the hash map!
+ *
+ * @param map the map
+ */
+void
+GNUNET_CONTAINER_multipeermap_destroy (struct GNUNET_CONTAINER_MultiPeerMap *map);
+
+
+/**
+ * @ingroup hashmap
+ * Given a key find a value in the map matching the key.
+ *
+ * @param map the map
+ * @param key what to look for
+ * @return NULL if no value was found; note that
+ *   this is indistinguishable from values that just
+ *   happen to be NULL; use "contains" to test for
+ *   key-value pairs with value NULL
+ */
+void *
+GNUNET_CONTAINER_multipeermap_get (const struct GNUNET_CONTAINER_MultiPeerMap *map,
+                                   const struct GNUNET_PeerIdentity *key);
+
+
+/**
+ * @ingroup hashmap
+ * Remove the given key-value pair from the map.  Note that if the
+ * key-value pair is in the map multiple times, only one of the pairs
+ * will be removed.
+ *
+ * @param map the map
+ * @param key key of the key-value pair
+ * @param value value of the key-value pair
+ * @return #GNUNET_YES on success, #GNUNET_NO if the key-value pair
+ *  is not in the map
+ */
+int
+GNUNET_CONTAINER_multipeermap_remove (struct GNUNET_CONTAINER_MultiPeerMap *map,
+                                      const struct GNUNET_PeerIdentity * key,
+                                     const void *value);
+
+/**
+ * @ingroup hashmap
+ * Remove all entries for the given key from the map.
+ * Note that the values would not be "freed".
+ *
+ * @param map the map
+ * @param key identifies values to be removed
+ * @return number of values removed
+ */
+int
+GNUNET_CONTAINER_multipeermap_remove_all (struct GNUNET_CONTAINER_MultiPeerMap *map,
+                                          const struct GNUNET_PeerIdentity *key);
+
+
+/**
+ * @ingroup hashmap
+ * Check if the map contains any value under the given
+ * key (including values that are NULL).
+ *
+ * @param map the map
+ * @param key the key to test if a value exists for it
+ * @return #GNUNET_YES if such a value exists,
+ *         #GNUNET_NO if not
+ */
+int
+GNUNET_CONTAINER_multipeermap_contains (const struct GNUNET_CONTAINER_MultiPeerMap *map,
+                                        const struct GNUNET_PeerIdentity *key);
+
+
+/**
+ * @ingroup hashmap
+ * Check if the map contains the given value under the given
+ * key.
+ *
+ * @param map the map
+ * @param key the key to test if a value exists for it
+ * @param value value to test for
+ * @return #GNUNET_YES if such a value exists,
+ *         #GNUNET_NO if not
+ */
+int
+GNUNET_CONTAINER_multipeermap_contains_value (const struct GNUNET_CONTAINER_MultiPeerMap *map,
+                                              const struct GNUNET_PeerIdentity * key,
+                                              const void *value);
+
+
+/**
+ * @ingroup hashmap
+ * Store a key-value pair in the map.
+ *
+ * @param map the map
+ * @param key key to use
+ * @param value value to use
+ * @param opt options for put
+ * @return #GNUNET_OK on success,
+ *         #GNUNET_NO if a value was replaced (with REPLACE)
+ *         #GNUNET_SYSERR if #GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY was the option and the
+ *                       value already exists
+ */
+int
+GNUNET_CONTAINER_multipeermap_put (struct GNUNET_CONTAINER_MultiPeerMap *map,
+                                   const struct GNUNET_PeerIdentity *key,
+                                   void *value,
+                                   enum GNUNET_CONTAINER_MultiHashMapOption opt);
+
+
+/**
+ * @ingroup hashmap
+ * Get the number of key-value pairs in the map.
+ *
+ * @param map the map
+ * @return the number of key value pairs
+ */
+unsigned int
+GNUNET_CONTAINER_multipeermap_size (const struct GNUNET_CONTAINER_MultiPeerMap *map);
+
+
+/**
+ * @ingroup hashmap
+ * Iterate over all entries in the map.
+ *
+ * @param map the map
+ * @param it function to call on each entry
+ * @param it_cls extra argument to @a it
+ * @return the number of key value pairs processed,
+ *         #GNUNET_SYSERR if it aborted iteration
+ */
+int
+GNUNET_CONTAINER_multipeermap_iterate (const struct GNUNET_CONTAINER_MultiPeerMap *map,
+                                       GNUNET_CONTAINER_PeerMapIterator it,
+                                       void *it_cls);
+
+
+/**
+ * @ingroup hashmap
+ * Create an iterator for a 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_multipeermap_iterate).  Note that the iterator can not be
+ * used anymore if elements have been removed from @a map after the creation of
+ * the iterator, or 'map' has been destroyed.  Adding elements to @a map may
+ * result in skipped or repeated elements.
+ *
+ * @param map the map to create an iterator for
+ * @return an iterator over the given multihashmap @a map
+ */
+struct GNUNET_CONTAINER_MultiPeerMapIterator *
+GNUNET_CONTAINER_multipeermap_iterator_create (const struct GNUNET_CONTAINER_MultiPeerMap *map);
+
+
+/**
+ * @ingroup hashmap
+ * Retrieve the next element from the hash map at the iterator's
+ * position.  If there are no elements left, #GNUNET_NO is returned,
+ * and @a key and @a value are not modified.  This operation is only
+ * allowed if no elements have been removed from the multihashmap
+ * since the creation of @a iter, and the map has not been destroyed.
+ * Adding elements may result in repeating or skipping elements.
+ *
+ * @param iter the iterator to get the next element from
+ * @param key pointer to store the key in, can be NULL
+ * @param value pointer to store the value in, can be NULL
+ * @return #GNUNET_YES we returned an element,
+ *         #GNUNET_NO if we are out of elements
+ */
+int
+GNUNET_CONTAINER_multipeermap_iterator_next (struct GNUNET_CONTAINER_MultiPeerMapIterator *iter,
+                                             struct GNUNET_PeerIdentity *key,
+                                             const void **value);
+
+
+/**
+ * @ingroup hashmap
+ * Destroy a multipeermap iterator.
+ *
+ * @param iter the iterator to destroy
+ */
+void
+GNUNET_CONTAINER_multipeermap_iterator_destroy (struct GNUNET_CONTAINER_MultiPeerMapIterator *iter);
+
+
+/**
+ * @ingroup hashmap
+ * Iterate over all entries in the map that match a particular key.
+ *
+ * @param map the map
+ * @param key public key that the entries must correspond to
+ * @param it function to call on each entry
+ * @param it_cls extra argument to @a it
+ * @return the number of key value pairs processed,
+ *         #GNUNET_SYSERR if it aborted iteration
+ */
+int
+GNUNET_CONTAINER_multipeermap_get_multiple (const struct GNUNET_CONTAINER_MultiPeerMap *map,
+                                            const struct GNUNET_PeerIdentity *key,
+                                            GNUNET_CONTAINER_PeerMapIterator it,
+                                            void *it_cls);
+
+
+
 /* Version of multihashmap with 32 bit keys */
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Opaque handle for the 32-bit key HashMap.
  */
 struct GNUNET_CONTAINER_MultiHashMap32;
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
+ * Opaque handle to an iterator over
+ * a 32-bit key multihashmap.
+ */
+struct GNUNET_CONTAINER_MultiHashMap32Iterator;
+
+
+/**
+ * @ingroup hashmap
  * Iterator over hash map entries.
  *
  * @param cls closure
@@ -858,7 +1115,7 @@ typedef int (*GNUNET_CONTAINER_HashMapIterator32) (void *cls,
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Create a 32-bit key multi hash map.
  *
  * @param len initial size (map will grow as needed)
@@ -869,7 +1126,7 @@ GNUNET_CONTAINER_multihashmap32_create (unsigned int len);
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Destroy a 32-bit key hash map.  Will not free any values
  * stored in the hash map!
  *
@@ -881,7 +1138,7 @@ GNUNET_CONTAINER_multihashmap32_destroy (struct GNUNET_CONTAINER_MultiHashMap32
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Get the number of key-value pairs in the map.
  *
  * @param map the map
@@ -893,7 +1150,7 @@ GNUNET_CONTAINER_multihashmap32_size (const struct
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Given a key find a value in the map matching the key.
  *
  * @param map the map
@@ -904,13 +1161,13 @@ GNUNET_CONTAINER_multihashmap32_size (const struct
  *   key-value pairs with value NULL
  */
 void *
-GNUNET_CONTAINER_multihashmap32_get (const struct 
+GNUNET_CONTAINER_multihashmap32_get (const struct
                                      GNUNET_CONTAINER_MultiHashMap32 *map,
                                      uint32_t key);
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Iterate over all entries in the map.
  *
  * @param map the map
@@ -927,7 +1184,7 @@ GNUNET_CONTAINER_multihashmap32_iterate (const struct
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Remove the given key-value pair from the map.  Note that if the
  * key-value pair is in the map multiple times, only one of the pairs
  * will be removed.
@@ -939,14 +1196,13 @@ GNUNET_CONTAINER_multihashmap32_iterate (const struct
  *  is not in the map
  */
 int
-GNUNET_CONTAINER_multihashmap32_remove (struct GNUNET_CONTAINER_MultiHashMap32
-                                        *map,
-                                        uint32_t key, 
+GNUNET_CONTAINER_multihashmap32_remove (struct GNUNET_CONTAINER_MultiHashMap32 *map,
+                                        uint32_t key,
                                        const void *value);
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Remove all entries for the given key from the map.
  * Note that the values would not be "freed".
  *
@@ -955,14 +1211,12 @@ GNUNET_CONTAINER_multihashmap32_remove (struct GNUNET_CONTAINER_MultiHashMap32
  * @return number of values removed
  */
 int
-GNUNET_CONTAINER_multihashmap32_remove_all (struct
-                                            GNUNET_CONTAINER_MultiHashMap32
-                                            *map,
+GNUNET_CONTAINER_multihashmap32_remove_all (struct GNUNET_CONTAINER_MultiHashMap32 *map,
                                             uint32_t key);
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Check if the map contains any value under the given
  * key (including values that are NULL).
  *
@@ -972,13 +1226,12 @@ GNUNET_CONTAINER_multihashmap32_remove_all (struct
  *         #GNUNET_NO if not
  */
 int
-GNUNET_CONTAINER_multihashmap32_contains (const struct
-                                          GNUNET_CONTAINER_MultiHashMap32 *map,
+GNUNET_CONTAINER_multihashmap32_contains (const struct GNUNET_CONTAINER_MultiHashMap32 *map,
                                           uint32_t key);
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Check if the map contains the given value under the given
  * key.
  *
@@ -989,15 +1242,13 @@ GNUNET_CONTAINER_multihashmap32_contains (const struct
  *         #GNUNET_NO if not
  */
 int
-GNUNET_CONTAINER_multihashmap32_contains_value (const struct
-                                                GNUNET_CONTAINER_MultiHashMap32
-                                                *map, 
+GNUNET_CONTAINER_multihashmap32_contains_value (const struct GNUNET_CONTAINER_MultiHashMap32 *map,
                                                 uint32_t key,
                                                 const void *value);
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Store a key-value pair in the map.
  *
  * @param map the map
@@ -1010,14 +1261,14 @@ GNUNET_CONTAINER_multihashmap32_contains_value (const struct
  *                       value already exists
  */
 int
-GNUNET_CONTAINER_multihashmap32_put (struct GNUNET_CONTAINER_MultiHashMap32
-                                     *map, uint32_t key, void *value,
-                                     enum GNUNET_CONTAINER_MultiHashMapOption
-                                     opt);
+GNUNET_CONTAINER_multihashmap32_put (struct GNUNET_CONTAINER_MultiHashMap32 *map,
+                                     uint32_t key,
+                                     void *value,
+                                     enum GNUNET_CONTAINER_MultiHashMapOption opt);
 
 
 /**
- * @ingroup hashmap 
+ * @ingroup hashmap
  * Iterate over all entries in the map that match a particular key.
  *
  * @param map the map
@@ -1028,20 +1279,62 @@ GNUNET_CONTAINER_multihashmap32_put (struct GNUNET_CONTAINER_MultiHashMap32
  *         #GNUNET_SYSERR if it aborted iteration
  */
 int
-GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
-                                              GNUNET_CONTAINER_MultiHashMap32
-                                              *map, uint32_t key,
-                                              GNUNET_CONTAINER_HashMapIterator32 
-                                              it, void *it_cls);
+GNUNET_CONTAINER_multihashmap32_get_multiple (const struct GNUNET_CONTAINER_MultiHashMap32 *map,
+                                              uint32_t key,
+                                              GNUNET_CONTAINER_HashMapIterator32 it,
+                                              void *it_cls);
+
+
+/**
+ * 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_multihashmap32_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.
+ *
+ * @param map the map to create an iterator for
+ * @return an iterator over the given multihashmap map
+ */
+struct GNUNET_CONTAINER_MultiHashMap32Iterator *
+GNUNET_CONTAINER_multihashmap32_iterator_create (const struct GNUNET_CONTAINER_MultiHashMap32 *map);
+
+
+/**
+ * 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.
+ *
+ * @param iter the iterator to get the next element from
+ * @param key pointer to store the key in, can be NULL
+ * @param value pointer to store the value in, can be NULL
+ * @return #GNUNET_YES we returned an element,
+ *         #GNUNET_NO if we are out of elements
+ */
+int
+GNUNET_CONTAINER_multihashmap32_iterator_next (struct GNUNET_CONTAINER_MultiHashMap32Iterator *iter,
+                                               uint32_t *key,
+                                               const void **value);
 
 
+/**
+ * Destroy a 32-bit multihashmap iterator.
+ *
+ * @param iter the iterator to destroy
+ */
+void
+GNUNET_CONTAINER_multihashmap32_iterator_destroy (struct GNUNET_CONTAINER_MultiHashMapIterator *iter);
 
 
 /* ******************** doubly-linked list *************** */
 /* To avoid mistakes: head->prev == tail->next == NULL     */
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Insert an element at the head of a DLL. Assumes that head, tail and
  * element are structs with prev and next fields.
  *
@@ -1062,7 +1355,7 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
 
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Insert an element at the tail of a DLL. Assumes that head, tail and
  * element are structs with prev and next fields.
  *
@@ -1083,7 +1376,7 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
 
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Insert an element into a DLL after the given other element.  Insert
  * at the head if the other element is NULL.
  *
@@ -1113,7 +1406,7 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
 
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Insert an element into a DLL before the given other element.  Insert
  * at the tail if the other element is NULL.
  *
@@ -1143,7 +1436,7 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
 
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Remove an element from a DLL. Assumes that head, tail and
  * element point to structs with prev and next fields.
  *
@@ -1175,7 +1468,7 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
    in multiple lists at the same time *********************** */
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Insert an element at the head of a MDLL. Assumes that head, tail and
  * element are structs with prev and next fields.
  *
@@ -1197,7 +1490,7 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
 
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Insert an element at the tail of a MDLL. Assumes that head, tail and
  * element are structs with prev and next fields.
  *
@@ -1219,7 +1512,7 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
 
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Insert an element into a MDLL after the given other element.  Insert
  * at the head if the other element is NULL.
  *
@@ -1250,7 +1543,7 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
 
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Insert an element into a MDLL before the given other element.  Insert
  * at the tail if the other element is NULL.
  *
@@ -1281,7 +1574,7 @@ GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
 
 
 /**
- * @ingroup dll 
+ * @ingroup dll
  * Remove an element from a MDLL. Assumes
  * that head, tail and element are structs
  * with prev and next fields.