org.jikesrvm.compilers.opt.util
Class DFSenumerateByFinish

java.lang.Object
  extended by org.jikesrvm.compilers.opt.util.Stack<GraphNode>
      extended by org.jikesrvm.compilers.opt.util.DFSenumerateByFinish
All Implemented Interfaces:
Iterable<GraphNode>, Enumeration<GraphNode>, GraphNodeEnumeration
Direct Known Subclasses:
FilteredDFSenumerateByFinish, ReverseDFSenumerateByFinish

public class DFSenumerateByFinish
extends Stack<GraphNode>
implements GraphNodeEnumeration

This class implements depth-first search over a Graph, return an enumeration of the nodes of the graph in order of increasing finishing time. This class follows the outNodes of the graph nodes to define the graph, but this behavior can be changed by overriding the getConnected method.


Field Summary
 GraphNode currentRoot
          While a depth-first enumeration is in progress, this field holds the current root node, i.e. the current botton of the search stack (assuming stacks grow upward).
private  GraphNodeEnumeration e
          an enumeration of all nodes to search from
private  GraphNodeEnumeration[] info
          an enumeration of child nodes for each node being searched
private  GraphNode theNextElement
          the current next element in finishing time order
 
Constructor Summary
protected DFSenumerateByFinish(Graph net)
          Construct a depth-first enumerator across all the nodes of a graph.
  DFSenumerateByFinish(Graph net, GraphNodeEnumeration nodes)
          Construct a depth-first enumerator across the (possibly improper) subset of nodes reachable from the nodes in the given enumeration.
 
Method Summary
protected  GraphNodeEnumeration getConnected(GraphNode n)
          get the out edges of a given node
 boolean hasMoreElements()
          Return whether there are any more nodes left to enumerate.
 GraphNode next()
          Find the next graph node in finishing time order.
 GraphNode nextElement()
          Wrapper for next() to make the Enumeration interface happy
 
Methods inherited from class org.jikesrvm.compilers.opt.util.Stack
compare, copy, empty, getTOS, isEmpty, iterator, peek, pop, push, shallowCopy, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

currentRoot

public GraphNode currentRoot
While a depth-first enumeration is in progress, this field holds the current root node, i.e. the current botton of the search stack (assuming stacks grow upward). This is used primarily when constructing strongly connected components.


theNextElement

private GraphNode theNextElement
the current next element in finishing time order


e

private final GraphNodeEnumeration e
an enumeration of all nodes to search from


info

private final GraphNodeEnumeration[] info
an enumeration of child nodes for each node being searched

Constructor Detail

DFSenumerateByFinish

protected DFSenumerateByFinish(Graph net)
Construct a depth-first enumerator across all the nodes of a graph.

Parameters:
net - the graph whose nodes to enumerate

DFSenumerateByFinish

public DFSenumerateByFinish(Graph net,
                            GraphNodeEnumeration nodes)
Construct a depth-first enumerator across the (possibly improper) subset of nodes reachable from the nodes in the given enumeration.

Parameters:
net - the graph whose nodes to enumerate
nodes - the set of nodes from which to start searching
Method Detail

hasMoreElements

public boolean hasMoreElements()
Return whether there are any more nodes left to enumerate.

Specified by:
hasMoreElements in interface Enumeration<GraphNode>
Returns:
true if there nodes left to enumerate.

next

public GraphNode next()
Find the next graph node in finishing time order.

Specified by:
next in interface GraphNodeEnumeration
Returns:
the next graph node in finishing time order.
See Also:
nextElement()

nextElement

public GraphNode nextElement()
Wrapper for next() to make the Enumeration interface happy

Specified by:
nextElement in interface Enumeration<GraphNode>
Returns:
the next node in finishing time order
See Also:
next()

getConnected

protected GraphNodeEnumeration getConnected(GraphNode n)
get the out edges of a given node

Parameters:
n - the node of which to get the out edges
Returns:
the out edges