8 private Hashtable sizemap;
9 private Hashtable constraintmap;
11 public ExactSize(State state) {
13 this.sizemap=new Hashtable();
14 this.constraintmap=new Hashtable();
18 public int getsize(SetDescriptor sd) {
19 SizeObject so=new SizeObject(sd);
20 if (sizemap.containsKey(so))
21 return ((Integer)sizemap.get(so)).intValue();
25 public Constraint getConstraint(SetDescriptor sd) {
26 SizeObject so=new SizeObject(sd);
27 return (Constraint)constraintmap.get(so);
30 private void computesizes() {
31 for(Iterator it=state.stSets.descriptors();it.hasNext();) {
32 SetDescriptor sd=(SetDescriptor)it.next();
33 for(int i=0;i<state.vConstraints.size();i++) {
34 Constraint c=(Constraint)state.vConstraints.get(i);
35 if (c.numQuantifiers()!=0)
37 DNFConstraint dconst=c.dnfconstraint;
40 for(int j=0;j<dconst.size();j++) {
41 Conjunction conj=dconst.get(j);
42 boolean goodmatch=false;
43 for(int k=0;k<conj.size();k++) {
44 DNFPredicate dpred=conj.get(k);
45 if (!dpred.isNegated()) {
46 Predicate p=dpred.getPredicate();
47 if (p instanceof ExprPredicate) {
48 ExprPredicate ep=(ExprPredicate)p;
49 if (ep.getType()==ExprPredicate.SIZE&&
50 ep.getOp()==Opcode.EQ&&
51 ep.getDescriptor()==sd&&
54 oldsize=ep.rightSize();
58 if (oldsize==ep.rightSize()) {
69 break; //this constraint won't work
73 System.out.println("Set "+sd.toString()+" has size "+oldsize);
74 SizeObject so=new SizeObject(sd);
75 sizemap.put(so,new Integer(oldsize));
76 constraintmap.put(so,c);