HilbertIndexMasks { private static void extractMask(List<Integer> bitsPerDimension, int i, BitVector mu) { for (int j = 0; j < bitsPerDimension.size(); ++j) { if (bitsPerDimension.get(bitsPerDimension.size() - j - 1) > i) { mu.set(j); } } } HilbertIndexMasks(MultiDimensionalSpec spec); int getCardinality(int i); List<Integer> cardinalities(); void copyMaskTo(int i, int d, BitVector mu);  }
@Test public void extractMask() { List<Integer> bitsPerDimension = Arrays.asList(5, 4, 6); MultiDimensionalSpec spec = new MultiDimensionalSpec(bitsPerDimension); HilbertIndexMasks masks = new HilbertIndexMasks(spec); for (int i = 0; i < spec.maxBitsPerDimension(); ++i) { for (int d = 0; d < bitsPerDimension.size(); ++d) { BitVector expected = extractMask(bitsPerDimension, i, d); BitVector actual = BitVectorFactories.OPTIMAL.apply(bitsPerDimension.size()); masks.copyMaskTo(i, d, actual); Assert.assertEquals(expected, actual); } } }