BloomFilter.NetCore
BloomFilter.NetCore copied to clipboard
Checking for bits set on Add?
I noticed that you check whether the bits were set on Add. Wouldn't it be better to just set the bits and not care about the results?
lock (_sync)
{
for (var i = 0; i < hashes.Count; i++)
{
if (!_hashBits.Get(hashes[i]))
{
_hashBits.Set(hashes[i], true);
processResults[i] = false;
}
else
{
processResults[i] = true;
}
}
}
Single or multiple, it needs to be clear that the return value indicates whether it already exists.
secne 1
if(bf.Contains("value")){
return;
}
//logic
bf.Add("value");
secne 2
if(!bf.Add("value")){
return;
}
//logic
secne 3
if(!bf.Add(new []{"v1","v2"}).All()){
return;
}
//logic