Java List Reverse reverse(List list)

Here you can find the source of reverse(List list)

Description

reverse

License

Open Source License

Declaration

public static <T> List<T> reverse(List<T> list) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void reverse(long a[], int b, int e) {
        if (!(b <= e)) {
            throw new IllegalArgumentException("Wrong begin & end");
        }// www .  j a v a  2  s .c  o  m

        for (; b < e; ++b, --e) {
            long t = a[b];
            a[b] = a[e];
            a[e] = t;
        }
    }

    public static void reverse(long a[]) {
        reverse(a, 0, a.length - 1);
    }

    public static void reverse(int a[], int b, int e) {
        if (!(b <= e)) {
            throw new IllegalArgumentException("Wrong begin & end");
        }

        for (; b < e; ++b, --e) {
            int t = a[b];
            a[b] = a[e];
            a[e] = t;
        }
    }

    public static void reverse(int a[]) {
        reverse(a, 0, a.length - 1);
    }

    public static void reverse(byte a[], int b, int e) {
        if (!(b <= e)) {
            throw new IllegalArgumentException("Wrong begin & end");
        }

        for (; b < e; ++b, --e) {
            byte t = a[b];
            a[b] = a[e];
            a[e] = t;
        }
    }

    public static void reverse(byte a[]) {
        reverse(a, 0, a.length - 1);
    }

    public static <T> List<T> reverse(List<T> list) {
        List<T> nlist = new ArrayList<T>(list);
        Collections.reverse(nlist);
        return nlist;
    }
}

Related

  1. reverse(List source)
  2. reverse(List list)
  3. reverse(List list)
  4. reverse(List a)
  5. reverse(List l)
  6. reverse(List list)
  7. reverse(List list)
  8. reverse(List list)
  9. reverse(List list)

  10. HOME | Copyright © www.java2s.com 2016