CombinationSet { public List<Combination> getAllCombinationsOfNOrMoreElements(int n) { List<Combination> combinations = new ArrayList<Combination>(); int nb = nbOfCombinationsAbove(n); for (Combination comb : getAllCombinations()) { if (combinations.size() == nb) break; if (comb.getSize() >= n) 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 testGetAllCombinationsOfNOrMoreElements() { HashSet<Integer> set = new HashSet<Integer>(); set.add(1); set.add(2); set.add(3); CombinationSet combiSet = new CombinationSet(set); List<Combination> combis = combiSet.getAllCombinationsOfNOrMoreElements(2); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); set.clear(); set.add(1); set.add(2); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); set.clear(); set.add(2); set.add(3); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); set.clear(); set.add(3); set.add(1); Assert.assertTrue(combis.contains(new Combination(set, combiSet))); }