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 if (sizemap.containsKey(sd))
20 return ((Integer)sizemap.get(sd)).intValue();
24 public Constraint getConstraint(SetDescriptor sd) {
25 return (Constraint)constraintmap.get(sd);
28 private void computesizes() {
29 for(Iterator it=state.stSets.descriptors();it.hasNext();) {
30 SetDescriptor sd=(SetDescriptor)it.next();
31 for(int i=0;i<state.vConstraints.size();i++) {
32 Constraint c=(Constraint)state.vConstraints.get(i);
33 if (c.numQuantifiers()!=0)
35 DNFConstraint dconst=c.dnfconstraint;
38 for(int j=0;j<dconst.size();j++) {
39 Conjunction conj=dconst.get(j);
40 boolean goodmatch=false;
41 for(int k=0;k<conj.size();k++) {
42 DNFPredicate dpred=conj.get(k);
43 if (!dpred.isNegated()) {
44 Predicate p=dpred.getPredicate();
45 if (p instanceof ExprPredicate) {
46 ExprPredicate ep=(ExprPredicate)p;
47 if (ep.getType()==ExprPredicate.SIZE&&
48 ep.getOp()==Opcode.EQ&&
49 ep.getDescriptor()==sd&&
52 oldsize=ep.rightSize();
56 if (oldsize==ep.rightSize()) {
67 break; //this constraint won't work
71 System.out.println("Set "+sd.toString()+" has size "+oldsize);
72 sizemap.put(sd,new Integer(oldsize));
73 constraintmap.put(sd,c);