7 default_hash_function::default_hash_function(
size_t seed)
12 size_t default_hash_function::operator()(
object const& o)
const
16 if (o.size() > max_obj_size)
17 throw std::runtime_error(
"object too large");
18 return o.size() == 0 ? 0 : h3_(o.data(), o.size());
21 default_hasher::default_hasher(std::vector<hash_function> fns)
22 : fns_(std::move(fns))
26 std::vector<digest> default_hasher::operator()(
object const& o)
const
28 std::vector<digest> d(fns_.size());
29 for (
size_t i = 0; i < fns_.size(); ++i)
35 double_hasher::double_hasher(
size_t k, hash_function h1, hash_function h2)
42 std::vector<digest> double_hasher::operator()(
object const& o)
const
46 std::vector<digest> d(k_);
47 for (
size_t i = 0; i < d.size(); ++i)
52 hasher make_hasher(
size_t k,
size_t seed,
bool double_hashing)
55 std::minstd_rand0 prng(seed);
58 auto h1 = default_hash_function(prng());
59 auto h2 = default_hash_function(prng());
60 return double_hasher(k, std::move(h1), std::move(h2));
64 std::vector<hash_function> fns(k);
65 for (
size_t i = 0; i < k; ++i)
66 fns[i] = default_hash_function(prng());
67 return default_hasher(std::move(fns));