Java List Reverse reversePath(List pathParts)

Here you can find the source of reversePath(List pathParts)

Description

Reverse path and return as a stack.

License

LGPL

Parameter

Parameter Description
pathParts path to reverse

Return

reversed path or an empty stack if no path parts are given. Never return null.

Declaration

public static Stack<String> reversePath(List<String> pathParts) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.*;

public class Main {
    /**/*from   w  w  w  .  ja  va 2s  .c  o m*/
     * Reverse path and return as a stack. First path element is on top of the
     * stack.
     * 
     * @param pathParts path to reverse
     * @return reversed path or an empty stack if no path parts are given. Never
     *         return null.
     */
    public static Stack<String> reversePath(List<String> pathParts) {
        Stack<String> pathStack = new Stack<String>();
        if (pathParts != null) {
            // Needs first extra argument at top of the stack
            for (int i = pathParts.size() - 1; i >= 0; i--) {
                pathStack.push(pathParts.get(i));
            }
        }
        return pathStack;
    }
}

Related

  1. reverseList(List list)
  2. reverseList(List list, boolean shallowCopy)
  3. reverseList2(List list)
  4. reverseListShallowCopy(List list)
  5. reverseOrder(List list)
  6. reversePermutation(final List permutation)
  7. reversePermutation(T[] arr, List p)
  8. reverseSort(final List lines)
  9. reverseUseList(int[] values)