-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBloomFilter.hpp
47 lines (35 loc) · 1 KB
/
BloomFilter.hpp
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
#ifndef BLOOMFILTER_HPP_
#define BLOOMFILTER_HPP_
#include <limits.h>
#include <iostream>
#include <assert.h>
#include <vector>
#include <math.h>
#include "Key.hpp"
#include "DataStructure.hpp"
class BloomFilter : public DataStructure {
public:
BloomFilter() {}
BloomFilter(unsigned long length) {
init(length);
}
virtual ~BloomFilter() {}
void init(unsigned long length);
// ADD FUNCTIONS
void add(const Key& key);
// FIND FUNCTIONS
int testExist(const Key& key, bool verbose = false);
//DEL FUNCTIONS
void del(const Key& key);
//DUMP FUNCTION
void dump();
private:
unsigned long hash1(const Key& key);
unsigned long hash2(const Key& key);
bool exist(const Key& key);
vector<unsigned long> m_tickBook;
unsigned long m_length; // number of bits in the bloom filter
unsigned long m_pockets; //the number of pockets
static const unsigned long m_pocketSize; //bits in each pocket
};
#endif /*BLOOMFILTER_HPP_*/