赞
踩
template <size_t N, class K = string,
class Hash_1 = BKDRHash,
class Hash_2 = SDBMHash,
class Hash_3 = RSHash>
class BloomFilter{
private:
BitSet<N> _bs;
};
void Set(const K& x){
/* Hash_1 h1;
h1(x);*/
size_t i1 = Hash_1()(x) % N;
size_t i2 = Hash_2()(x) % N;
size_t i3 = Hash_3()(x) % N;
cout << i1 << " " << i2 << " " << i3 << endl;
_bs.set(i1);
_bs.set(i2);
_bs.set(i3);
}
bool Test(const K& key){
size_t i1 = Hash_1()(key) % N;
size_t i2 = Hash_2()(key) % N;
size_t i3 = Hash_3()(key) % N;
if (!_bs.test(i1))
return false;
if (!_bs.test(i2))
return false;
if (!_bs.test(i3))
return false;
return true;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。