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>
57 class bloom_parameters;
62 class Error :
public std::runtime_error
65 using std::runtime_error::runtime_error;
71 double false_positive_probability);
74 double false_positive_probability,
75 const ndn::name::Component& bfName);
92 insert(
const ndn::Name& key);
95 contains(
const ndn::Name& key)
const;
98 typedef uint32_t bloom_type;
99 typedef uint8_t cell_type;
105 compute_indices(
const bloom_type& hash, std::size_t& bit_index, std::size_t& bit)
const;
108 generate_unique_salt();
117 return lhs.bit_table_ == rhs.bit_table_;
123 return lhs.bit_table_ != rhs.bit_table_;
129 ndn::printHex(os, bf.bit_table_,
false);
134 std::vector<bloom_type> salt_;
135 std::vector<cell_type> bit_table_;
136 unsigned int salt_count_ = 0;
137 unsigned int table_size_ = 0;
138 unsigned int projected_element_count_ = 0;
139 unsigned int inserted_element_count_ = 0;
140 unsigned long long int random_seed_ = 0;
141 double desired_false_positive_probability_ = 0.0;
void insert(const ndn::Name &key)
friend bool operator!=(const BloomFilter &lhs, const BloomFilter &rhs)
void appendToName(ndn::Name &name) const
Append our bloom filter to the given name.
bool contains(const ndn::Name &key) const
friend std::ostream & operator<<(std::ostream &os, const BloomFilter &bf)
friend bool operator==(const BloomFilter &lhs, const BloomFilter &rhs)