bloom: Add some source documentation.
[adu.git] / bloom.h
1 /*
2 * Copyright (C) 2008 Andre Noll <maan@systemlinux.org>
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 int bloom_init(unsigned bloom_filter_order, unsigned num_hash_functions,
24 struct bloom **result);
25 void bloom_free(struct bloom *b);
26 int bloom_test_and_insert(const uint8_t *data, size_t len, struct bloom *b);