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.
356111
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;
    }
234310
def dfs_paths(path)
      paths = []
      stack = [path]
      seen  = Set.new

      while path = stack.pop
        seen.add(path.last)
        paths << path

        children = yield path.last
        children.reverse_each do |node|
          stack.push(path + [node]) unless seen.include?(node)
        end
      end

      paths
    end
1257412
public Routed<T> route(String path) {
    Routed<T> ret = first.route(path);
    if (ret != null) return ret;

    ret = other.route(path);
    if (ret != null) return ret;

    ret = last.route(path);
    if (ret != null) return ret;

    if (notFound != null) return new Routed<T>(notFound, true, Collections.<String, String>emptyMap());

    return null;
  }
557567
function segments(filepath) {
  const parsed = path.parse(filepath);
  const dirWithoutRoot = parsed.dir.substring(parsed.root.length);

  return dirWithoutRoot
    .split(path.sep)
    .concat(parsed.name)
    .reverse();
}
798133
public static String getNodeFromPath(String path)
    {
        PathUtils.validatePath(path);
        int i = path.lastIndexOf(PATH_SEPARATOR);
        if ( i < 0 )
        {
            return path;
        }
        if ( (i + 1) >= path.length() )
        {
            return "";
        }
        return path.substring(i + 1);
    }
925953
public static String getAllButLastSegment(final List<PathSegment> segments) {
        if (segments.isEmpty()) {
            return "";
        }
        return segments.subList(0, segments.size() - 1).stream().map(PathSegment::getPath)
                    .collect(joining("/"));
    }
165650
def get_path_components(directory):
    
    drive, dirs = os.path.splitdrive(directory)
    folders = []
    previous = ""
    while dirs != previous and dirs != "":
        previous = dirs
        dirs, folder = os.path.split(dirs)
        if folder != "":
            folders.append(folder)
    folders.reverse()
    return drive, folders
816515
public static String pathOnly(String path)
   {
      String curPath = path;
      curPath = curPath.substring(curPath.indexOf("/"));
      curPath = curPath.substring(0, curPath.lastIndexOf("/"));
      if ("".equals(curPath))
      {
         curPath = "/";
      }
      return curPath;
   }
561402
function getSegmentedSubPaths(paths) {
    let segments = new Map();

    // Get earliest Path in tree where paths intersect
    paths[0].getDeepestCommonAncestorFrom(
      paths,
      (lastCommon, index, ancestries) => {
        // found the LCA
        if (!lastCommon.isProgram()) {
          let fnParent;
          if (
            lastCommon.isFunction() &&
            t.isBlockStatement(lastCommon.node.body)
          ) {
            segments.set(lastCommon, paths);
            return;
          } else if (
            !(fnParent = getFunctionParent(lastCommon)).isProgram() &&
            t.isBlockStatement(fnParent.node.body)
          ) {
            segments.set(fnParent, paths);
            return;
          }
        }
        // Deopt and construct segments otherwise
        for (const ancestor of ancestries) {
          const fnPath = getChildFuncion(ancestor);
          if (fnPath === void 0) {
            continue;
          }
          const validDescendants = paths.filter(p => {
            return p.isDescendant(fnPath);
          });
          segments.set(fnPath, validDescendants);
        }
      }
    );
    return segments;
  }
758596
def reversed(self):
        """"""
        newpath = [seg.reversed() for seg in self]
        newpath.reverse()
        return Path(*newpath)
931264
public static String getParentPath(final String path) {
    final int pos = path.lastIndexOf(File.separator);
    if (pos <= 0) {
      return null;
    }
    return path.substring(0, pos);
  }
395548
func (p *Path) Reverse() *Path {
	newPath := NewPath(p.qs)
	ctx := &newPath.baseContext
	for i := len(p.stack) - 1; i >= 0; i-- {
		var revMorphism morphism
		revMorphism, ctx = p.stack[i].Reversal(ctx)
		newPath.stack = append(newPath.stack, revMorphism)
	}
	return newPath
}
784864
private String doBackwardPathOnly(final FedoraResource resource) {

        final String path = reverse.convert(resource.getPath());
        if (path == null) {
            throw new RepositoryRuntimeException("Unable to process reverse chain for resource " + resource);
        }

        return convertToExternalPath(path);
    }
1212342
public static Geometry reverse(Geometry geometry) {
        if (geometry == null) {
            return null;
        }
        if (geometry instanceof MultiPoint) {
            return reverseMultiPoint((MultiPoint) geometry);
        }
        return geometry.reverse();
    }
756228
function pathStrToPathArr(path) {
	path = path.substr(1).split('/').map(part => {
		// De-tokenize '/' characters in path name
		return part.replace(/~1/g, '/');
	});

	// For some reason, path arrays whose only item is an empty string cause errors.
	// In this case, we replace the path with an empty array, which seems to be fine.
	if (path.length === 1 && path[0] === '') {
		path = [];
	}

	return path;
}
446187
final long reversePart(long v, int maxBits) {
        long rest = v & (~((1L << maxBits) - 1));
        return rest | reverse(v, maxBits);
    }
153214
public LinkedList<PlanNode> getPathTo( PlanNode descendant ) {
        assert descendant != null;
        LinkedList<PlanNode> stack = new LinkedList<PlanNode>();
        PlanNode node = descendant;
        while (node != this) {
            stack.addFirst(node);
            node = node.getParent();
            assert node != null : "The supplied node is not a descendant of this node";
        }
        stack.addFirst(this);
        return stack;
    }