2 This file is part of GNUnet
3 Copyright (C) 2012 GNUnet e.V.
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.
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.
17 * @file set/gnunet-service-set_union_strata_estimator.h
18 * @brief estimator of set difference
19 * @author Florian Dold
22 #ifndef GNUNET_CONSENSUS_STRATA_ESTIMATOR_H
23 #define GNUNET_CONSENSUS_STRATA_ESTIMATOR_H
26 #include "gnunet_common.h"
27 #include "gnunet_util_lib.h"
32 #if 0 /* keep Emacsens' auto-indent happy */
39 * A handle to a strata estimator.
41 struct StrataEstimator
44 * The IBFs of this strata estimator.
46 struct InvertibleBloomFilter **strata;
49 * Size of the IBF array in @e strata
51 unsigned int strata_count;
54 * Size of each IBF stratum (in bytes)
56 unsigned int ibf_size;
61 * Write the given strata estimator to the buffer.
63 * @param se strata estimator to serialize
64 * @param[out] buf buffer to write to, must be of appropriate size
65 * @return number of bytes written to @a buf
68 strata_estimator_write (const struct StrataEstimator *se,
73 * Read strata from the buffer into the given strata
74 * estimator. The strata estimator must already be allocated.
76 * @param buf buffer to read from
77 * @param buf_len number of bytes in @a buf
78 * @param is_compressed is the data compressed?
79 * @param[out] se strata estimator to write to
80 * @return #GNUNET_OK on success
83 strata_estimator_read (const void *buf,
86 struct StrataEstimator *se);
90 * Create a new strata estimator with the given parameters.
92 * @param strata_count number of stratas, that is, number of ibfs in the estimator
93 * @param ibf_size size of each ibf stratum
94 * @param ibf_hashnum hashnum parameter of each ibf
95 * @return a freshly allocated, empty strata estimator, NULL on error
97 struct StrataEstimator *
98 strata_estimator_create (unsigned int strata_count,
100 uint8_t ibf_hashnum);
104 * Get an estimation of the symmetric difference of the elements
105 * contained in both strata estimators.
107 * @param se1 first strata estimator
108 * @param se2 second strata estimator
109 * @return abs(|se1| - |se2|)
112 strata_estimator_difference (const struct StrataEstimator *se1,
113 const struct StrataEstimator *se2);
117 * Add a key to the strata estimator.
119 * @param se strata estimator to add the key to
120 * @param key key to add
123 strata_estimator_insert (struct StrataEstimator *se,
128 * Remove a key from the strata estimator.
130 * @param se strata estimator to remove the key from
131 * @param key key to remove
134 strata_estimator_remove (struct StrataEstimator *se,
139 * Destroy a strata estimator, free all of its resources.
141 * @param se strata estimator to destroy.
144 strata_estimator_destroy (struct StrataEstimator *se);
148 * Make a copy of a strata estimator.
150 * @param se the strata estimator to copy
153 struct StrataEstimator *
154 strata_estimator_dup (struct StrataEstimator *se);
157 #if 0 /* keep Emacsens' auto-indent happy */