行业知识
14.【CPP】哈希的应用(位图||布隆过滤器||哈希切分)
2026-11-21 05:45:52
来源:互联网转载
位图
位图的实现
templateclass BitSet{public:BitSet(){_bits.resize(N / 8 + 1, 0);}void set(size_t x){size_t i = x / 8;size_t j = x % 8;_bits[i] |= (1size_t i = x / 8;size_t j = x % 8;_bits[i] &= ~(1 size_t i = x / 8;size_t j = x % 8;return _bits[i] & (1 public:void set(size_t x){//00变01if (_bs1.test(x) == false && _bs2.test(x) == false){_bs2.set(x);}//01变10,代表出现多次else if (_bs1.test(x) == false && _bs2.test(x) == true){_bs1.set(x);_bs2.reset(x);}else{//不变}}void Print(){for (size_t i = 0; i
上一篇:怎么连接internet服务器?