33 #ifndef BLOOMFILTER_H_
34 #define BLOOMFILTER_H_
50 virtual size_t count()
const = 0;
52 virtual void clear() = 0;
53 virtual const std::list<bloom_type>
hash(
const unsigned char* begin, std::size_t remaining_length)
const = 0;
66 const std::list<bloom_type>
hash(
const unsigned char* begin, std::size_t remaining_length)
const;
71 bloom_type hash_ap(
const unsigned char* begin, std::size_t remaining_length,
bloom_type hash)
const;
73 std::vector<bloom_type> _salt;
74 std::size_t salt_count_;
84 BloomFilter(std::size_t table_size = 8192, std::size_t salt_count = 2);
95 void insert(
const unsigned char* key_begin,
const std::size_t length);
100 insert(reinterpret_cast<const unsigned char*>(&t),
sizeof(T));
103 void insert(
const std::string& key);
105 void insert(
const char* data,
const std::size_t& length);
107 template<
typename InputIterator>
108 void insert(
const InputIterator begin,
const InputIterator end)
110 InputIterator it = begin;
117 virtual bool contains(
const unsigned char* key_begin,
const std::size_t length)
const;
122 return contains(reinterpret_cast<const unsigned char*>(&t),static_cast<std::size_t>(
sizeof(T)));
125 bool contains(
const std::string& key)
const;
127 bool contains(
const char* data,
const std::size_t& length)
const;
129 template<
typename InputIterator>
130 InputIterator
contains_all(
const InputIterator begin,
const InputIterator end)
const
132 InputIterator it = begin;
144 template<
typename InputIterator>
145 InputIterator
contains_none(
const InputIterator begin,
const InputIterator end)
const
147 InputIterator it = begin;
159 virtual std::size_t
size()
const;