@Test public void testComputeParities() { long[] input = null; Assert.assertNull(computeParities(input)); long[] parities = computeParities(new long[87]); Assert.assertEquals(2, parities.length); input = new long[2]; input[0] = 8L; input[1] = 9L; parities = computeParities(input); Assert.assertEquals(1, parities.length); Assert.assertEquals(1, parities[0]); }
public static long[] computeParities(final long[] input) { final int numInput = input == null || input.length == 0 ? 0 : input.length; if (numInput == 0) { return input; } final int storage = (int) (numInput >> 6) + 1; final long[] parities = new long[storage]; if (isOddParity(input[0])) { parities[0] ^= 1; } for (int i = 1; i < numInput; i++) { final int section = i >> 6; final int currentIdx = i % 64 - 1; if (isOddParity(input[i])) { parities[section] ^= 1 << currentIdx; } } return parities; }
PracticeQuestionsCh5 { public static long[] computeParities(final long[] input) { final int numInput = input == null || input.length == 0 ? 0 : input.length; if (numInput == 0) { return input; } final int storage = (int) (numInput >> 6) + 1; final long[] parities = new long[storage]; if (isOddParity(input[0])) { parities[0] ^= 1; } for (int i = 1; i < numInput; i++) { final int section = i >> 6; final int currentIdx = i % 64 - 1; if (isOddParity(input[i])) { parities[section] ^= 1 << currentIdx; } } return parities; } }
PracticeQuestionsCh5 { public static long[] computeParities(final long[] input) { final int numInput = input == null || input.length == 0 ? 0 : input.length; if (numInput == 0) { return input; } final int storage = (int) (numInput >> 6) + 1; final long[] parities = new long[storage]; if (isOddParity(input[0])) { parities[0] ^= 1; } for (int i = 1; i < numInput; i++) { final int section = i >> 6; final int currentIdx = i % 64 - 1; if (isOddParity(input[i])) { parities[section] ^= 1 << currentIdx; } } return parities; }  }
PracticeQuestionsCh5 { public static long[] computeParities(final long[] input) { final int numInput = input == null || input.length == 0 ? 0 : input.length; if (numInput == 0) { return input; } final int storage = (int) (numInput >> 6) + 1; final long[] parities = new long[storage]; if (isOddParity(input[0])) { parities[0] ^= 1; } for (int i = 1; i < numInput; i++) { final int section = i >> 6; final int currentIdx = i % 64 - 1; if (isOddParity(input[i])) { parities[section] ^= 1 << currentIdx; } } return parities; }  static long[] computeParities(final long[] input); static long swapBits(final long x, final int i, final int j); static void powerSet(Set<Integer> set); static int stringToInt(String s); static String changeBase(String s, int b1, int b2); }
PracticeQuestionsCh5 { public static long[] computeParities(final long[] input) { final int numInput = input == null || input.length == 0 ? 0 : input.length; if (numInput == 0) { return input; } final int storage = (int) (numInput >> 6) + 1; final long[] parities = new long[storage]; if (isOddParity(input[0])) { parities[0] ^= 1; } for (int i = 1; i < numInput; i++) { final int section = i >> 6; final int currentIdx = i % 64 - 1; if (isOddParity(input[i])) { parities[section] ^= 1 << currentIdx; } } return parities; }  static long[] computeParities(final long[] input); static long swapBits(final long x, final int i, final int j); static void powerSet(Set<Integer> set); static int stringToInt(String s); static String changeBase(String s, int b1, int b2); static final Logger LOGGER; }