You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if the all the main objects that have a HashAlgorithm set could have that algorithm set at instantiation-time rather than an extra call to SetHash()
The text was updated successfully, but these errors were encountered:
Hi @mattlorimor, are you still interested in this change? If so, I could give it a shot, but I would have some questions.
Would you be okay with leaving the existing constructors, and adding new constructors that include the hash as the last argument? For BloomFilter, that would look something like this:
public BloomFilter(uint n, double fpRate) :
this(n, fpRate, Defaults.GetDefaultHashAlgorithm())
{
}
public BloomFilter(uint n, double fpRate, HashAlgorithm hash)
{
var m = Utils.OptimalM(n, fpRate);
var k = Utils.OptimalK(fpRate);
Buckets = new Buckets(m, 1);
this.Hash = hash;
this.m = m;
this.k = k;
}
Another option would be to have one constructor, but make the hash default to null and have null mean "default"; e.g.,
public BloomFilter(uint n, double fpRate, HashAlgorithm hash = null)
{
var m = Utils.OptimalM(n, fpRate);
var k = Utils.OptimalK(fpRate);
Buckets = new Buckets(m, 1);
this.Hash = hash ?? Defaults.GetDefaultHashAlgorithm();
this.m = m;
this.k = k;
}
My personal preference would be for the two constructor approach, but either way is fine.
Would you be okay with actually removing the SetHash() functions entirely? That would be my vote. If you wanted to keep the SetHash() methods, I would suggest that we change them to throw an exception if any data has already been added to the collection, since changing the hash function at that time must be a mistake.
It would be nice if the all the main objects that have a
HashAlgorithm
set could have that algorithm set at instantiation-time rather than an extra call toSetHash()
The text was updated successfully, but these errors were encountered: