-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBloomFilter.h
34 lines (33 loc) · 886 Bytes
/
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
/*
BloomFilter.h - Bloom filter lib.
*Creates a bloom filter from scrach
*Filter items
*Accept a already created filter
Created by Erico Netto, December 22, 2017.
Released into the public domain.
*/
#ifndef BloomFilter_h
#define BloomFilter_h
#include <vector>
class BloomFilter
{
public:
BloomFilter(int items_count, float fp_prob_);
BloomFilter(int items_count, std::vector<bool> &filter);
BloomFilter(int items_count, bool *filter, int sizeOfFilter);
void addItem(char *strItem);
bool checkItem(char *strItem);
int getFilterSize();
float getFalseProb();
int getHashCount();
std::vector<bool> getFilter();
private:
float fp_prob_;
int filter_size_;
std::vector<bool> filter_;
int hash_count_;
int calc_hash_count_(int m, int n);
int calc_size_(int n, float p);
float calc_prob_(int n, int m);
};
#endif