Java List Reverse reversed(final List list)

Here you can find the source of reversed(final List list)

Description

reversed

License

Open Source License

Declaration

public static <T> Iterable<T> reversed(final List<T> list) 

Method Source Code

//package com.java2s;

import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class Main {
    public static <T> Iterable<T> reversed(final List<T> list) {
        return new Iterable<T>() {
            public Iterator<T> iterator() {
                return new Iterator<T>() {
                    final ListIterator<T> it = list.listIterator(list.size());

                    public boolean hasNext() {
                        return it.hasPrevious();
                    }/*from   ww w .  j  av a2 s.c o m*/

                    public T next() {
                        return it.previous();
                    }

                    public void remove() {
                        it.remove();
                    }
                };
            }
        };
    }
}

Related

  1. reverse(List xs)
  2. reverse(List l)
  3. reverseCopy(Iterable list)
  4. reverseCopy(List list)
  5. reverseCopy(List original)
  6. reversed(List l)
  7. reversed(List list)
  8. reversedCopy(List src, List dest)
  9. reverseIterable(final List list)