GNUnet  0.19.2
gnunet_container_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2001-2015 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
55 #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
56 #error "Only <gnunet_util_lib.h> can be included directly."
57 #endif
58 
59 #ifndef GNUNET_CONTAINER_LIB_H
60 #define GNUNET_CONTAINER_LIB_H
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #if 0 /* keep Emacsens' auto-indent happy */
65 }
66 #endif
67 #endif
68 
69 
70 /* add error and config prototypes */
71 
72 #include "gnunet_crypto_lib.h"
73 
74 
90 int
91 GNUNET_try_compression (const char *data,
92  size_t old_size,
93  char **result,
94  size_t *new_size);
95 
96 
107 char *
108 GNUNET_decompress (const char *input, size_t input_size, size_t output_size);
109 
110 
111 /* ******************* bloomfilter ***************** */
112 
118 
119 
130  struct GNUNET_HashCode *next);
131 
132 
147  size_t size,
148  unsigned int k);
149 
150 
167  size_t size,
168  unsigned int k);
169 
170 
180 int
182  const struct GNUNET_CONTAINER_BloomFilter *bf,
183  char *data,
184  size_t size);
185 
186 
195 bool
197  const struct GNUNET_CONTAINER_BloomFilter *bf,
198  const struct GNUNET_HashCode *e);
199 
200 
208 void
210  const struct GNUNET_HashCode *e);
211 
212 
220 void
222  const struct GNUNET_HashCode *e);
223 
224 
234  const struct GNUNET_CONTAINER_BloomFilter *bf);
235 
236 
245 void
247 
248 
255 size_t
257  const struct GNUNET_CONTAINER_BloomFilter *bf);
258 
259 
267 size_t
269  const struct GNUNET_CONTAINER_BloomFilter *bf);
270 
271 
278 void
280 
281 
294 int
296  const char *data,
297  size_t size);
298 
299 
310 int
312  struct GNUNET_CONTAINER_BloomFilter *bf,
313  const struct GNUNET_CONTAINER_BloomFilter *to_or);
314 
315 
328 void
331  void *iterator_cls,
332  size_t size,
333  unsigned int k);
334 
335 
336 
337 /* ******************************* HashMap **************************** */
338 
344 
351 
357 {
365 
371 
378 
389 };
390 
391 
403 typedef enum GNUNET_GenericReturnValue
405  void *cls,
406  const struct GNUNET_HashCode *key,
407  void *value);
408 
409 
428  int do_not_copy_keys);
429 
430 
438 void
441 
442 
454 void *
456  const struct GNUNET_CONTAINER_MultiHashMap *map,
457  const struct GNUNET_HashCode *key);
458 
459 
474  const struct GNUNET_HashCode *key,
475  const void *value);
476 
486 int
489  const struct GNUNET_HashCode *key);
490 
491 
500 unsigned int
502 
503 
516  const struct GNUNET_CONTAINER_MultiHashMap *map,
517  const struct GNUNET_HashCode *key);
518 
519 
533  const struct GNUNET_CONTAINER_MultiHashMap *map,
534  const struct GNUNET_HashCode *key,
535  const void *value);
536 
537 
554  const struct GNUNET_HashCode *key,
555  void *value,
557 
565 unsigned int
567  const struct GNUNET_CONTAINER_MultiHashMap *map);
568 
569 
580 int
584  void *it_cls);
585 
586 
602  const struct GNUNET_CONTAINER_MultiHashMap *map);
603 
604 
623  struct GNUNET_HashCode *key,
624  const void **value);
625 
626 
633 void
636 
637 
649 int
652  const struct GNUNET_HashCode *key,
654  void *it_cls);
655 
656 
668 unsigned int
670  const struct GNUNET_CONTAINER_MultiHashMap *map,
672  void *it_cls);
673 
674 
675 /* ***************** Version of Multihashmap for peer identities ****************** */
676 
688 typedef enum GNUNET_GenericReturnValue
690  void *cls,
691  const struct GNUNET_PeerIdentity *key,
692  void *value);
693 
694 
699 
700 
718 GNUNET_CONTAINER_multipeermap_create (unsigned int len, int do_not_copy_keys);
719 
720 
728 void
731 
732 
744 void *
746  const struct GNUNET_CONTAINER_MultiPeerMap *map,
747  const struct GNUNET_PeerIdentity *key);
748 
749 
764  const struct GNUNET_PeerIdentity *key,
765  const void *value);
766 
776 int
779  const struct GNUNET_PeerIdentity *key);
780 
781 
794  const struct GNUNET_CONTAINER_MultiPeerMap *map,
795  const struct GNUNET_PeerIdentity *key);
796 
797 
811  const struct GNUNET_CONTAINER_MultiPeerMap *map,
812  const struct GNUNET_PeerIdentity *key,
813  const void *value);
814 
815 
829 int
832  const struct GNUNET_PeerIdentity *key,
833  void *value,
835 
836 
844 unsigned int
846  const struct GNUNET_CONTAINER_MultiPeerMap *map);
847 
848 
859 int
863  void *it_cls);
864 
865 
882  const struct GNUNET_CONTAINER_MultiPeerMap *map);
883 
884 
906  struct GNUNET_PeerIdentity *key,
907  const void **value);
908 
909 
916 void
919 
920 
932 int
935  const struct GNUNET_PeerIdentity *key,
937  void *it_cls);
938 
939 
951 unsigned int
953  const struct GNUNET_CONTAINER_MultiPeerMap *map,
955  void *it_cls);
956 
957 
958 /* ***************** Version of Multihashmap for short hashes ****************** */
959 
971 typedef enum GNUNET_GenericReturnValue
973  void *cls,
974  const struct GNUNET_ShortHashCode *key,
975  void *value);
976 
977 
982 
983 
1001 GNUNET_CONTAINER_multishortmap_create (unsigned int len, int do_not_copy_keys);
1002 
1003 
1011 void
1014 
1015 
1027 void *
1029  const struct GNUNET_CONTAINER_MultiShortmap *map,
1030  const struct GNUNET_ShortHashCode *key);
1031 
1032 
1045 int
1048  const struct GNUNET_ShortHashCode *key,
1049  const void *value);
1050 
1060 int
1063  const struct GNUNET_ShortHashCode *key);
1064 
1065 
1076 int
1078  const struct GNUNET_CONTAINER_MultiShortmap *map,
1079  const struct GNUNET_ShortHashCode *key);
1080 
1081 
1093 int
1095  const struct GNUNET_CONTAINER_MultiShortmap *map,
1096  const struct GNUNET_ShortHashCode *key,
1097  const void *value);
1098 
1099 
1116  const struct GNUNET_ShortHashCode *key,
1117  void *value,
1119 
1120 
1128 unsigned int
1130  const struct GNUNET_CONTAINER_MultiShortmap *map);
1131 
1132 
1143 int
1147  void *it_cls);
1148 
1149 
1151 
1152 
1168  const struct GNUNET_CONTAINER_MultiShortmap *map);
1169 
1170 
1189  struct GNUNET_ShortHashCode *key,
1190  const void **value);
1191 
1192 
1199 void
1202 
1203 
1215 int
1218  const struct GNUNET_ShortHashCode *key,
1220  void *it_cls);
1221 
1222 
1234 unsigned int
1236  const struct GNUNET_CONTAINER_MultiShortmap *map,
1238  void *it_cls);
1239 
1240 
1241 /* ***************** Version of Multihashmap for UUIDs ****************** */
1242 
1243 
1255 typedef enum GNUNET_GenericReturnValue
1257  void *cls,
1258  const struct GNUNET_Uuid *key,
1259  void *value);
1260 
1261 
1266 
1267 
1285 GNUNET_CONTAINER_multiuuidmap_create (unsigned int len, int do_not_copy_keys);
1286 
1287 
1295 void
1298 
1299 
1311 void *
1313  const struct GNUNET_CONTAINER_MultiUuidmap *map,
1314  const struct GNUNET_Uuid *key);
1315 
1316 
1331  const struct GNUNET_Uuid *key,
1332  const void *value);
1333 
1343 int
1346  const struct GNUNET_Uuid *key);
1347 
1348 
1361  const struct GNUNET_CONTAINER_MultiUuidmap *map,
1362  const struct GNUNET_Uuid *key);
1363 
1364 
1378  const struct GNUNET_CONTAINER_MultiUuidmap *map,
1379  const struct GNUNET_Uuid *key,
1380  const void *value);
1381 
1382 
1399  const struct GNUNET_Uuid *key,
1400  void *value,
1402 
1403 
1411 unsigned int
1413  const struct GNUNET_CONTAINER_MultiUuidmap *map);
1414 
1415 
1426 int
1430  void *it_cls);
1431 
1432 
1434 
1435 
1451  const struct GNUNET_CONTAINER_MultiUuidmap *map);
1452 
1453 
1472  struct GNUNET_Uuid *key,
1473  const void **value);
1474 
1475 
1482 void
1485 
1486 
1498 int
1501  const struct GNUNET_Uuid *key,
1503  void *it_cls);
1504 
1505 
1517 unsigned int
1519  const struct GNUNET_CONTAINER_MultiUuidmap *map,
1521  void *it_cls);
1522 
1523 
1524 /* Version of multihashmap with 32 bit keys */
1525 
1531 
1532 
1539 
1540 
1552 typedef enum GNUNET_GenericReturnValue
1554  void *cls,
1555  uint32_t key,
1556  void *value);
1557 
1558 
1568 
1569 
1577 void
1580 
1581 
1589 unsigned int
1591  const struct GNUNET_CONTAINER_MultiHashMap32 *map);
1592 
1593 
1605 void *
1607  const struct GNUNET_CONTAINER_MultiHashMap32 *map,
1608  uint32_t key);
1609 
1610 
1621 int
1625  void *it_cls);
1626 
1627 
1643  uint32_t key,
1644  const void *value);
1645 
1646 
1656 int
1659  uint32_t key);
1660 
1661 
1674  const struct GNUNET_CONTAINER_MultiHashMap32 *map,
1675  uint32_t key);
1676 
1677 
1691  const struct GNUNET_CONTAINER_MultiHashMap32 *map,
1692  uint32_t key,
1693  const void *value);
1694 
1695 
1712  uint32_t key,
1713  void *value,
1715 
1716 
1728 int
1731  uint32_t key,
1733  void *it_cls);
1734 
1735 
1750  const struct GNUNET_CONTAINER_MultiHashMap32 *map);
1751 
1752 
1770  uint32_t *key,
1771  const void **value);
1772 
1773 
1779 void
1782 
1783 
1784 /* ******************** doubly-linked list *************** */
1785 /* To avoid mistakes: head->prev == tail->next == NULL */
1786 
1796 #define GNUNET_CONTAINER_DLL_insert(head, tail, element) \
1797  do \
1798  { \
1799  GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1800  GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1801  (element)->next = (head); \
1802  (element)->prev = NULL; \
1803  if ((tail) == NULL) \
1804  (tail) = element; \
1805  else \
1806  (head)->prev = element; \
1807  (head) = (element); \
1808  } while (0)
1809 
1810 
1820 #define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element) \
1821  do \
1822  { \
1823  GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1824  GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1825  (element)->prev = (tail); \
1826  (element)->next = NULL; \
1827  if ((head) == NULL) \
1828  (head) = element; \
1829  else \
1830  (tail)->next = element; \
1831  (tail) = (element); \
1832  } while (0)
1833 
1834 
1845 #define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element) \
1846  do \
1847  { \
1848  GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1849  GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1850  (element)->prev = (other); \
1851  if (NULL == other) \
1852  { \
1853  (element)->next = (head); \
1854  (head) = (element); \
1855  } \
1856  else \
1857  { \
1858  (element)->next = (other)->next; \
1859  (other)->next = (element); \
1860  } \
1861  if (NULL == (element)->next) \
1862  (tail) = (element); \
1863  else \
1864  (element)->next->prev = (element); \
1865  } while (0)
1866 
1867 
1878 #define GNUNET_CONTAINER_DLL_insert_before(head, tail, other, element) \
1879  do \
1880  { \
1881  GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
1882  GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
1883  (element)->next = (other); \
1884  if (NULL == other) \
1885  { \
1886  (element)->prev = (tail); \
1887  (tail) = (element); \
1888  } \
1889  else \
1890  { \
1891  (element)->prev = (other)->prev; \
1892  (other)->prev = (element); \
1893  } \
1894  if (NULL == (element)->prev) \
1895  (head) = (element); \
1896  else \
1897  (element)->prev->next = (element); \
1898  } while (0)
1899 
1900 
1915 #define GNUNET_CONTAINER_DLL_remove(head, tail, element) \
1916  do \
1917  { \
1918  GNUNET_assert (((element)->prev != NULL) || ((head) == (element))); \
1919  GNUNET_assert (((element)->next != NULL) || ((tail) == (element))); \
1920  if ((element)->prev == NULL) \
1921  (head) = (element)->next; \
1922  else \
1923  (element)->prev->next = (element)->next; \
1924  if ((element)->next == NULL) \
1925  (tail) = (element)->prev; \
1926  else \
1927  (element)->next->prev = (element)->prev; \
1928  (element)->next = NULL; \
1929  (element)->prev = NULL; \
1930  } while (0)
1931 
1932 
1933 /* ************ Multi-DLL interface, allows DLL elements to be
1934  in multiple lists at the same time *********************** */
1935 
1946 #define GNUNET_CONTAINER_MDLL_insert(mdll, head, tail, element) \
1947  do \
1948  { \
1949  GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
1950  GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
1951  (element)->next_ ## mdll = (head); \
1952  (element)->prev_ ## mdll = NULL; \
1953  if ((tail) == NULL) \
1954  (tail) = element; \
1955  else \
1956  (head)->prev_ ## mdll = element; \
1957  (head) = (element); \
1958  } while (0)
1959 
1960 
1971 #define GNUNET_CONTAINER_MDLL_insert_tail(mdll, head, tail, element) \
1972  do \
1973  { \
1974  GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
1975  GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
1976  (element)->prev_ ## mdll = (tail); \
1977  (element)->next_ ## mdll = NULL; \
1978  if ((head) == NULL) \
1979  (head) = element; \
1980  else \
1981  (tail)->next_ ## mdll = element; \
1982  (tail) = (element); \
1983  } while (0)
1984 
1985 
1997 #define GNUNET_CONTAINER_MDLL_insert_after(mdll, head, tail, other, element) \
1998  do \
1999  { \
2000  GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
2001  GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
2002  (element)->prev_ ## mdll = (other); \
2003  if (NULL == other) \
2004  { \
2005  (element)->next_ ## mdll = (head); \
2006  (head) = (element); \
2007  } \
2008  else \
2009  { \
2010  (element)->next_ ## mdll = (other)->next_ ## mdll; \
2011  (other)->next_ ## mdll = (element); \
2012  } \
2013  if (NULL == (element)->next_ ## mdll) \
2014  (tail) = (element); \
2015  else \
2016  (element)->next_ ## mdll->prev_ ## mdll = (element); \
2017  } while (0)
2018 
2019 
2031 #define GNUNET_CONTAINER_MDLL_insert_before(mdll, head, tail, other, element) \
2032  do \
2033  { \
2034  GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
2035  GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
2036  (element)->next_ ## mdll = (other); \
2037  if (NULL == other) \
2038  { \
2039  (element)->prev = (tail); \
2040  (tail) = (element); \
2041  } \
2042  else \
2043  { \
2044  (element)->prev_ ## mdll = (other)->prev_ ## mdll; \
2045  (other)->prev_ ## mdll = (element); \
2046  } \
2047  if (NULL == (element)->prev_ ## mdll) \
2048  (head) = (element); \
2049  else \
2050  (element)->prev_ ## mdll->next_ ## mdll = (element); \
2051  } while (0)
2052 
2053 
2065 #define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element) \
2066  do \
2067  { \
2068  GNUNET_assert (((element)->prev_ ## mdll != NULL) || ((head) == (element))); \
2069  GNUNET_assert (((element)->next_ ## mdll != NULL) || ((tail) == (element))); \
2070  if ((element)->prev_ ## mdll == NULL) \
2071  (head) = (element)->next_ ## mdll; \
2072  else \
2073  (element)->prev_ ## mdll->next_ ## mdll = (element)->next_ ## mdll; \
2074  if ((element)->next_ ## mdll == NULL) \
2075  (tail) = (element)->prev_ ## mdll; \
2076  else \
2077  (element)->next_ ## mdll->prev_ ## mdll = (element)->prev_ ## mdll; \
2078  (element)->next_ ## mdll = NULL; \
2079  (element)->prev_ ## mdll = NULL; \
2080  } while (0)
2081 
2082 
2096 #define GNUNET_CONTAINER_DLL_insert_sorted(TYPE, \
2097  comparator, \
2098  comparator_cls, \
2099  head, \
2100  tail, \
2101  element) \
2102  do \
2103  { \
2104  if ((NULL == head) || (0 < comparator (comparator_cls, element, head))) \
2105  { \
2106  /* insert at head, element < head */ \
2107  GNUNET_CONTAINER_DLL_insert (head, tail, element); \
2108  } \
2109  else \
2110  { \
2111  TYPE *pos; \
2112  \
2113  for (pos = head; NULL != pos; pos = pos->next) \
2114  if (0 < comparator (comparator_cls, element, pos)) \
2115  break; /* element < pos */ \
2116  if (NULL == pos) /* => element > tail */ \
2117  { \
2118  GNUNET_CONTAINER_DLL_insert_tail (head, tail, element); \
2119  } \
2120  else /* prev < element < pos */ \
2121  { \
2122  GNUNET_CONTAINER_DLL_insert_after (head, tail, pos->prev, element); \
2123  } \
2124  } \
2125  } while (0)
2126 
2127 
2128 /* ******************** Heap *************** */
2129 
2130 
2136 
2137 
2143 {
2149 
2155 };
2156 
2157 
2162 struct GNUNET_CONTAINER_Heap;
2163 
2164 
2170 
2171 
2179 struct GNUNET_CONTAINER_Heap *
2181 
2182 
2190 void
2192 
2193 
2201 void *
2203 
2204 
2216  void **element,
2218 
2219 
2227 unsigned int
2229 
2230 
2240  const struct GNUNET_CONTAINER_HeapNode *node);
2241 
2242 
2254 typedef enum GNUNET_GenericReturnValue
2256  void *cls,
2257  struct GNUNET_CONTAINER_HeapNode *node,
2258  void *element,
2260 
2261 
2270 void
2273  void *iterator_cls);
2274 
2287 void *
2289 
2290 
2302  void *element,
2304 
2305 
2313 void *
2315 
2316 
2324 void *
2326 
2327 
2335 void
2338 
2339 
2340 #if 0 /* keep Emacsens' auto-indent happy */
2341 {
2342 #endif
2343 #ifdef __cplusplus
2344 }
2345 #endif
2346 
2347 
2348 /* ifndef GNUNET_CONTAINER_LIB_H */
2349 #endif
2350  /* end of group addition */
2352 
2353 /* end of gnunet_container_lib.h */
static struct Experiment * e
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
struct GNUNET_HashCode key
The key used in the DHT.
static char * filename
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * value
Value of the record to add/remove.
static int result
Global testing status.
cryptographic primitives for GNUnet
int GNUNET_CONTAINER_bloomfilter_or(struct GNUNET_CONTAINER_BloomFilter *bf, const char *data, size_t size)
"or" the entries of the given raw data array with the data of the given Bloom filter.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_load(const char *filename, size_t size, unsigned int k)
Load a Bloom filter from a file.
int GNUNET_CONTAINER_bloomfilter_get_raw_data(const struct GNUNET_CONTAINER_BloomFilter *bf, char *data, size_t size)
Copy the raw data of this Bloom filter into the given data array.
void GNUNET_CONTAINER_bloomfilter_resize(struct GNUNET_CONTAINER_BloomFilter *bf, GNUNET_CONTAINER_HashCodeIterator iterator, void *iterator_cls, size_t size, unsigned int k)
Resize a bloom filter.
int GNUNET_CONTAINER_bloomfilter_or2(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_CONTAINER_BloomFilter *to_or)
"or" the entries of the given raw data array with the data of the given Bloom filter.
void GNUNET_CONTAINER_bloomfilter_add(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Add an element to the filter.
bool GNUNET_CONTAINER_bloomfilter_test(const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Test if an element is in the filter.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_copy(const struct GNUNET_CONTAINER_BloomFilter *bf)
Create a copy of a bloomfilter.
void GNUNET_CONTAINER_bloomfilter_clear(struct GNUNET_CONTAINER_BloomFilter *bf)
Reset a Bloom filter to empty.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a Bloom filter from raw bits.
int(* GNUNET_CONTAINER_HashCodeIterator)(void *cls, struct GNUNET_HashCode *next)
Iterator over struct GNUNET_HashCode.
size_t GNUNET_CONTAINER_bloomfilter_get_size(const struct GNUNET_CONTAINER_BloomFilter *bf)
Get size of the bloom filter.
void GNUNET_CONTAINER_bloomfilter_remove(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Remove an element from the filter.
void GNUNET_CONTAINER_bloomfilter_free(struct GNUNET_CONTAINER_BloomFilter *bf)
Free the space associated with a filter in memory, flush to drive if needed (do not free the space on...
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_contains_value(const struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key, const void *value)
Check if the map contains the given value under the given key.
unsigned int GNUNET_CONTAINER_multiuuidmap_size(const struct GNUNET_CONTAINER_MultiUuidmap *map)
Get the number of key-value pairs in 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).
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.
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.
int GNUNET_CONTAINER_multiuuidmap_iterate(struct GNUNET_CONTAINER_MultiUuidmap *map, GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_ShortmapIterator)(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
Iterator over hash map entries.
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.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Check if the map contains any value under the given key (including values that are NULL).
struct GNUNET_CONTAINER_MultiUuidmapIterator * GNUNET_CONTAINER_multiuuidmap_iterator_create(const struct GNUNET_CONTAINER_MultiUuidmap *map)
Create an iterator for a multihashmap.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_PeerMapIterator)(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
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.
unsigned int GNUNET_CONTAINER_multiuuidmap_get_random(const struct GNUNET_CONTAINER_MultiUuidmap *map, GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, void *it_cls)
Call it on a random value from the map, or not at all if the map is empty.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_iterator_next(struct GNUNET_CONTAINER_MultiUuidmapIterator *iter, struct GNUNET_Uuid *key, const void **value)
Retrieve the next element from the hash map at the iterator's position.
enum GNUNET_GenericReturnValue 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).
void GNUNET_CONTAINER_multishortmap_iterator_destroy(struct GNUNET_CONTAINER_MultiShortmapIterator *iter)
Destroy a multishortmap iterator.
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.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
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.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains_value(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Check if the map contains the given value under the given key.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
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.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
int GNUNET_CONTAINER_multiuuidmap_remove_all(struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key)
Remove all entries for the given key from the map.
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.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
struct GNUNET_CONTAINER_MultiUuidmap * GNUNET_CONTAINER_multiuuidmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
struct GNUNET_CONTAINER_MultiShortmapIterator * GNUNET_CONTAINER_multishortmap_iterator_create(const struct GNUNET_CONTAINER_MultiShortmap *map)
Create an iterator for a multihashmap.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
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.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMapIterator * GNUNET_CONTAINER_multihashmap_iterator_create(const struct GNUNET_CONTAINER_MultiHashMap *map)
Create an iterator for a multihashmap.
unsigned int GNUNET_CONTAINER_multipeermap_get_random(const struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Call it on a random value from the map, or not at all if the map is empty.
void GNUNET_CONTAINER_multipeermap_iterator_destroy(struct GNUNET_CONTAINER_MultiPeerMapIterator *iter)
Destroy a multipeermap iterator.
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.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_remove(struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key, const void *value)
Remove the given key-value pair from the map.
int GNUNET_CONTAINER_multipeermap_remove_all(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Remove all entries for the given key from the map.
void GNUNET_CONTAINER_multiuuidmap_destroy(struct GNUNET_CONTAINER_MultiUuidmap *map)
Destroy a hash map.
GNUNET_CONTAINER_MultiHashMapOption
Options for storing values in the HashMap.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void * GNUNET_CONTAINER_multiuuidmap_get(const struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key)
Given a key find a value in the map matching the key.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
int GNUNET_CONTAINER_multiuuidmap_get_multiple(struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key, GNUNET_CONTAINER_MultiUuidmapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_MulitHashMapIteratorCallback)(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries.
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.
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.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_contains(const struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key)
Check if the map contains any value under the given key (including values that are NULL).
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.
unsigned int GNUNET_CONTAINER_multihashmap_clear(struct GNUNET_CONTAINER_MultiHashMap *map)
Remove all entries from the map.
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.
void GNUNET_CONTAINER_multihashmap_iterator_destroy(struct GNUNET_CONTAINER_MultiHashMapIterator *iter)
Destroy a multihashmap iterator.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_MultiUuidmapIteratorCallback)(void *cls, const struct GNUNET_Uuid *key, void *value)
Iterator over uuid map entries.
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_multihashmap32_remove_all(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Remove all entries for the given key from the map.
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
unsigned int GNUNET_CONTAINER_multihashmap_get_random(const struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback 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_MultiPeerMapIterator * GNUNET_CONTAINER_multipeermap_iterator_create(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Create an iterator for a multihashmap.
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_MulitHashMapIterator32Callback)(void *cls, uint32_t key, void *value)
Iterator over hash map entries.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multiuuidmap_iterator_destroy(struct GNUNET_CONTAINER_MultiUuidmapIterator *iter)
Destroy a multiuuidmap iterator.
enum GNUNET_GenericReturnValue 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.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
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.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_iterator_next(struct GNUNET_CONTAINER_MultiPeerMapIterator *iter, struct GNUNET_PeerIdentity *key, const void **value)
Retrieve the next element from the hash map at the iterator's position.
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).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multiuuidmap_put(struct GNUNET_CONTAINER_MultiUuidmap *map, const struct GNUNET_Uuid *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
GNUNET_CONTAINER_HeapOrder
Heap type, either max or min.
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
GNUNET_CONTAINER_HeapCostType GNUNET_CONTAINER_heap_node_get_cost(const struct GNUNET_CONTAINER_HeapNode *node)
Get the current cost of the node.
void GNUNET_CONTAINER_heap_update_cost(struct GNUNET_CONTAINER_HeapNode *node, GNUNET_CONTAINER_HeapCostType new_cost)
Updates the cost of any node in the tree.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_HeapIterator)(void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element, GNUNET_CONTAINER_HeapCostType cost)
Iterator for heap.
void * GNUNET_CONTAINER_heap_walk_get_next(struct GNUNET_CONTAINER_Heap *heap)
Perform a random walk of the tree.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
unsigned int GNUNET_CONTAINER_heap_get_size(const struct GNUNET_CONTAINER_Heap *heap)
Get the current size of the heap.
void GNUNET_CONTAINER_heap_iterate(const struct GNUNET_CONTAINER_Heap *heap, GNUNET_CONTAINER_HeapIterator iterator, void *iterator_cls)
Iterate over all entries in the heap.
uint64_t GNUNET_CONTAINER_HeapCostType
Cost by which elements in a heap can be ordered.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
@ GNUNET_CONTAINER_HEAP_ORDER_MIN
Heap with the minimum cost at the root.
@ GNUNET_CONTAINER_HEAP_ORDER_MAX
Heap with the maximum cost at the root.
char * GNUNET_decompress(const char *input, size_t input_size, size_t output_size)
Decompress input, return the decompressed data as output.
Definition: compress.c:70
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_heap_peek2(const struct GNUNET_CONTAINER_Heap *heap, void **element, GNUNET_CONTAINER_HeapCostType *cost)
Get element and cost stored at the root of heap.
enum GNUNET_GenericReturnValue 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.
void GNUNET_CONTAINER_multihashmap32_iterator_destroy(struct GNUNET_CONTAINER_MultiHashMapIterator *iter)
Destroy a 32-bit multihashmap iterator.
struct GNUNET_CONTAINER_MultiHashMap32Iterator * GNUNET_CONTAINER_multihashmap32_iterator_create(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Create an iterator for a 32-bit multihashmap.
int GNUNET_try_compression(const char *data, size_t old_size, char **result, size_t *new_size)
Try to compress the given block of data using libz.
Definition: compress.c:33
size_t GNUNET_CONTAINER_bloomfilter_get_element_addresses(const struct GNUNET_CONTAINER_BloomFilter *bf)
Get the number of the addresses set per element in the bloom filter.
GNUNET_GenericReturnValue
Named constants for return values.
static unsigned int size
Size of the "table".
Definition: peer.c:68
void * element
Our element.
struct GNUNET_CONTAINER_Heap * heap
Heap this node belongs to.
GNUNET_CONTAINER_HeapCostType cost
Cost for this element.
Handle to a node in a heap.
enum GNUNET_CONTAINER_HeapOrder order
How is the heap sorted?
Internal representation of the hash map.
Internal representation of the hash map.
Internal representation of the hash map.
Internal representation of the hash map.
Internal representation of the hash map.
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
A 256-bit hashcode.
A UUID, a 128 bit "random" value.