Code example for BitSet

Methods: cardinalityclearflipset

0
    /** 
     * @tests java.util.BitSet#cardinality() 
     */ 
    public void test_cardinality() { 
        // test for method int java.util.BitSet.cardinality() 
        BitSet bs = new BitSet(500);
        bs.set(5);
        bs.set(32);
        bs.set(63);
        bs.set(64);
        bs.set(71, 110);
        bs.set(127, 130);
        bs.set(193);
        bs.set(450);
        assertEquals("cardinality() returned wrong value", 48, bs.cardinality());
 
        bs.flip(0, 500);
        assertEquals("cardinality() returned wrong value", 452, bs
                .cardinality());
 
        bs.clear();
        assertEquals("cardinality() returned wrong value", 0, bs.cardinality());
 
        bs.set(0, 500);
        assertEquals("cardinality() returned wrong value", 500, bs
                .cardinality());
    } 
 
    protected void setUp() { 
 
        eightbs = new BitSet();
Connect your IDE to all the code out there  Get Codota for Java