扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
本系列:
创新互联是一家专注于成都做网站、网站制作、成都外贸网站建设和雅安移动机房的网络公司,有着丰富的建站经验和案例。
IPv6编码地址数:2^128(约3.4×10^38)
IPv6是IETF设计的用于替代现行版本IP协议(IPv4)的下一代IP协议,号称可以为全世界的每一粒沙子编上一个网址。
- public
boolean put(T object, Funnel super T> funnel, int numHashFunctions, BitArray bits) { - long bitSize = bits.bitSize();
- long hash64 = Hashing.murmur3_128().hashObject(object, funnel).asLong();
- int hash1 = (int) hash64;
- int hash2 = (int) (hash64 >>> 32);
- boolean bitsChanged = false;
- for (int i = 1; i <= numHashFunctions; i++) {
- int combinedHash = hash1 + (i * hash2);
- // Flip all the bits if it's negative (guaranteed positive number)
- if (combinedHash < 0) {
- combinedHash = ~combinedHash;
- }
- bitsChanged |= bits.set(combinedHash % bitSize);
- }
- return bitsChanged;
- }
- boolean set(long index) {
- if (!get(index)) {
- data[(int) (index >>> 6)] |= (1L << index);
- bitCount++;
- return true;
- }
- return false;
- }
- boolean get(long index) {
- return (data[(int) (index >>> 6)] & (1L << index)) != 0;
- }
02 先get()一下,看看是不是已经置为1。
03 index右移6位就是除以64,说明data是long型的数组,除以64就定位到了bit所在的数组下标。1L左移index位,定位到了bit在long中的位置。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流