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.contains(set1)&&((Set)subset.get(set1)).contains(set2);
27 public boolean noIntersection(SetDescriptor set1, SetDescriptor set2) {
28 return intersection.contains(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 SetDescriptor subsetsd=(SetDescriptor)st.pop();
40 System.out.print(subsetsd.toString());
42 st.addAll(subsetsd.getSubsets());
43 if (!subset.contains(sd))
44 subset.put(sd,new HashSet());
45 ((HashSet)subset.get(sd)).addAll(subsetsd.getSubsets());
46 for(Iterator it=subsetsd.getSubsets().iterator();it.hasNext();) {
47 SetDescriptor sd2=(SetDescriptor)it.next();
48 if (!superset.contains(sd2))
49 superset.put(sd2,new HashSet());
50 ((HashSet)superset.get(sd2)).add(sd);
54 for(int i=0;i<descriptors.size();i++) {
55 SetDescriptor sd=(SetDescriptor)descriptors.get(i);
56 if (sd.isPartition()) {
57 Vector subst=sd.getSubsets();
58 for(Iterator it1=subst.iterator();it1.hasNext();) {
59 SetDescriptor sd1=(SetDescriptor)it1.next();
60 for(Iterator it2=subst.iterator();it2.hasNext();) {
61 SetDescriptor sd2=(SetDescriptor)it2.next();
63 for(Iterator it3=sd1.allSubsets().iterator();it3.hasNext();) {
64 SetDescriptor sd3=(SetDescriptor)it3.next();
66 if (!intersection.contains(sd3))
67 intersection.put(sd3,new HashSet());
68 ((HashSet)intersection.get(sd3)).addAll(sd2.allSubsets());