GNUnet 0.24.1-15-gab6ed22f1
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#include "gnunet_common.h"
56#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
57#error "Only <gnunet_util_lib.h> can be included directly."
58#endif
59
60#ifndef GNUNET_CONTAINER_LIB_H
61#define GNUNET_CONTAINER_LIB_H
62
63#ifdef __cplusplus
64extern "C" {
65#if 0 /* keep Emacsens' auto-indent happy */
66}
67#endif
68#endif
69
70
71/* add error and config prototypes */
72
73#include "gnunet_crypto_lib.h"
74
75
91int
92GNUNET_try_compression (const char *data,
93 size_t old_size,
94 char **result,
95 size_t *new_size);
96
97
108char *
109GNUNET_decompress (const char *input, size_t input_size, size_t output_size);
110
111
112/* ******************* bloomfilter ***************** */
113
119
120
130typedef int (*GNUNET_CONTAINER_HashCodeIterator) (void *cls,
131 struct GNUNET_HashCode *next);
132
133
148 size_t size,
149 unsigned int k);
150
151
168 size_t size,
169 unsigned int k);
170
171
183 const struct GNUNET_CONTAINER_BloomFilter *bf,
184 char *data,
185 size_t size);
186
187
196bool
198 const struct GNUNET_CONTAINER_BloomFilter *bf,
199 const struct GNUNET_HashCode *e);
200
201
209void
211 const struct GNUNET_HashCode *e);
212
213
221void
223 const struct GNUNET_HashCode *e);
224
225
235 const struct GNUNET_CONTAINER_BloomFilter *bf);
236
237
246void
248
249
256size_t
258 const struct GNUNET_CONTAINER_BloomFilter *bf);
259
260
268size_t
270 const struct GNUNET_CONTAINER_BloomFilter *bf);
271
272
279void
281
282
297 const char *data,
298 size_t size);
299
300
314 const struct GNUNET_CONTAINER_BloomFilter *to_or);
315
316
329void
332 void *iterator_cls,
333 size_t size,
334 unsigned int k);
335
336
337
338/* ******************************* HashMap **************************** */
339
345
352
358{
366
372
379
391
392
404typedef enum GNUNET_GenericReturnValue
406 void *cls,
407 const struct GNUNET_HashCode *key,
408 void *value);
409
410
429 int do_not_copy_keys);
430
431
439void
442
443
455void *
458 const struct GNUNET_HashCode *key);
459
460
475 const struct GNUNET_HashCode *key,
476 const void *value);
477
487int
490 const struct GNUNET_HashCode *key);
491
492
501unsigned int
503
504
518 const struct GNUNET_HashCode *key);
519
520
535 const struct GNUNET_HashCode *key,
536 const void *value);
537
538
555 const struct GNUNET_HashCode *key,
556 void *value,
558
566unsigned int
568 const struct GNUNET_CONTAINER_MultiHashMap *map);
569
570
581int
585 void *it_cls);
586
587
603 const struct GNUNET_CONTAINER_MultiHashMap *map);
604
605
624 struct GNUNET_HashCode *key,
625 const void **value);
626
627
634void
637
638
653 const struct GNUNET_HashCode *key,
655 void *it_cls);
656
657
669unsigned int
673 void *it_cls);
674
675
676/* ***************** Version of Multihashmap for peer identities ****************** */
677
689typedef enum GNUNET_GenericReturnValue
691 void *cls,
692 const struct GNUNET_PeerIdentity *key,
693 void *value);
694
695
700
701
719GNUNET_CONTAINER_multipeermap_create (unsigned int len, int do_not_copy_keys);
720
721
729void
732
733
745void *
748 const struct GNUNET_PeerIdentity *key);
749
750
765 const struct GNUNET_PeerIdentity *key,
766 const void *value);
767
777int
780 const struct GNUNET_PeerIdentity *key);
781
782
796 const struct GNUNET_PeerIdentity *key);
797
798
813 const struct GNUNET_PeerIdentity *key,
814 const void *value);
815
816
830int
833 const struct GNUNET_PeerIdentity *key,
834 void *value,
836
837
845unsigned int
847 const struct GNUNET_CONTAINER_MultiPeerMap *map);
848
849
860int
864 void *it_cls);
865
866
883 const struct GNUNET_CONTAINER_MultiPeerMap *map);
884
885
907 struct GNUNET_PeerIdentity *key,
908 const void **value);
909
910
917void
920
921
933int
936 const struct GNUNET_PeerIdentity *key,
938 void *it_cls);
939
940
952unsigned int
956 void *it_cls);
957
958
959/* ***************** Version of Multihashmap for short hashes ****************** */
960
972typedef enum GNUNET_GenericReturnValue
974 void *cls,
975 const struct GNUNET_ShortHashCode *key,
976 void *value);
977
978
983
984
1002GNUNET_CONTAINER_multishortmap_create (unsigned int len, int do_not_copy_keys);
1003
1004
1012void
1015
1016
1028void *
1030 const struct GNUNET_CONTAINER_MultiShortmap *map,
1031 const struct GNUNET_ShortHashCode *key);
1032
1033
1046int
1049 const struct GNUNET_ShortHashCode *key,
1050 const void *value);
1051
1061int
1064 const struct GNUNET_ShortHashCode *key);
1065
1066
1077int
1079 const struct GNUNET_CONTAINER_MultiShortmap *map,
1080 const struct GNUNET_ShortHashCode *key);
1081
1082
1094int
1096 const struct GNUNET_CONTAINER_MultiShortmap *map,
1097 const struct GNUNET_ShortHashCode *key,
1098 const void *value);
1099
1100
1117 const struct GNUNET_ShortHashCode *key,
1118 void *value,
1120
1121
1129unsigned int
1131 const struct GNUNET_CONTAINER_MultiShortmap *map);
1132
1133
1144int
1148 void *it_cls);
1149
1150
1152
1153
1169 const struct GNUNET_CONTAINER_MultiShortmap *map);
1170
1171
1190 struct GNUNET_ShortHashCode *key,
1191 const void **value);
1192
1193
1200void
1203
1204
1216int
1219 const struct GNUNET_ShortHashCode *key,
1221 void *it_cls);
1222
1223
1235unsigned int
1237 const struct GNUNET_CONTAINER_MultiShortmap *map,
1239 void *it_cls);
1240
1241
1242/* ***************** Version of Multihashmap for UUIDs ****************** */
1243
1244
1256typedef enum GNUNET_GenericReturnValue
1258 void *cls,
1259 const struct GNUNET_Uuid *key,
1260 void *value);
1261
1262
1267
1268
1286GNUNET_CONTAINER_multiuuidmap_create (unsigned int len, int do_not_copy_keys);
1287
1288
1296void
1299
1300
1312void *
1314 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1315 const struct GNUNET_Uuid *key);
1316
1317
1332 const struct GNUNET_Uuid *key,
1333 const void *value);
1334
1344int
1347 const struct GNUNET_Uuid *key);
1348
1349
1362 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1363 const struct GNUNET_Uuid *key);
1364
1365
1379 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1380 const struct GNUNET_Uuid *key,
1381 const void *value);
1382
1383
1400 const struct GNUNET_Uuid *key,
1401 void *value,
1403
1404
1412unsigned int
1414 const struct GNUNET_CONTAINER_MultiUuidmap *map);
1415
1416
1431 void *it_cls);
1432
1433
1435
1436
1452 const struct GNUNET_CONTAINER_MultiUuidmap *map);
1453
1454
1473 struct GNUNET_Uuid *key,
1474 const void **value);
1475
1476
1483void
1486
1487
1499int
1502 const struct GNUNET_Uuid *key,
1504 void *it_cls);
1505
1506
1518unsigned int
1520 const struct GNUNET_CONTAINER_MultiUuidmap *map,
1522 void *it_cls);
1523
1524
1525/* Version of multihashmap with 32 bit keys */
1526
1532
1533
1540
1541
1553typedef enum GNUNET_GenericReturnValue
1555 void *cls,
1556 uint32_t key,
1557 void *value);
1558
1559
1569
1570
1578void
1581
1582
1590unsigned int
1592 const struct GNUNET_CONTAINER_MultiHashMap32 *map);
1593
1594
1606void *
1609 uint32_t key);
1610
1611
1622int
1626 void *it_cls);
1627
1628
1644 uint32_t key,
1645 const void *value);
1646
1647
1657int
1660 uint32_t key);
1661
1662
1676 uint32_t key);
1677
1678
1693 uint32_t key,
1694 const void *value);
1695
1696
1713 uint32_t key,
1714 void *value,
1716
1717
1729int
1732 uint32_t key,
1734 void *it_cls);
1735
1736
1751 const struct GNUNET_CONTAINER_MultiHashMap32 *map);
1752
1753
1771 uint32_t *key,
1772 const void **value);
1773
1774
1780void
1783
1784
1785/* ******************** doubly-linked list *************** */
1786/* To avoid mistakes: head->prev == tail->next == NULL */
1787
1797#define GNUNET_CONTAINER_DLL_insert(head, tail, element) \
1798 do \
1799 { \
1800 GNUNET_assert ((NULL == (head)) == (NULL == (tail))); \
1801 GNUNET_assert ((NULL == (element)->prev) && ((head) != (element))); \
1802 GNUNET_assert ((NULL == (element)->next) && ((tail) != (element))); \
1803 (element)->next = (head); \
1804 (element)->prev = NULL; \
1805 if (NULL == (tail)) \
1806 (tail) = element; \
1807 else \
1808 (head)->prev = element; \
1809 (head) = (element); \
1810 } while (0)
1811
1812
1822#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element) \
1823 do \
1824 { \
1825 GNUNET_assert ((NULL == (head)) == (NULL == (tail))); \
1826 GNUNET_assert ((NULL == (element)->prev) && ((head) != (element))); \
1827 GNUNET_assert ((NULL == (element)->next) && ((tail) != (element))); \
1828 (element)->prev = (tail); \
1829 (element)->next = NULL; \
1830 if (NULL == (head)) \
1831 (head) = element; \
1832 else \
1833 (tail)->next = element; \
1834 (tail) = (element); \
1835 } while (0)
1836
1837
1848#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element) \
1849 do \
1850 { \
1851 GNUNET_assert ((NULL == (head)) == (NULL == (tail))); \
1852 GNUNET_assert ((NULL == (element)->prev) && ((head) != (element))); \
1853 GNUNET_assert ((NULL == (element)->next) && ((tail) != (element))); \
1854 (element)->prev = (other); \
1855 if (NULL == other) \
1856 { \
1857 (element)->next = (head); \
1858 (head) = (element); \
1859 } \
1860 else \
1861 { \
1862 (element)->next = (other)->next; \
1863 (other)->next = (element); \
1864 } \
1865 if (NULL == (element)->next) \
1866 (tail) = (element); \
1867 else \
1868 (element)->next->prev = (element); \
1869 } while (0)
1870
1871
1882#define GNUNET_CONTAINER_DLL_insert_before(head, tail, other, element) \
1883 do \
1884 { \
1885 GNUNET_assert ((NULL == (head)) == (NULL == (tail))); \
1886 GNUNET_assert ((NULL == (element)->prev) && ((head) != (element))); \
1887 GNUNET_assert ((NULL == (element)->next) && ((tail) != (element))); \
1888 (element)->next = (other); \
1889 if (NULL == other) \
1890 { \
1891 (element)->prev = (tail); \
1892 (tail) = (element); \
1893 } \
1894 else \
1895 { \
1896 (element)->prev = (other)->prev; \
1897 (other)->prev = (element); \
1898 } \
1899 if (NULL == (element)->prev) \
1900 (head) = (element); \
1901 else \
1902 (element)->prev->next = (element); \
1903 } while (0)
1904
1905
1920#define GNUNET_CONTAINER_DLL_remove(head, tail, element) \
1921 do \
1922 { \
1923 GNUNET_assert ((NULL != (element)->prev) || ((head) == (element))); \
1924 GNUNET_assert ((NULL != (element)->next) || ((tail) == (element))); \
1925 if (NULL == (element)->prev) \
1926 (head) = (element)->next; \
1927 else \
1928 (element)->prev->next = (element)->next; \
1929 if (NULL == (element)->next) \
1930 (tail) = (element)->prev; \
1931 else \
1932 (element)->next->prev = (element)->prev; \
1933 (element)->next = NULL; \
1934 (element)->prev = NULL; \
1935 } while (0)
1936
1937
1938/* ************ Multi-DLL interface, allows DLL elements to be
1939 in multiple lists at the same time *********************** */
1940
1951#define GNUNET_CONTAINER_MDLL_insert(mdll, head, tail, element) \
1952 do \
1953 { \
1954 GNUNET_assert ((NULL == (head)) == (NULL == (tail))); \
1955 GNUNET_assert ((NULL == (element)->prev_ ## mdll) && ((head) != (element))); \
1956 GNUNET_assert ((NULL == (element)->next_ ## mdll) && ((tail) != (element))); \
1957 (element)->next_ ## mdll = (head); \
1958 (element)->prev_ ## mdll = NULL; \
1959 if (NULL == (tail)) \
1960 (tail) = element; \
1961 else \
1962 (head)->prev_ ## mdll = element; \
1963 (head) = (element); \
1964 } while (0)
1965
1966
1977#define GNUNET_CONTAINER_MDLL_insert_tail(mdll, head, tail, element) \
1978 do \
1979 { \
1980 GNUNET_assert ((NULL == (head)) == (NULL == (tail))); \
1981 GNUNET_assert ((NULL == (element)->prev_ ## mdll) && ((head) != (element))); \
1982 GNUNET_assert ((NULL == (element)->next_ ## mdll) && ((tail) != (element))); \
1983 (element)->prev_ ## mdll = (tail); \
1984 (element)->next_ ## mdll = NULL; \
1985 if (NULL == (head)) \
1986 (head) = element; \
1987 else \
1988 (tail)->next_ ## mdll = element; \
1989 (tail) = (element); \
1990 } while (0)
1991
1992
2004#define GNUNET_CONTAINER_MDLL_insert_after(mdll, head, tail, other, element) \
2005 do \
2006 { \
2007 GNUNET_assert ((NULL == (head)) == (NULL == (tail))); \
2008 GNUNET_assert ((NULL == (element)->prev_ ## mdll) && ((head) != (element))); \
2009 GNUNET_assert ((NULL == (element)->next_ ## mdll) && ((tail) != (element))); \
2010 (element)->prev_ ## mdll = (other); \
2011 if (NULL == other) \
2012 { \
2013 (element)->next_ ## mdll = (head); \
2014 (head) = (element); \
2015 } \
2016 else \
2017 { \
2018 (element)->next_ ## mdll = (other)->next_ ## mdll; \
2019 (other)->next_ ## mdll = (element); \
2020 } \
2021 if (NULL == (element)->next_ ## mdll) \
2022 (tail) = (element); \
2023 else \
2024 (element)->next_ ## mdll->prev_ ## mdll = (element); \
2025 } while (0)
2026
2027
2039#define GNUNET_CONTAINER_MDLL_insert_before(mdll, head, tail, other, element) \
2040 do \
2041 { \
2042 GNUNET_assert ((NULL == (head)) == (NULL == (tail))); \
2043 GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
2044 GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
2045 (element)->next_ ## mdll = (other); \
2046 if (NULL == other) \
2047 { \
2048 (element)->prev = (tail); \
2049 (tail) = (element); \
2050 } \
2051 else \
2052 { \
2053 (element)->prev_ ## mdll = (other)->prev_ ## mdll; \
2054 (other)->prev_ ## mdll = (element); \
2055 } \
2056 if (NULL == (element)->prev_ ## mdll) \
2057 (head) = (element); \
2058 else \
2059 (element)->prev_ ## mdll->next_ ## mdll = (element); \
2060 } while (0)
2061
2062
2074#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element) \
2075 do \
2076 { \
2077 GNUNET_assert ((NULL != (element)->prev_ ## mdll) || ((head) == (element))); \
2078 GNUNET_assert ((NULL != (element)->next_ ## mdll) || ((tail) == (element))); \
2079 if (NULL == (element)->prev_ ## mdll) \
2080 (head) = (element)->next_ ## mdll; \
2081 else \
2082 (element)->prev_ ## mdll->next_ ## mdll = (element)->next_ ## mdll; \
2083 if (NULL == (element)->next_ ## mdll) \
2084 (tail) = (element)->prev_ ## mdll; \
2085 else \
2086 (element)->next_ ## mdll->prev_ ## mdll = (element)->prev_ ## mdll; \
2087 (element)->next_ ## mdll = NULL; \
2088 (element)->prev_ ## mdll = NULL; \
2089 } while (0)
2090
2091
2105#define GNUNET_CONTAINER_DLL_insert_sorted(TYPE, \
2106 comparator, \
2107 comparator_cls, \
2108 head, \
2109 tail, \
2110 element) \
2111 do \
2112 { \
2113 if ((NULL == head) || (0 < comparator (comparator_cls, element, head))) \
2114 { \
2115 /* insert at head, element < head */ \
2116 GNUNET_CONTAINER_DLL_insert (head, tail, element); \
2117 } \
2118 else \
2119 { \
2120 TYPE *pos; \
2121 \
2122 for (pos = head; NULL != pos; pos = pos->next) \
2123 if (0 < comparator (comparator_cls, element, pos)) \
2124 break; /* element < pos */ \
2125 if (NULL == pos) /* => element > tail */ \
2126 { \
2127 GNUNET_CONTAINER_DLL_insert_tail (head, tail, element); \
2128 } \
2129 else /* prev < element < pos */ \
2130 { \
2131 GNUNET_CONTAINER_DLL_insert_after (head, tail, pos->prev, element); \
2132 } \
2133 } \
2134 } while (0)
2135
2136
2137/* ******************** Heap *************** */
2138
2139
2145
2146
2152{
2158
2165
2166
2172
2173
2179
2180
2188struct GNUNET_CONTAINER_Heap *
2190
2191
2199void
2201
2202
2210void *
2212
2213
2225 void **element,
2227
2228
2236unsigned int
2238
2239
2249 const struct GNUNET_CONTAINER_HeapNode *node);
2250
2251
2263typedef enum GNUNET_GenericReturnValue
2265 void *cls,
2266 struct GNUNET_CONTAINER_HeapNode *node,
2267 void *element,
2269
2270
2279void
2282 void *iterator_cls);
2283
2296void *
2298
2299
2311 void *element,
2313
2314
2322void *
2324
2325
2333void *
2335
2336
2344void
2347
2348
2349#if 0 /* keep Emacsens' auto-indent happy */
2350{
2351#endif
2352#ifdef __cplusplus
2353}
2354#endif
2355
2356
2357/* ifndef GNUNET_CONTAINER_LIB_H */
2358#endif
2359 /* end of group addition */
2361
2362/* end of gnunet_container_lib.h */
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static char * filename
static char * value
Value of the record to add/remove.
static int result
Global testing status.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
cryptographic primitives for GNUnet
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.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a Bloom filter from raw bits.
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.
enum GNUNET_GenericReturnValue 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.
int(* GNUNET_CONTAINER_HashCodeIterator)(void *cls, struct GNUNET_HashCode *next)
Iterator over struct GNUNET_HashCode.
enum GNUNET_GenericReturnValue 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.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_load(const char *filename, size_t size, unsigned int k)
Load a Bloom filter from a file.
enum GNUNET_GenericReturnValue 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.
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...
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.
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).
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.
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.
int GNUNET_CONTAINER_multihashmap32_get_multiple(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
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_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMapIterator * GNUNET_CONTAINER_multipeermap_iterator_create(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Create an iterator for a multihashmap.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_ShortmapIterator)(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
Iterator over hash map entries.
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).
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.
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.
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.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
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.
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_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
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_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.
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.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_MultiHashMapIterator32Callback)(void *cls, uint32_t key, void *value)
Iterator over hash map entries.
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_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
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.
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.
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).
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
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.
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.
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.
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.
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.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_MultiHashMapIteratorCallback)(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries.
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_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_MultiUuidmapIterator * GNUNET_CONTAINER_multiuuidmap_iterator_create(const struct GNUNET_CONTAINER_MultiUuidmap *map)
Create an iterator for a multihashmap.
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_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries 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_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_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.
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.
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.
struct GNUNET_CONTAINER_MultiHashMapIterator * GNUNET_CONTAINER_multihashmap_iterator_create(const struct GNUNET_CONTAINER_MultiHashMap *map)
Create an iterator for a multihashmap.
@ 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_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
GNUNET_CONTAINER_HeapOrder
Heap type, either max or min.
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_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
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.
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.
void * GNUNET_CONTAINER_heap_walk_get_next(struct GNUNET_CONTAINER_Heap *heap)
Perform a random walk of the tree.
@ 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.
struct GNUNET_CONTAINER_MultiHashMap32Iterator * GNUNET_CONTAINER_multihashmap32_iterator_create(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Create an iterator for a 32-bit multihashmap.
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.
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_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.
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 struct GNUNET_CONTAINER_MultiPeerMap * map
Peermap of PeerIdentities to "struct PeerEntry" (for fast lookup).
Definition: peer.c:63
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.