forked from sysprog21/dict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bloom.h
29 lines (21 loc) · 860 Bytes
/
bloom.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef _BLOOM_H
#define _BLOOM_H
#include <stdbool.h>
#include <stddef.h>
typedef unsigned int (*hash_function)(const void *data);
typedef struct bloom_filter *bloom_t;
/* Creates a new bloom filter with no hash functions and size * 8 bits. */
bloom_t bloom_create(size_t size);
/* Frees a bloom filter. */
void bloom_free(bloom_t filter);
/* Adds a hashing function to the bloom filter. You should add all of the
* functions you intend to use before you add any items. */
void bloom_add_hash(bloom_t filter, hash_function func);
/* Adds an item to the bloom filter. */
void bloom_add(bloom_t filter, const void *item);
/* Tests if an item is in the bloom filter.
*
* Returns false if the item has definitely not been added before. Returns true
* if the item was probably added before. */
bool bloom_test(bloom_t filter, const void *item);
#endif