libbf  0.1
 All Classes Functions Typedefs Friends Pages
basic.h
1 #ifndef BF_BLOOM_FILTER_BASIC_H
2 #define BF_BLOOM_FILTER_BASIC_H
3 
4 #include <random>
5 #include <bf/bitvector.h>
6 #include <bf/bloom_filter.h>
7 #include <bf/hash.h>
8 
9 namespace bf {
10 
17 {
18 public:
27  static size_t m(double fp, size_t capacity);
28 
37  static size_t k(size_t cells, size_t capacity);
38 
42  basic_bloom_filter(hasher h, size_t cells);
43 
56  basic_bloom_filter(double fp, size_t capacity, size_t seed = 0,
57  bool double_hashing = true);
58 
60 
61  using bloom_filter::add;
63 
64  virtual void add(object const& o) override;
65  virtual size_t lookup(object const& o) const override;
66  virtual void clear() override;
67 
73  void remove(object const& o);
74 
77  void swap(basic_bloom_filter& other);
78 
79 private:
80  hasher hasher_;
81  bitvector bits_;
82 };
83 
84 } // namespace bf
85 
86 #endif