-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbloom_filter.h
42 lines (30 loc) · 961 Bytes
/
bloom_filter.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
#ifndef __BLOOM_H_INCLUDED__
#define __BLOOM_H_INCLUDED__
#include <cstdint>
#include <vector>
struct BloomParams final {
const uint32_t bit_count;
const unsigned int hash_count;
};
BloomParams get_params_for(unsigned int, double);
class BloomFilter final {
public:
BloomFilter() = default;
BloomFilter(uint32_t size, unsigned int hash_count);
BloomFilter(const BloomParams& params);
//BloomFilter () = default;
BloomFilter(const BloomFilter&) = delete;
BloomFilter operator=(const BloomFilter&) = delete;
BloomFilter(BloomFilter&&) = default;
BloomFilter& operator= (BloomFilter&& other) = default;
uint32_t get_size() const;
uint32_t get_hash_count() const;
static uint32_t hasher1(uint32_t);
void insert(uint32_t num);
bool contains(uint32_t num) const;
private:
uint32_t modulo = 0;
unsigned int hash_count = 0;
std::vector<bool> table{};
};
#endif // __BLOOM_H_INCLUDED__