@@ -0,0 +1,1486 @@
+/**%0A * Copyright %C2%A9 2014  Mattias Andr%C3%A9e (maandree@member.fsf.org)%0A * %0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A * %0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU Affero General Public License for more details.%0A * %0A * You should have received a copy of the GNU Affero General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0Apackage algorithms.arrays;%0A%0Aimport java.util.Random;%0A%0A%0A/**%0A * Bias free array shuffling class using Knuth Shuffle.%3Cbr%3E%0A * Sattolo Cycle is an improvement of this method.%0A */%0Apublic class KnuthShuffle%0A%7B%0A%C2%A3%3Efor T in boolean char byte short int long float double Object; do%0A    /**%0A     * Shuffles an array%0A     *%0A     * @param  array   The array to shuffle%0A     * @param  random  The random generator to use%0A     */%0A    public static void shuffle(%C2%A3%7BT%7D%5B%5D array, Random random)%0A    %7B%0A        int i = 0, j;%0A        int n = array.length - 1;%0A        for (;;)%0A%09%7B%0A%09    if (i == n)%0A%09%09break;%0A            %0A%09    %C2%A3%7BT%7D temp = array%5Bi%5D;%0A%09    array%5Bi%5D = array%5Bj = random.nextInt(n - i) + i + 1%5D;%0A%09    array%5Bj%5D = temp;%0A            %0A%09    i++;%0A%09%7D%0A    %7D%0A%C2%A3%3Edone%0A%7D%0A%0A

add knuth shuffle