/// <summary> /// Initializes a new instance of the <see cref="BloomFilter<T>"/> class. /// </summary> /// <param name="size">The size in bits</param> /// <param name="keys">The key count</param> /// <param name="hashgen">The hash generation function</param> public BloomFilter(int size, int keys, CountingBloomFilter <T> .GenerateHash hashgen) { array = new BitArray(size, false); KeyCount = keys; hashGenerator = hashgen; }
/// <summary> /// Unions the specified filters /// </summary> /// <param name="s">The s.</param> public void Union(CountingBloomFilter <T> s) { if (s.KeyCount != this.KeyCount) { throw new ArgumentException("Cannot union two filters with different key counts"); } s.UnionOnto(array); }
/// <summary> /// Initializes a new instance of the <see cref="BloomFilter<T>"/> class. /// </summary> /// <param name="estimatedsize">The estimated number of items in the filter</param> /// <param name="targetFalsePositiveRate">The target positive rate when the estimated size is attained</param> /// <param name="hashgen">The hash generation function</param> public BloomFilter(int estimatedsize, float targetFalsePositiveRate, CountingBloomFilter <T> .GenerateHash hashgen) { int size = (int)(-(estimatedsize * Math.Log(targetFalsePositiveRate)) / 0.480453014f); int keys = (int)(0.7f * size / estimatedsize); array = new BitArray(size, false); KeyCount = keys; hashGenerator = hashgen; }