/** * Travel dependencies tree by DFS and Post-Order algorithm. * * @param tree The initial tree which contains root node only. * @param footprint The footprint of the traversal. * @param output Output queue of combined files. */ private void travel( Stack<ArrayList<String>> tree, Stack<String> footprint, ArrayList<String> output) { for (String node : tree.peek()) { // Detect circular dependences by looking back footprint. if (footprint.contains(node)) { String msg = "Circular dependences was found\n"; for (String path : footprint) { msg += " " + path + " ->\n"; } msg += " " + node; App.exit(msg); } // Skip visited node. if (output.contains(node)) { continue; } // Move forward. footprint.push(node); // Add sub nodes. tree.push(getDependencies(node)); // Travel sub nodes. travel(tree, footprint, output); // Clean visited nodes. tree.pop(); // Move backward. footprint.pop(); // Add first visited node to output queue. output.add(node); } }
public static void getValue(Stack<String> a, String name) { if (a.contains("Isenbaev")) {} }