Anonymous user
User:Margusmartsepp/Contributions/Java/Utils.java: Difference between revisions
User:Margusmartsepp/Contributions/Java/Utils.java (view source)
Revision as of 05:17, 28 October 2010
, 13 years agono edit summary
(Created page with "<lang java> import java.util.ArrayList; import java.util.Collections; public class Utils<T extends Comparable<T>> { private void swap(ArrayList<T> data, int i, int j) { T t =...") |
No edit summary |
||
Line 3:
import java.util.Collections;
public class Utils
private static <T> void swap(ArrayList<T> data, int i, int j) {
T t = data.get(i);
data.set(i, data.get(j));
Line 10:
}
public static ArrayList<Integer> mRange(int from, int to) {
ArrayList<Integer> result = new ArrayList<Integer>();
for (int i = from; i <= to; i++)
Line 17:
}
public static <T extends Comparable<? super T>> boolean nextPerm(ArrayList<T> data) {
// find the swaps
int c = -1, d = data.size();
Line 43:
}
public static <T extends Comparable<? super T>> ArrayList<ArrayList<T>> Permutations(ArrayList<T> d) {▼
▲ public ArrayList<ArrayList<T>> Permutations(ArrayList<T> d) {
ArrayList<ArrayList<T>> result = new ArrayList<ArrayList<T>>();
Collections.sort(d);
do {
result.add(
} while (
return result;
}
|