1 package Analysis.OwnershipAnalysis;
9 public class ChangeTupleSet extends Canonical {
11 private HashSet<ChangeTuple> changeTuples;
13 public ChangeTupleSet() {
14 changeTuples = new HashSet<ChangeTuple>();
17 public ChangeTupleSet(ChangeTuple ct) {
22 public ChangeTupleSet(ChangeTupleSet cts) {
23 changeTuples = (HashSet<ChangeTuple>)cts.changeTuples.clone();
26 public ChangeTupleSet makeCanonical() {
27 return (ChangeTupleSet) Canonical.makeCanonical(this);
30 public Iterator iterator() {
31 return changeTuples.iterator();
35 return changeTuples.size();
38 public ChangeTupleSet union(ChangeTupleSet ctsIn) {
41 ChangeTupleSet ctsOut = new ChangeTupleSet(this);
42 ctsOut.changeTuples.addAll(ctsIn.changeTuples);
43 return ctsOut.makeCanonical();
46 public ChangeTupleSet union(ChangeTuple ctIn) {
49 ChangeTupleSet ctsOut = new ChangeTupleSet(this);
50 ctsOut.changeTuples.add(ctIn);
51 return ctsOut.makeCanonical();
54 public boolean isEmpty() {
55 return changeTuples.isEmpty();
58 public boolean isSubset(ChangeTupleSet ctsIn) {
60 return ctsIn.changeTuples.containsAll(this.changeTuples);
64 public boolean equals(Object o) {
69 if( !(o instanceof ChangeTupleSet) ) {
73 ChangeTupleSet cts = (ChangeTupleSet) o;
74 return changeTuples.equals(cts.changeTuples);
77 private boolean oldHashSet = false;
78 private int oldHash = 0;
79 public int hashCode() {
80 int currentHash = changeTuples.hashCode();
82 if( oldHashSet == false ) {
83 oldHash = currentHash;
86 if( oldHash != currentHash ) {
87 System.out.println("IF YOU SEE THIS A CANONICAL ChangeTupleSet CHANGED");
97 public String toString() {
100 Iterator i = this.iterator();
101 while( i.hasNext() ) {