CombinationSet { public List<Combination> getAllCombinations() { List<Combination> combinations = new ArrayList<Combination>(); for (long i = 1; i <= totalNb; i++) { Set<Object> subSet = new HashSet<Object>(); BigInteger bigInt = BigInteger.valueOf(i); for (int j = 0; j < bigInt.bitLength(); j++) { if (bigInt.testBit(j)) subSet.add(internalList.get(j)); } Combination comb = new Combination(subSet, this); combinations.add(comb); } return combinations; } CombinationSet(Set<? extends Object> set); int nbOfCombinations(int k); int nbOfCombinationsAbove(int k); List<Combination> getAllCombinationsOfNElements(int n); List<Combination> getAllCombinationsOfNOrMoreElements(int n); List<Combination> getAllCombinations(); long getTotalNb();  }
@Test public void testGetAllCombinations() { HashSet<Integer> set = new HashSet<Integer>(); set.add(1); set.add(2); set.add(3); CombinationSet combiSet = new CombinationSet(set); List<Combination> combis = combiSet.getAllCombinations(); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); set.clear(); set.add(1); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); set.add(2); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); set.clear(); set.add(2); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); set.add(3); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); set.clear(); set.add(3); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); set.add(1); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); }