bitset
bitset copied to clipboard
andNot not working as expected
Hey, Thanks for sharing this code, really helpful! Just a quick observation about the andNot method. This function fails to pass the following test:
bitSet = new BitSet();
BitSet bs = bitSet;
for (int i = 0; i <= 7; i++) {
bitSet.set(i);
}
bs.clear(5);
BitSet bs2 = new BitSet();
bs2.set(2);
bs2.set(3);
bs.andNot(bs2);
assertEquals("Incorrect bitset after andNot",
"{0, 1, 4, 6, 7}", bs.toString());
bs = new BitSet(0);
bs.andNot(bs2);
assertEquals("Incorrect size", 0, bs.length());
Fails assertion with "incorrect bitset after andNot", I see "{0,1,2,3,4,6,7}" instead of "{0, 1, 4, 6, 7}" I have moved to using this implementation as well : https://github.com/atonparker/bitterset