List of utility methods to do List Permutate
List
| perm(List perm List<List<T>> result = new ArrayList<>(); for (int i = 0; i < l.size(); i++) { for (List<T> perm : perm(sub(l, i))) { perm.add(0, l.get(i)); result.add(perm); result.add(new ArrayList<T>()); ... |
List | permsList(List topList) Given a mainlist of sublists, return a new newlist of newsublists, such that: - the number of newsublists is the number of "cycles" ("permutations"?) - each newsublist has the same number of objects in it as the original mainlist had sublists. int numSublists = topList.size(); if (numSublists == 0) return topList; List retList = new ArrayList(); List firstElements = (List) topList.get(0); List tailPerms = permsList(topList.subList(1, numSublists)); for (Iterator it = firstElements.iterator(); it.hasNext();) { Object item = it.next(); ... |
List
| permutate(List permutate if (src.size() <= 1) { List<List<T>> al = new ArrayList<>(); al.add(src); return al; List<List<T>> result = new ArrayList<>(); for (int i = 0; i < src.size(); i++) { List<T> copy = new ArrayList<>(src); ... |
List | permutation(List permutation List<String> result = new ArrayList<String>(); for (String s1 : list1) { for (String s2 : list2) { StringBuilder sb = new StringBuilder(); sb.append(s1); if (!isEmpty(token)) { sb.append(token); sb.append(s2); result.add(sb.toString()); return result; |
void | permutation(String prefix, String s, List permutation int n = s.length(); if (n == 0) { list.add(prefix); } else { for (int i = 0; i < n; i++) { permutation(prefix + s.charAt(i), s.substring(0, i) + s.substring(i + 1, n), list); |
List
| permutations(List permutations return permutations(new ArrayList<E>(), list, new ArrayList<List<E>>()); |
List
| permutations(List permutations List<List<T>> perms = new ArrayList<List<T>>(); if (listings.size() == 0) { return perms; List<T> list = new ArrayList<T>(); list.add(listings.get(0)); perms.add(list); if (listings.size() == 1) { ... |
List | permutations(Map permutations List<Map<String, T>> list = new ArrayList<Map<String, T>>(); if (parameterValues == null || parameterValues.size() == 0) { return list; permute(new HashMap<String, T>(), new ArrayList<String>(parameterValues.keySet()), parameterValues, list); return list; |
List | permute(List s1, List s2) permute List result = new ArrayList<List>(s1.size() * s2.size()); for (int i = 0; i < s1.size(); i++) { Object o1 = s1.get(i); for (int j = 0; j < s2.size(); j++) { Object o2 = s2.get(j); ArrayList item = new ArrayList(); if (o1 instanceof Collection) item.addAll((Collection) o1); ... |
List
| permute(List permute return permute(arr, 0);
|