Change tabbing for everything....
[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();
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     assert ctsIn != null;
36
37     ChangeTupleSet ctsOut = new ChangeTupleSet(this);
38     ctsOut.changeTuples.addAll(ctsIn.changeTuples);
39     return ctsOut.makeCanonical();
40   }
41
42   public ChangeTupleSet union(ChangeTuple ctIn) {
43     assert ctIn != null;
44
45     ChangeTupleSet ctsOut = new ChangeTupleSet(this);
46     ctsOut.changeTuples.add(ctIn);
47     return ctsOut.makeCanonical();
48   }
49
50   public boolean isEmpty() {
51     return changeTuples.isEmpty();
52   }
53
54   public boolean isSubset(ChangeTupleSet ctsIn) {
55     assert ctsIn != null;
56     return ctsIn.changeTuples.containsAll(this.changeTuples);
57   }
58
59   public boolean equals(Object o) {
60     if( o == null ) {
61       return false;
62     }
63
64     if( !(o instanceof ChangeTupleSet) ) {
65       return false;
66     }
67
68     ChangeTupleSet cts = (ChangeTupleSet) o;
69     return changeTuples.equals(cts.changeTuples);
70   }
71
72   public int hashCode() {
73     return changeTuples.hashCode();
74   }
75
76   public String toString() {
77     String s = "[";
78
79     Iterator i = this.iterator();
80     while( i.hasNext() ) {
81       s += "\n  "+i.next();
82     }
83
84     s += "\n]";
85
86     return s;
87   }
88 }