3 ms·
This example works well for raw data but not for complex types. You could make the filter a template, taking the key and a "hasher" function as template args.
by nate_martin 10y ago
This example works well for raw data but not for complex types. You could make the filter a template, taking the key and a "hasher" function as template args.
- schmatz 10y agoGreat suggestion; I wasn't sure the idiomatic way to template this, thanks for letting me know!
- nate_martin 10y agoProbably something like this: template< class Key, class Hash = std::hash<Key> > class BloomFilter;
- schmatz 10y agoI updated the blog post with your suggestion; CDN should be updated soon :)
- bradleyjg 10y agoI don't use c++ so I'm not sure how std:hash works or gets implemented, but the way that guava (Google's java library) does it is by passing in a key and a funnel object. The funnel object is essentially responsible for decomposing the object into a byte stream. The advantage of doing it this way rather than making the caller specify his own hash is that you can use murmurhash3 which you thought had the best properties for the bloom filter.
- mavam 10y agoEven better: N3980 [1] This proposal decouples the implementation of hash functions from how types get hashed. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3980.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n398...