@Test public void grayCodeInverse() { BitSet bs = new BitSet(); BitSetMath.grayCodeInverse(bs); Assert.assertTrue(bs.isEmpty()); bs.set(1); BitSet expected = new BitSet(); expected.set(0, 2); BitSetMath.grayCodeInverse(bs); Assert.assertEquals(expected, bs); }
public static void grayCodeInverse(BitSet i) { boolean oneBeyond = true; for (int j = i.length() - 2; j >= 0; --j) { if (oneBeyond) { oneBeyond = !i.get(j); i.set(j, oneBeyond); } else { oneBeyond = i.get(j); } } }
BitSetMath { public static void grayCodeInverse(BitSet i) { boolean oneBeyond = true; for (int j = i.length() - 2; j >= 0; --j) { if (oneBeyond) { oneBeyond = !i.get(j); i.set(j, oneBeyond); } else { oneBeyond = i.get(j); } } } }
BitSetMath { public static void grayCodeInverse(BitSet i) { boolean oneBeyond = true; for (int j = i.length() - 2; j >= 0; --j) { if (oneBeyond) { oneBeyond = !i.get(j); i.set(j, oneBeyond); } else { oneBeyond = i.get(j); } } } private  BitSetMath(); }
BitSetMath { public static void grayCodeInverse(BitSet i) { boolean oneBeyond = true; for (int j = i.length() - 2; j >= 0; --j) { if (oneBeyond) { oneBeyond = !i.get(j); i.set(j, oneBeyond); } else { oneBeyond = i.get(j); } } } private  BitSetMath(); static int increment(BitSet i); static void rotate(BitSet bs, int n, int count); static void extractBitRange(BitSet chi, int from, int to, BitSet r); static void grayCode(BitSet i); static void grayCodeInverse(BitSet i); static void copy(BitSet from, BitSet to); static long littleEndianBitSetToNonNegativeLong(BitSet bs); static void nonNegativeLongToLittleEndianBitSet(long value, BitSet bs); }
BitSetMath { public static void grayCodeInverse(BitSet i) { boolean oneBeyond = true; for (int j = i.length() - 2; j >= 0; --j) { if (oneBeyond) { oneBeyond = !i.get(j); i.set(j, oneBeyond); } else { oneBeyond = i.get(j); } } } private  BitSetMath(); static int increment(BitSet i); static void rotate(BitSet bs, int n, int count); static void extractBitRange(BitSet chi, int from, int to, BitSet r); static void grayCode(BitSet i); static void grayCodeInverse(BitSet i); static void copy(BitSet from, BitSet to); static long littleEndianBitSetToNonNegativeLong(BitSet bs); static void nonNegativeLongToLittleEndianBitSet(long value, BitSet bs);  }