refactor toInt() and related machinery into Node
[sbp.git] / src / edu / berkeley / sbp / Node.java
index 872e377..1dcf050 100644 (file)
@@ -11,7 +11,8 @@ import java.util.*;
 import java.lang.reflect.*;
 
 class Node
-    implements GraphViz.ToGraphViz {
+    implements IntegerMappable,
+               GraphViz.ToGraphViz {
 
     // GraphViz //////////////////////////////////////////////////////////////////////////////
 
@@ -36,4 +37,11 @@ class Node
     }
     public boolean isTransparent() { return false; }
     public boolean isHidden() { return false; }
+
+    // IntegerMappable ////////////////////////////////////////////////////////////
+
+    private static int node_idx = 0;
+    private final int idx = node_idx++;
+    public int toInt() { return idx; }
+
 }
\ No newline at end of file