
Vicente Botet wrote:
Phil Endecott-48 wrote:
Alejandro Cabrera write:
Arash Partow wrote:
Looks ok, but one important question - Why is the BF typed? Its not necessary and in fact there are many use-cases where one might want to insert and/or test membership for a range of different types using the same BF - all that those types require are that they be hashable.
Could you give a concrete example of insertion of different types? any type?
You mean a practical application? No.
Though not necessary, I believe having a typed BF is safer. If there are users that want to eschew type safety to allow operations on multiple types, I believe this can be accomplished either by using a Bloom filter that accepts insertions of type void *.
Hmm, it's not clear to me how exactly you would do that with void*. I think Arash's suggestion is better, and you can then build strongly-typed filters on top of the "any" version like this:
class bloom_filter_any { template <typename T> void insert(const T& val) { .... } .... };
could you elaborate how the hash functions will be applied to any T?, Should this imply dynamic polymorphism?
No, it doesn't require dynamic polymorphism, just compile-type polymorphism. The filter's hash functions must accept the types that are actually used in calls to insert() etc. Regards, Phil.