Java Utililty Methods List Reverse

List of utility methods to do List Reverse

Description

The list of methods to do List Reverse are organized into topic(s).

Method

ListaddReverse(List list, List append)
Adds the contents of one list to the other in reverse order.
for (ListIterator i = append.listIterator(append.size()); i.hasPrevious();)
    list.add(i.previous());
return list;
intcompareVersions(List list1, List list2)
INTERNAL: Compares two lists of Integers -1, 0, 1 means the first list is less than, equal, greater than the second list.
int n = Math.max(list1.size(), list2.size());
int res = 0;
for (int i = 0; i < n; i++) {
    int l1 = 0;
    if (i < list1.size()) {
        l1 = list1.get(i);
    int l2 = 0;
...
intcompareVersions(List version1, List version2)
compare Versions
for (Iterator<Integer> it1 = version1.iterator(), it2 = version2.iterator();;) {
    if (!it1.hasNext()) {
        return it2.hasNext() ? -1 : 0;
    if (!it2.hasNext()) {
        return it1.hasNext() ? 1 : 0;
    Integer num1 = it1.next();
...
intcompareVersions(String version1, String version2)
Compares two versions strings (ex.
return compareVersions(version1, version2, 3);
ListcreateReversedList(List inputList)
create Reversed List
List<T> result = new ArrayList<T>(inputList); 
Collections.reverse(result);
return result;
EfirstElementOf(List list, int reverseIndexPosition)
Returns the first element of a given List
return list != null && !list.isEmpty() ? list.get(0) : null;
StringformatToIp(final List shortList, final boolean reverseOrder)
Formats a List with short values into it's IP-Address representation.
if (shortList == null) {
    return null;
if (reverseOrder) {
    Collections.reverse(shortList);
return shortList.toString().replaceAll(",[ ]*", ".").replaceAll("[\\[\\]]", "");
IterablegetReversedListIterable(final List inList)
get Reversed List Iterable
return new Iterable<T>() {
    @Override
    public Iterator<T> iterator() {
        return getReversedListIterator(inList);
};
IterableiterateReverse(final List elements)
iterate Reverse
return new Iterable<T>() {
    @Override
    public Iterator<T> iterator() {
        return new Iterator<T>() {
            ListIterator<T> it = elements.listIterator(elements.size());
            @Override
            public boolean hasNext() {
                return it.hasPrevious();
...
StringlistToArrowSep(List strings, String highlightFirst, String highlightSecond, boolean reversed)
list To Arrow Sep
if (strings.isEmpty())
    return "&6None";
StringBuilder sb = new StringBuilder();
for (String s : strings) {
    if (s.equalsIgnoreCase(highlightFirst)) {
        sb.append("&b").append(s).append("&4").append(reversed ? " <--- " : " ---> ");
    } else if (s.equalsIgnoreCase(highlightSecond)) {
        sb.append("&b").append(s).append("&7").append(reversed ? " <--- " : " ---> ");
...