Java Utililty Methods List Permutate

List of utility methods to do List Permutate

Description

The list of methods to do List Permutate are organized into topic(s).

Method

List>perm(List l)
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>());
...
ListpermsList(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 src)
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);
...
Listpermutation(List list1, List list2, String token)
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;
voidpermutation(String prefix, String s, List 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 list)
permutations
return permutations(new ArrayList<E>(), list, new ArrayList<List<E>>());
List>permutations(List listings)
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> parameterValues)
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;
Listpermute(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 arr)
permute
return permute(arr, 0);