Java Collection Reverse reverseOrder(Collection objects)

Here you can find the source of reverseOrder(Collection objects)

Description

reverse Order

License

Open Source License

Declaration

public static <K> Collection<K> reverseOrder(Collection<K> objects) 

Method Source Code


//package com.java2s;
/*/*  ww  w  .j ava  2  s  .c  o  m*/
 * WANDORA
 * Knowledge Extraction, Management, and Publishing Application
 * http://wandora.org
 * 
 * Copyright (C) 2004-2016 Wandora Team
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * 
 *
 * GenericVelocityHelper.java
 *
 * Created on 17. joulukuuta 2004, 10:54
 */

import java.util.*;

public class Main {
    public static <K> Collection<K> reverseOrder(Collection<K> objects) {
        Object[] reversed = new Object[objects.size()];
        Iterator<K> iter = objects.iterator();
        int i = objects.size() - 1;
        while (iter.hasNext()) {
            reversed[i] = iter.next();
            i--;
        }
        Collection<K> reversedCollection = new ArrayList<K>();
        for (i = 0; i < reversed.length; i++) {
            reversedCollection.add((K) reversed[i]);
        }
        return reversedCollection;
    }
}

Related

  1. reverse(Collection collection)
  2. reverse(Collection c)
  3. reverse(Collection input)
  4. reverseMap(Map> input)