コード例 #1
0
static auto make_insertion_decision_generator(const filter_t &filter) {
  using param_t = std::bernoulli_distribution::param_type;
  bernoulli_distribution dist;
  minstd_rand gen(3782348);

  return [&filter, gen = std::move(gen), dist ]() mutable {
    if (filter.empty())
      return true;
    if (filter.full())
      return false;
    const double load_factor = double(filter.size()) / filter.capacity();
    return dist(gen, param_t(1.0 - load_factor));
  };
}
コード例 #2
0
// Checks whether lhs and rhs are clones.
static bool totally_equal(const filter_t &lhs, const filter_t &rhs) noexcept {
  return lhs.size() == rhs.size() && lhs.capacity() == rhs.capacity() &&
         lhs.quotient_bits() == rhs.quotient_bits() &&
         lhs.remainder_bits() == rhs.remainder_bits() && equal(lhs, rhs);
}