more refactoring into Node
[sbp.git] / src / edu / berkeley / sbp / Node.java
index 09718af..1168c78 100644 (file)
@@ -12,13 +12,21 @@ import java.lang.reflect.*;
 
 class Node<OtherNode extends Node>
     implements IntegerMappable,
-               GraphViz.ToGraphViz {
+               GraphViz.ToGraphViz,
+               Iterable<OtherNode> {
 
     protected       FastSet<OtherNode> predecessors = new FastSet<OtherNode>();
     protected       FastSet<OtherNode> successors = new FastSet<OtherNode>();
     //private       HashSet<OtherNode> predecessors = new HashSet<OtherNode>();
     //private       HashSet<OtherNode> successors = new HashSet<OtherNode>();
 
+    public Iterator<OtherNode> iterator() { return predecessors.iterator(); }
+
+    public boolean noSuccessors() { return successors.size()==0; }
+    public boolean predecessorsContains(OtherNode n) {
+        return predecessors.contains(n);
+    }
+
     // GraphViz //////////////////////////////////////////////////////////////////////////////
 
     public GraphViz.StateNode toGraphViz(GraphViz gv) {