checkpoint
[sbp.git] / src / edu / berkeley / sbp / Union.java
index b000f95..9ac5e61 100644 (file)
@@ -15,14 +15,15 @@ public class Union extends Element implements Iterable<Sequence> {
     private final List<Sequence> alternatives = new ArrayList<Sequence>();
 
     public Iterator<Sequence> iterator() { return alternatives.iterator(); }
+    public boolean contains(Sequence s) { return alternatives.contains(s); }
 
     Topology toAtom() {
         if (alternatives.size()==0) throw new RuntimeException("cannot build an Atom from a Union with no productions");
         Topology ret = null;
         for(Sequence s : this) {
             Topology a = s.toAtom();
-            if (ret==null) ret = a.dup();
-            else           ret = ret.union(a.dup());
+            if (ret==null) ret = a;
+            else           ret = ret.union(a);
         }
         if (ret==null) throw new RuntimeException("confusion on " + this);
         return ret;