Merge branch 'refs/heads/t/fchdir-warning-fix'
[adu.git] / bloom.h
1 /*
2  * Copyright (C) 2008 Andre Noll <maan@tuebingen.mpg.de>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /** \file bloom.h Struct bloom and bloom filter functions. */
8
9 /** Describes one instance of a bloom filter. */
10 struct bloom {
11         /** The bloom filter is of size 2^order bits. */
12         unsigned order;
13         /** Set that many bits in the filter per entry. */
14         unsigned num_hash_functions;
15         /** How many entries have been inserted so far. */
16         uint64_t num_entries;
17         /** Number of bits currently set. */
18         uint64_t num_set_bits;
19         /** The bit array. */
20         uint8_t *filter;
21 };
22
23 struct bloom *bloom_new(unsigned order, unsigned num_hash_functions);
24 void bloom_free(struct bloom *b);
25 int bloom_insert(const uint8_t *data, size_t len, struct bloom *b);