List of utility methods to do List Permutate
List
| permute(List Create a list of all permutations (lists) of the elements within the given list. List<List<E>> result = new ArrayList<List<E>>(); if (list1 != null) { int s1 = list1.size(); if (s1 > 0) { int index = 0; for (Iterator<E> it = list1.iterator(); it.hasNext(); ++index) { E elt = it.next(); List<E> list2 = new LinkedList<E>(list1.subList(0, index)); ... |
void | permute(List
Recursively creates permutations. for (int i = index; i < list.size(); i++) { Collections.swap(list, i, index); permute(list, index + 1, result); Collections.swap(list, index, i); if (index == list.size() - 1) { result.add(new ArrayList<T>(list)); |
T[] | permute(T[] arr, List permute T[] arr_new = arr.clone(); for (int i = 0; i < arr.length; i++) { arr_new[p.get(i)] = arr[i]; return arr_new; |
List
| permutedGroups(List
Generate all permuted groups from each list of elements. List<List<List<E>>> result = new ArrayList<List<List<E>>>(); if (elementLists == null || elementLists.size() == 0) { return result; int size = elementLists.size(); if (size == 1) { List<E> elements = elementLists.get(0); List<List<E>> groups = new ArrayList<List<E>>(); ... |
void | permuteList(List list, int[] permutations) permute List if (permutations.length != list.size()) { throw new IllegalArgumentException("List length and permutation length are not equal"); List<Object> tmpList = new ArrayList<Object>(permutations.length); for (int i = 0; i < permutations.length; i++) { tmpList.add(list.get(permutations[i])); list.clear(); ... |
List | permuteList(List permute List List<T> result = new ArrayList<T>(); result.addAll(in); Random R = new Random(seed); for (int permuteSize = in.size(); permuteSize > 1; permuteSize--) { int pos = Math.abs(R.nextInt()) % permuteSize; T tmp = result.get(permuteSize - 1); result.set(permuteSize - 1, result.get(pos)); result.set(pos, tmp); ... |
List | permuteList(List permute List List<T> output = new ArrayList<T>(); for (int i = 0; i < permutation.length; i++) { output.add(list.get(permutation[i])); return output; |
void | permVisit(int[] value, int n, int k, List Helper method for generating the integer sequence permutations. permLevel = permLevel + 1; value[k] = permLevel; if (permLevel == n) { res.add(copySubarray(value, 0, value.length)); } else { for (int i = 0; i < n; i++) { if (value[i] == 0) permVisit(value, n, i, res); ... |