Factorial base numbers indexing permutations of a collection: Difference between revisions
Content deleted Content added
New post. |
m Minor code improvement. |
||
Line 848: | Line 848: | ||
} |
} |
||
private static <T> List<T> permutation(List<T> elements, List<Integer> |
private static <T> List<T> permutation(List<T> elements, List<Integer> factoradic) { |
||
List<T> copy = new ArrayList<T>(elements); |
List<T> copy = new ArrayList<T>(elements); |
||
int m = 0; |
int m = 0; |
||
for ( int g : |
for ( int g : factoradic ) { |
||
Collections.rotate(copy.subList(m, m + g + 1), 1); |
Collections.rotate(copy.subList(m, m + g + 1), 1); |
||
m += 1; |
m += 1; |