From f977bbc6aaa3399ee5ab5903f4dc5e87885f0ff1 Mon Sep 17 00:00:00 2001 From: sjfink Date: Fri, 5 Dec 2008 22:00:57 +0000 Subject: [PATCH] a few more generics git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3124 f5eafffb-2e1d-0410-98e4-8ec43c5233c4 --- .../util/graph/traverse/DFSPathFinder.java | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/DFSPathFinder.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/DFSPathFinder.java index a605865e9..9c59f57e0 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/DFSPathFinder.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/DFSPathFinder.java @@ -24,13 +24,10 @@ import com.ibm.wala.util.debug.Assertions; import com.ibm.wala.util.graph.Graph; /** - * This class searches depth-first search for node that matches some - * criteria. - * If found, it reports a path to the first node found. + * This class searches depth-first search for node that matches some criteria. If found, it reports a path to the first node found. * - * This class follows the outNodes of the - * graph nodes to define the graph, but this behavior can be changed - * by overriding the getConnected method. + * This class follows the outNodes of the graph nodes to define the graph, but this behavior can be changed by overriding the + * getConnected method. */ public class DFSPathFinder extends Stack { public static final long serialVersionUID = 9939900773328288L; @@ -56,16 +53,15 @@ public class DFSPathFinder extends Stack { final private Map> pendingChildren = HashMapFactory.make(25); /** - * Flag recording whether initialization has happened. + * Flag recording whether initialization has happened. */ private boolean initialized = false; /** - * Construct a depth-first enumerator starting with a particular node - * in a directed graph. - * + * Construct a depth-first enumerator starting with a particular node in a directed graph. + * * @param G the graph whose nodes to enumerate - * @throws IllegalArgumentException if G is null + * @throws IllegalArgumentException if G is null */ public DFSPathFinder(Graph G, T N, Filter f) throws IllegalArgumentException { if (G == null) { @@ -80,10 +76,9 @@ public class DFSPathFinder extends Stack { } /** - * Construct a depth-first enumerator across the (possibly - * improper) subset of nodes reachable from the nodes in the given - * enumeration. - * + * Construct a depth-first enumerator across the (possibly improper) subset of nodes reachable from the nodes in the given + * enumeration. + * * @param nodes the set of nodes from which to start searching */ public DFSPathFinder(Graph G, Iterator nodes, Filter f) { @@ -102,19 +97,18 @@ public class DFSPathFinder extends Stack { } /** - * @return a List of nodes that specifies the first path found - * from a root to a node accepted by the filter. Returns null if - * no path found. + * @return a List of nodes that specifies the first path found from a root to a node accepted by the filter. Returns null if no + * path found. */ - public List find() { + public List find() { if (!initialized) { init(); } while (hasNext()) { T n = peek(); if (filter.accepts(n)) { - List path = currentPath(); - advance(); + List path = currentPath(); + advance(); return path; } advance(); @@ -124,7 +118,7 @@ public class DFSPathFinder extends Stack { private List currentPath() { ArrayList result = new ArrayList(); - for(Iterator path = iterator(); path.hasNext(); ) { + for (Iterator path = iterator(); path.hasNext();) { result.add(0, path.next()); } return result; @@ -132,7 +126,7 @@ public class DFSPathFinder extends Stack { /** * Return whether there are any more nodes left to enumerate. - * + * * @return true if there nodes left to enumerate. */ public boolean hasNext() { @@ -141,13 +135,16 @@ public class DFSPathFinder extends Stack { /** * Method getPendingChildren. + * * @return Object */ private Iterator getPendingChildren(T n) { return pendingChildren.get(n); } + /** * Method setPendingChildren. + * * @param v * @param iterator */ @@ -179,7 +176,7 @@ public class DFSPathFinder extends Stack { return; } } - // didn't find any new children. pop the stack and try again. + // didn't find any new children. pop the stack and try again. pop(); } while (!empty()); @@ -198,10 +195,10 @@ public class DFSPathFinder extends Stack { /** * get the out edges of a given node - * + * * @param n the node of which to get the out edges * @return the out edges - * + * */ protected Iterator getConnected(T n) { return G.getSuccNodes(n);