Java List Reverse getReversedListIterable(final List inList)

Here you can find the source of getReversedListIterable(final List inList)

Description

get Reversed List Iterable

License

Open Source License

Declaration

public static <T> Iterable<T> getReversedListIterable(final List<T> inList) 

Method Source Code

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

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

public class Main {
    public static <T> Iterable<T> getReversedListIterable(final List<T> inList) {

        return new Iterable<T>() {
            @Override/*from w  w w .  j  a  v a  2 s .  c o  m*/
            public Iterator<T> iterator() {
                return getReversedListIterator(inList);
            }
        };
    }

    public static <T> Iterator<T> getReversedListIterator(final List<T> inList) {

        return new Iterator<T>() {

            int index = inList == null ? -1 : inList.size() - 1;

            @Override
            public boolean hasNext() {
                return index >= 0;
            }

            @Override
            public T next() {

                return inList.get(index--);
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }

        };
    }
}

Related

  1. compareVersions(List version1, List version2)
  2. compareVersions(String version1, String version2)
  3. createReversedList(List inputList)
  4. firstElementOf(List list, int reverseIndexPosition)
  5. formatToIp(final List shortList, final boolean reverseOrder)
  6. iterateReverse(final List elements)
  7. listToArrowSep(List strings, String highlightFirst, String highlightSecond, boolean reversed)
  8. reverse(Collection list)
  9. reverse(final List list)