On 8/25/13 7:47 AM, Gilles wrote: > Hi. > >> [...] >> + >> + /** >> + * Verifies that the iterator generates a lexicographically >> + * increasing sequence of b(n,k) arrays, each having length k >> + * and each array itself increasing. >> + * >> + * Note: the lexicographic order check only works for n < 10. > > What about not using a fixed base (cf. below)?
Thanks for the review! Yes, I think below would work. The key is the base, as you note. Or being less lazy and just actually directly implementing lexicographic order check. I did not see the need to test with n > 10; but I would be fine with the change below to allow it. Phil > >> + * >> + * @param iterator >> + * @param n size of universe >> + * @param k size of subsets >> + */ >> + private void checkIterator(Iterator<int[]> iterator, int n, >> int k) { >> + long lastLex = -1; >> + long length = 0; >> + while (iterator.hasNext()) { >> + final int[] iterate = iterator.next(); >> + Assert.assertEquals(k, iterate.length); >> + final long curLex = lexNorm(iterate); > ^^^^^^^^^^^^^^^ > Replace with > final long curLex = lexNorm(iterate, n); > >> + Assert.assertTrue(curLex > lastLex); >> + lastLex = curLex; >> + length++; >> + for (int i = 1; i < iterate.length; i++) { >> + Assert.assertTrue(iterate[i] > iterate[i - 1]); >> + } >> + } > >> [...] > >> + >> + /** >> + * Returns the value represented by the digits in the input >> array in reverse order. >> + * For example [3,2,1] returns 123. >> + * >> + * @param iterate input array >> + * @return lexicographic norm >> + */ >> + private long lexNorm(int[] iterate) { > ^^^ > Replace with > private long lexNorm(int[] iterate, int n) > >> + long ret = 0; >> + for (int i = iterate.length - 1; i >= 0; i--) { >> + ret += iterate[i] * ArithmeticUtils.pow(10l, (long) i); > ^^^^^^^^^^^^^^ > Replace with > ret += iterate[i] * ArithmeticUtils.pow(n, (long) i); > >> + } >> + return ret; >> + } >> +} > >> [...] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org