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
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file set/gnunet-service-set_union_strata_estimator.h
23 * @brief estimator of set difference
24 * @author Florian Dold
27 #ifndef GNUNET_CONSENSUS_STRATA_ESTIMATOR_H
28 #define GNUNET_CONSENSUS_STRATA_ESTIMATOR_H
31 #include "gnunet_common.h"
32 #include "gnunet_util_lib.h"
37 #if 0 /* keep Emacsens' auto-indent happy */
44 * A handle to a strata estimator.
46 struct StrataEstimator
49 * The IBFs of this strata estimator.
51 struct InvertibleBloomFilter **strata;
54 * Size of the IBF array in @e strata
56 unsigned int strata_count;
59 * Size of each IBF stratum (in bytes)
61 unsigned int ibf_size;
66 * Write the given strata estimator to the buffer.
68 * @param se strata estimator to serialize
69 * @param[out] buf buffer to write to, must be of appropriate size
70 * @return number of bytes written to @a buf
73 strata_estimator_write (const struct StrataEstimator *se,
78 * Read strata from the buffer into the given strata
79 * estimator. The strata estimator must already be allocated.
81 * @param buf buffer to read from
82 * @param buf_len number of bytes in @a buf
83 * @param is_compressed is the data compressed?
84 * @param[out] se strata estimator to write to
85 * @return #GNUNET_OK on success
88 strata_estimator_read (const void *buf,
91 struct StrataEstimator *se);
95 * Create a new strata estimator with the given parameters.
97 * @param strata_count number of stratas, that is, number of ibfs in the estimator
98 * @param ibf_size size of each ibf stratum
99 * @param ibf_hashnum hashnum parameter of each ibf
100 * @return a freshly allocated, empty strata estimator, NULL on error
102 struct StrataEstimator *
103 strata_estimator_create (unsigned int strata_count,
105 uint8_t ibf_hashnum);
109 * Get an estimation of the symmetric difference of the elements
110 * contained in both strata estimators.
112 * @param se1 first strata estimator
113 * @param se2 second strata estimator
114 * @return abs(|se1| - |se2|)
117 strata_estimator_difference (const struct StrataEstimator *se1,
118 const struct StrataEstimator *se2);
122 * Add a key to the strata estimator.
124 * @param se strata estimator to add the key to
125 * @param key key to add
128 strata_estimator_insert (struct StrataEstimator *se,
133 * Remove a key from the strata estimator.
135 * @param se strata estimator to remove the key from
136 * @param key key to remove
139 strata_estimator_remove (struct StrataEstimator *se,
144 * Destroy a strata estimator, free all of its resources.
146 * @param se strata estimator to destroy.
149 strata_estimator_destroy (struct StrataEstimator *se);
153 * Make a copy of a strata estimator.
155 * @param se the strata estimator to copy
158 struct StrataEstimator *
159 strata_estimator_dup (struct StrataEstimator *se);
162 #if 0 /* keep Emacsens' auto-indent happy */