@@ -0,0 +1,2018 @@
+/**%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.*;%0A%0A%0A/**%0A * Class for reversing arrays%0A */%0Apublic class Reverse%0A%7B%0A%C2%A3%3Efor T in boolean char byte short int long; do%0A    /**%0A     * Reverses an array%0A     *%0A     * @param  items  The array to reverse%0A     */%0A    public static void reverse(%C2%A3%7BT%7D%5B%5D items)%0A    %7B%0A        for (int i = 0, j = items.length - 1; i %3C j; i++, j--)%0A%09%7B%0A%09    items%5Bj%5D %5E= items%5Bi%5D;%0A%09    items%5Bi%5D %5E= items%5Bj%5D;%0A%09    items%5Bj%5D %5E= items%5Bi%5D;%0A%09%7D%0A    %7D%0A%C2%A3%3Edone%0A%0A%C2%A3%3Efor T in float double Object; do%0A    /**%0A     * Reverses an array%0A     *%0A     * @param  items  The array to reverse%0A     */%0A    public static void reverse(%C2%A3%7BT%7D%5B%5D items)%0A    %7B%0A        %C2%A3%7BT%7D temp;%0A        for (int i = 0, j = items.length - 1; i %3C j; i++, j--)%0A%09%7B%0A%09    temp = items%5Bi%5D;%0A%09    items%5Bi%5D = items%5Bj%5D;%0A%09    items%5Bj%5D = temp;%0A%09%7D%0A    %7D%0A%C2%A3%3Edone%0A%0A%C2%A3%3Efor T in boolean char byte short int long float double Object; do%0A    /**%0A     * Make a clone of an array, but make it reversed%0A     *%0A     * @param   items  The array to reverse%0A     * @return         The array reversed%0A     */%0A    public static %C2%A3%7BT%7D%5B%5D reverseClone(%C2%A3%7BT%7D%5B%5D items)%0A    %7B%0A        %C2%A3%7BT%7D%5B%5D rc = new %C2%A3%7BT%7D%5Bitems.length%5D;%0A        for (int i = 0, n = items.length - 1; i %3C= n; i++)%0A            rc%5Bi%5D = items%5Bn - i%5D;%0A        return rc;%0A    %7D%0A%C2%A3%3Edone%0A%7D%0A%0A

add reverse