/** * Returns a Cartesian product of the lists of values specified. * * @param lists the lists of values * * @return the Cartesian product */ private List<String[]> getCrossProduct(Map<Integer, List<String>> lists) { List<String[]> results = new ArrayList<>(); getCrossProduct(results, lists, 0, new String[lists.size()]); return results; }
/** * Returns a Cartesian product of the lists of values specified. * * @param lists the lists of values * * @return the Cartesian product */ private List<String[]> getCrossProduct(Map<Integer, List<String>> lists) { List<String[]> results = new ArrayList<>(); getCrossProduct(results, lists, 0, new String[lists.size()]); return results; }
/** * A helper function used to compute a Cartesian product of the lists of values specified. */ private void getCrossProduct(List<String[]> results, Map<Integer, List<String>> lists, int depth, String[] current) { for (int i = 0; i < lists.get(depth).size(); i++) { current[depth] = lists.get(depth).get(i); if (depth < lists.keySet().size() - 1) { getCrossProduct(results, lists, depth + 1, current); } else { results.add(Arrays.copyOf(current, current.length)); } } }
/** * A helper function used to compute a Cartesian product of the lists of values specified. */ private void getCrossProduct(List<String[]> results, Map<Integer, List<String>> lists, int depth, String[] current) { for (int i = 0; i < lists.get(depth).size(); i++) { current[depth] = lists.get(depth).get(i); if (depth < lists.keySet().size() - 1) { getCrossProduct(results, lists, depth + 1, current); } else { results.add(Arrays.copyOf(current, current.length)); } } }
List<String[]> crossProductResult = getCrossProduct(partitionValues); List<List<String>> partitionFilters = new ArrayList<>(); for (String[] crossProductRow : crossProductResult)
List<String[]> crossProductResult = getCrossProduct(partitionValues); List<List<String>> partitionFilters = new ArrayList<>(); for (String[] crossProductRow : crossProductResult)