/// <summary> /// Creates a new filter /// </summary> /// <param name="storage">Bloom Filter storage</param> /// <param name="parameters">Parameters</param> /// <param name="hashFunctions">Hash Functions</param> protected BaseHybridBloomFilter(IBloomFilterStorage storage, IBloomFilterParameters parameters, IEnumerable <Func <T, int> > hashFunctions) : base(storage) { if (parameters.NumberOfBits < 1) { throw new ArgumentException("Number of bits must be >= 1", "parameters"); } if (hashFunctions == null) { throw new ArgumentNullException("hashFunctions"); } this._hashFunctions = new List <Func <T, int> >(hashFunctions); this._hashFunctions.RemoveAll(f => f == null); if (this._hashFunctions.Count <= 1) { throw new ArgumentException("A bloom filter requires at least 2 hash functions", "hashFunctions"); } if (parameters.NumberOfBits <= this._hashFunctions.Count) { throw new ArgumentException("Number of bits must be bigger than the number of hash functions", "parameters"); } this.NumberOfBits = parameters.NumberOfBits; this._parameters = parameters; }
/// <summary> /// Creates a new /// </summary> /// <param name="storage">Bloom Filter Storage</param> /// <param name="parameters">Parameters</param> /// <param name="h1">First hash function</param> /// <param name="h2">Second hash function</param> protected BaseFastBloomFilter(IBloomFilterStorage storage, IBloomFilterParameters parameters, Func <T, int> h1, Func <T, int> h2) : base(storage) { if (parameters == null) { throw new ArgumentNullException("parameters", "Paramaeters cannot be null"); } if (h1 == null) { throw new ArgumentException("Hash functions cannot be null", "h1"); } if (h2 == null) { throw new ArgumentException("Hash functions cannot be null", "h2"); } if (parameters.NumberOfBits <= parameters.NumberOfHashFunctions) { throw new ArgumentException("Number of bits must be bigger than the number of hash functions", "parameters"); } this._parameters = parameters; this.NumberOfBits = parameters.NumberOfBits; this._h1 = h1; this._h2 = h2; }
/// <summary> /// Creates a new filter /// </summary> /// <param name="storage">Storage to use</param> protected BaseBloomFilter(IBloomFilterStorage storage) { if (storage == null) { throw new ArgumentNullException("storage", "Storage cannot be null"); } this.Storage = storage; }
/// <summary> /// Creates a new filter /// </summary> /// <param name="storage">Bloom Filter storage</param> /// <param name="bits">Number of Bits</param> /// <param name="hashFunctions">Hash Functions</param> protected BaseNaiveBloomFilter(IBloomFilterStorage storage, int bits, IEnumerable <Func <T, int> > hashFunctions) : base(storage) { if (bits <= 0) { throw new ArgumentException("Bits must be a positive value", "bits"); } if (hashFunctions == null) { throw new ArgumentNullException("hashFunctions"); } this._hashFunctions = new List <Func <T, int> >(hashFunctions); this._hashFunctions.RemoveAll(f => f == null); if (this._hashFunctions.Count <= 1) { throw new ArgumentException("A bloom filter requires at least 2 hash functions", "hashFunctions"); } if (bits <= this._hashFunctions.Count) { throw new ArgumentException("Bits must be bigger than the number of hash functions", "bits"); } this.NumberOfBits = bits; }