Here you can find the source of randomPermute(List
public static <T> void randomPermute(List<T> l, Random rand)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <T> void randomPermute(List<T> l, Random rand) { for (int i = 0; i < l.size(); i++) { int j = i + rand.nextInt(l.size() - i); T x = l.get(i);/* ww w . ja v a2 s . c om*/ l.set(i, l.get(j)); l.set(j, x); } } public static <T> T get(List<T> l, int i) { return get(l, i, null); } public static <T> T get(List<T> l, int i, T defValue) { if (i < 0) i += l.size(); if (i < 0 || i >= l.size()) return defValue; return l.get(i); } public static <T> T get(T[] l, int i) { return get(l, i, null); } public static <T> T get(T[] l, int i, T defValue) { if (i < 0) i += l.length; if (i < 0 || i >= l.length) return defValue; return l[i]; } public static double get(double[] l, int i, double defValue) { if (i < 0) i += l.length; if (i < 0 || i >= l.length) return defValue; return l[i]; } public static int[] set(int[] v, int x) { for (int i = 0; i < v.length; i++) v[i] = x; return v; } public static int[] set(int[] v, int x[], int n) { for (int i = 0; i < n; i++) v[i] = x[i]; return v; } public static int[] set(int[] v, int x[]) { return set(v, x, v.length); } public static double[] set(double[] v, double x[]) { for (int i = 0; i < v.length; i++) v[i] = x[i]; return v; } public static double[] set(double[] v, double x) { for (int i = 0; i < v.length; i++) v[i] = x; return v; } public static double[][] set(double[][] v, double[][] x) { for (int i = 0; i < v.length; i++) for (int j = 0; j < v[i].length; j++) v[i][j] = x[i][j]; return v; } public static double[][] set(double[][] v, double x) { for (int i = 0; i < v.length; i++) set(v[i], x); return v; } public static double[][][] set(double[][][] v, double x) { for (int i = 0; i < v.length; i++) set(v[i], x); return v; } public static double[][][][] set(double[][][][] v, double x) { for (int i = 0; i < v.length; i++) set(v[i], x); return v; } public static double[][][][][] set(double[][][][][] v, double x) { for (int i = 0; i < v.length; i++) set(v[i], x); return v; } }