Java BitSet

来源:互联网 发布:新浪域名 编辑:程序博客网 时间:2024/05/16 12:11

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));
        }

        
    }

 

results:

false
true
false
false
false
true
false
false
false
false
true