5 public class SetAnalysis {
7 Hashtable intersection;
11 public SetAnalysis(State state) {
13 intersection=new Hashtable();
14 subset=new Hashtable();
15 superset=new Hashtable();
19 public Set getSuperset(SetDescriptor set1) {
20 return (Set)superset.get(set1);
23 public boolean isSubset(SetDescriptor set1, SetDescriptor set2) {
24 return subset.containsKey(set1)&&((Set)subset.get(set1)).contains(set2);
27 public boolean noIntersection(SetDescriptor set1, SetDescriptor set2) {
28 return intersection.containsKey(set1)&&((Set)intersection.get(set1)).contains(set2);
32 SymbolTable sets=state.stSets;
33 Vector descriptors=sets.getAllDescriptors();
34 for(int i=0;i<descriptors.size();i++) {
35 SetDescriptor sd=(SetDescriptor)descriptors.get(i);
37 st.addAll(sd.getSubsets());
39 if (!subset.containsKey(sd))
40 subset.put(sd,new HashSet());
41 ((HashSet)subset.get(sd)).addAll(sd.getSubsets());
42 for(Iterator it=sd.getSubsets().iterator();it.hasNext();) {
43 SetDescriptor sd2=(SetDescriptor)it.next();
44 if (!superset.containsKey(sd2))
45 superset.put(sd2,new HashSet());
46 ((HashSet)superset.get(sd2)).add(sd);
50 SetDescriptor subsetsd=(SetDescriptor)st.pop();
52 st.addAll(subsetsd.getSubsets());
53 if (!subset.containsKey(sd))
54 subset.put(sd,new HashSet());
55 ((HashSet)subset.get(sd)).addAll(subsetsd.getSubsets());
56 for(Iterator it=subsetsd.getSubsets().iterator();it.hasNext();) {
57 SetDescriptor sd2=(SetDescriptor)it.next();
58 if (!superset.containsKey(sd2))
59 superset.put(sd2,new HashSet());
60 ((HashSet)superset.get(sd2)).add(sd);
64 for(int i=0;i<descriptors.size();i++) {
65 SetDescriptor sd=(SetDescriptor)descriptors.get(i);
66 if (sd.isPartition()) {
67 Vector subst=sd.getSubsets();
68 for(Iterator it1=subst.iterator();it1.hasNext();) {
69 SetDescriptor sd1=(SetDescriptor)it1.next();
70 for(Iterator it2=subst.iterator();it2.hasNext();) {
71 SetDescriptor sd2=(SetDescriptor)it2.next();
73 for(Iterator it3=sd1.allSubsets().iterator();it3.hasNext();) {
74 SetDescriptor sd3=(SetDescriptor)it3.next();
76 if (!intersection.containsKey(sd3))
77 intersection.put(sd3,new HashSet());
78 ((HashSet)intersection.get(sd3)).addAll(sd2.allSubsets());