-
Notifications
You must be signed in to change notification settings - Fork 2
/
bloomfilter.h
63 lines (46 loc) · 1.7 KB
/
bloomfilter.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
Copyright notice
================
Copyright (C) 2010
Lorenzo Martignoni <[email protected]>
Roberto Paleari <[email protected]>
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
ProcessTap is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __BLOOM_FILTER__
#define __BLOOM_FILTER__
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
unsigned char k;
unsigned int m;
unsigned char *buckets;
unsigned int n;
} bloomfilter_t;
bloomfilter_t *bloomfilter_init(unsigned int m, unsigned char k);
void bloomfilter_destroy(bloomfilter_t *bf);
void bloomfilter_clear(bloomfilter_t *bf);
void bloomfilter_fill(bloomfilter_t *bf);
void bloomfilter_add(bloomfilter_t *, unsigned char *, unsigned int);
int bloomfilter_contain(bloomfilter_t *, unsigned char *, unsigned int);
void bloomfilter_union(bloomfilter_t *, bloomfilter_t *);
void bloomfilter_intersect(bloomfilter_t *, bloomfilter_t *);
bloomfilter_t *bloomfilter_copy(bloomfilter_t *);
double bloomfilter_fp(bloomfilter_t *bf);
int bloomfilter_size(bloomfilter_t *bf);
#ifdef __cplusplus
} // extern "C"
#endif
#endif