@Test public void index3() { ListInt sizes = new ArrayInt(15,3,2); int[] actualCoords = new int[] {10,0,1}; boolean[] invert = new boolean[] {true, true, false}; int index = (4 * 3 + 2) * 2 + 1; assertThat(InvertListNumber.index(actualCoords, sizes, invert), equalTo(index)); }
static int index(int[] coords, ListInt sizes, boolean[] invert) { int index = 0; for (int i = 0; i < coords.length; i++) { index *= sizes.getInt(i); if (!invert[i]) { index += coords[i]; } else { index += sizes.getInt(i) - coords[i] - 1; } } return index; }
InvertListNumber implements ListNumber { static int index(int[] coords, ListInt sizes, boolean[] invert) { int index = 0; for (int i = 0; i < coords.length; i++) { index *= sizes.getInt(i); if (!invert[i]) { index += coords[i]; } else { index += sizes.getInt(i) - coords[i] - 1; } } return index; } }
InvertListNumber implements ListNumber { static int index(int[] coords, ListInt sizes, boolean[] invert) { int index = 0; for (int i = 0; i < coords.length; i++) { index *= sizes.getInt(i); if (!invert[i]) { index += coords[i]; } else { index += sizes.getInt(i) - coords[i] - 1; } } return index; }  }
InvertListNumber implements ListNumber { static int index(int[] coords, ListInt sizes, boolean[] invert) { int index = 0; for (int i = 0; i < coords.length; i++) { index *= sizes.getInt(i); if (!invert[i]) { index += coords[i]; } else { index += sizes.getInt(i) - coords[i] - 1; } } return index; }   }
InvertListNumber implements ListNumber { static int index(int[] coords, ListInt sizes, boolean[] invert) { int index = 0; for (int i = 0; i < coords.length; i++) { index *= sizes.getInt(i); if (!invert[i]) { index += coords[i]; } else { index += sizes.getInt(i) - coords[i] - 1; } } return index; }    }