Added reachability classes, all of which are extensions of Canonical such that
[IRC.git] / Robust / src / Analysis / OwnershipAnalysis / ChangeTupleSet.java
1 package Analysis.OwnershipAnalysis;
2
3 import IR.*;
4 import IR.Flat.*;
5 import java.util.*;
6 import java.io.*;
7
8
9 public class ChangeTupleSet extends Canonical {
10
11     private HashSet<ChangeTuple> changeTuples;
12
13     public ChangeTupleSet() {
14         changeTuples = new HashSet<ChangeTuple>();
15     }
16
17     public ChangeTupleSet( ChangeTuple ct ) {
18         this();
19         changeTuples.add( ct );
20     }
21
22     public ChangeTupleSet( ChangeTupleSet cts ) {
23         changeTuples = (HashSet<ChangeTuple>) cts.changeTuples.clone(); //COPY?!
24     }
25
26     public ChangeTupleSet makeCanonical() {
27         return (ChangeTupleSet) Canonical.makeCanonical( this );
28     }
29
30     public Iterator iterator() {
31         return changeTuples.iterator();
32     }
33
34     public ChangeTupleSet union( ChangeTupleSet ctsIn ) {
35         ChangeTupleSet ctsOut = new ChangeTupleSet( this );
36         ctsOut.changeTuples.addAll( ctsIn.changeTuples );
37         return ctsOut.makeCanonical();
38     }
39
40     public boolean isSubset( ChangeTupleSet ctsIn ) {
41         return ctsIn.changeTuples.containsAll( this.changeTuples );
42     }
43
44     public boolean equals( Object o ) {
45         if( !(o instanceof ChangeTupleSet) ) {
46             return false;
47         }
48
49         ChangeTupleSet cts = (ChangeTupleSet) o;
50         return changeTuples.equals( cts.changeTuples );
51     }
52
53     public int hashCode() {
54         return changeTuples.hashCode();
55     }
56
57     public String toString() {
58         String s = "[";
59
60         Iterator i = this.iterator();
61         while( i.hasNext() ) {
62             s += "\n  "+i.next();
63         }
64
65         s += "\n]";
66
67         return s;
68     }
69 }