@Test public void testGetSetBitOffsetWithAll() { int v; v = Creator.getSetBitOffset(0xffffffff, 0); assertEquals(0, v); v = Creator.getSetBitOffset(0xffffffff, 1); assertEquals(1, v); v = Creator.getSetBitOffset(0xffffffff, 2); assertEquals(2, v); v = Creator.getSetBitOffset(0xffffffff, 3); assertEquals(3, v); v = Creator.getSetBitOffset(0xffffffff, 4); assertEquals(4, v); v = Creator.getSetBitOffset(0xffffffff, 5); assertEquals(5, v); v = Creator.getSetBitOffset(0xffffffff, 6); assertEquals(6, v); v = Creator.getSetBitOffset(0xffffffff, 7); assertEquals(7, v); v = Creator.getSetBitOffset(0xffffffff, 8); assertEquals(8, v); v = Creator.getSetBitOffset(0xffffffff, 31); assertEquals(31, v); v = Creator.getSetBitOffset(0xffffffff, 32); assertEquals(-1, v); }
protected static int getSetBitOffset(final int mask, final int bitIndex) { int count = 0; int workingMask = mask; int low = Integer.numberOfTrailingZeros(workingMask); workingMask >>>= low; assert (workingMask & 1) == 1 || workingMask == 0; for (int i = low; workingMask != 0; i++) { if ((workingMask & 1) != 0) { if (count == bitIndex) { return i; } count++; } workingMask >>>= 1; } return -1; }
Creator { protected static int getSetBitOffset(final int mask, final int bitIndex) { int count = 0; int workingMask = mask; int low = Integer.numberOfTrailingZeros(workingMask); workingMask >>>= low; assert (workingMask & 1) == 1 || workingMask == 0; for (int i = low; workingMask != 0; i++) { if ((workingMask & 1) != 0) { if (count == bitIndex) { return i; } count++; } workingMask >>>= 1; } return -1; } }
Creator { protected static int getSetBitOffset(final int mask, final int bitIndex) { int count = 0; int workingMask = mask; int low = Integer.numberOfTrailingZeros(workingMask); workingMask >>>= low; assert (workingMask & 1) == 1 || workingMask == 0; for (int i = low; workingMask != 0; i++) { if ((workingMask & 1) != 0) { if (count == bitIndex) { return i; } count++; } workingMask >>>= 1; } return -1; } private  Creator(); }
Creator { protected static int getSetBitOffset(final int mask, final int bitIndex) { int count = 0; int workingMask = mask; int low = Integer.numberOfTrailingZeros(workingMask); workingMask >>>= low; assert (workingMask & 1) == 1 || workingMask == 0; for (int i = low; workingMask != 0; i++) { if ((workingMask & 1) != 0) { if (count == bitIndex) { return i; } count++; } workingMask >>>= 1; } return -1; } private  Creator(); static GameMatrix createFull(); static GameMatrix createVariant(
            final GameMatrix fullyFilled); static Riddle createRiddle(final GameMatrix fullMatrix); }
Creator { protected static int getSetBitOffset(final int mask, final int bitIndex) { int count = 0; int workingMask = mask; int low = Integer.numberOfTrailingZeros(workingMask); workingMask >>>= low; assert (workingMask & 1) == 1 || workingMask == 0; for (int i = low; workingMask != 0; i++) { if ((workingMask & 1) != 0) { if (count == bitIndex) { return i; } count++; } workingMask >>>= 1; } return -1; } private  Creator(); static GameMatrix createFull(); static GameMatrix createVariant(
            final GameMatrix fullyFilled); static Riddle createRiddle(final GameMatrix fullMatrix);  }