46 #ifndef PSYNC_DETAIL_BLOOM_FILTER_HPP 47 #define PSYNC_DETAIL_BLOOM_FILTER_HPP 49 #include <ndn-cxx/name.hpp> 50 #include <ndn-cxx/util/string-helper.hpp> 58 class bloom_parameters;
63 class Error :
public std::runtime_error
66 using std::runtime_error::runtime_error;
72 double false_positive_probability);
75 double false_positive_probability,
76 const ndn::name::Component& bfName);
93 insert(
const std::string& key);
96 contains(
const std::string& key)
const;
99 typedef uint32_t bloom_type;
100 typedef uint8_t cell_type;
106 compute_indices(
const bloom_type& hash, std::size_t& bit_index, std::size_t& bit)
const;
109 generate_unique_salt();
118 return lhs.bit_table_ == rhs.bit_table_;
124 return lhs.bit_table_ != rhs.bit_table_;
130 ndn::printHex(os, bf.bit_table_.data(), bf.bit_table_.size(),
false);
135 std::vector<bloom_type> salt_;
136 std::vector<cell_type> bit_table_;
137 unsigned int salt_count_ = 0;
138 unsigned int table_size_ = 0;
139 unsigned int projected_element_count_ = 0;
140 unsigned int inserted_element_count_ = 0;
141 unsigned long long int random_seed_ = 0;
142 double desired_false_positive_probability_ = 0.0;
148 #endif // PSYNC_DETAIL_BLOOM_FILTER_HPP void insert(const std::string &key)
friend std::ostream & operator<<(std::ostream &os, const BloomFilter &bf)
bool contains(const std::string &key) const
friend bool operator!=(const BloomFilter &lhs, const BloomFilter &rhs)
friend bool operator==(const BloomFilter &lhs, const BloomFilter &rhs)
void appendToName(ndn::Name &name) const
Append our bloom filter to the given name.