Java使用BitSet做大数据量查重复
That's what I look for a long time. May used in Bloom Filter.
public static void main(String[] args) throws ParseException {
BitSet bit = new BitSet (100);
bit.set(1);
bit.set(10);
BitSet anBit = new BitSet();
anBit.set(10);
anBit.set(5);
//bit.and(anBit);
bit.or(anBit);
for(int i=0; i<bit.length(); i++)
{
System.out.println(bit.get(i));
}
}
BitSet bit = new BitSet (100);
bit.set(1);
bit.set(10);
BitSet anBit = new BitSet();
anBit.set(10);
anBit.set(5);
//bit.and(anBit);
bit.or(anBit);
for(int i=0; i<bit.length(); i++)
{
System.out.println(bit.get(i));
}
}
results:
false
true
false
false
false
true
false
false
false
false
true