From: bdemsky Date: Sat, 17 Apr 2004 00:30:28 +0000 (+0000) Subject: Added code to compute maximum sizes of sets. So we can eliminate set removes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8098bc30c0b85814194cb8e53d62ffe5ffe318ef;p=repair.git Added code to compute maximum sizes of sets. So we can eliminate set removes when they aren't necessary. --- diff --git a/Repair/RepairCompiler/MCC/IR/ComputeMaxSize.java b/Repair/RepairCompiler/MCC/IR/ComputeMaxSize.java new file mode 100755 index 0000000..0dec8e0 --- /dev/null +++ b/Repair/RepairCompiler/MCC/IR/ComputeMaxSize.java @@ -0,0 +1,80 @@ +package MCC.IR; +import MCC.State; +import java.util.*; + +/** This class computes the maximum size of sets and relations */ + +public class ComputeMaxSize { + State state; + Hashtable sizemap; /* -1 means infinity */ + + + public ComputeMaxSize(State state) { + this.state=state; + sizemap=new Hashtable(); + computesizes(); + } + + /** This method compute relation and set maximum sizes */ + private void computesizes() { + Vector rules=state.vRules; + boolean change=true; + Set descriptorset=new HashSet(); + descriptorset.addAll(state.stSets.getAllDescriptors()); + descriptorset.addAll(state.stRelations.getAllDescriptors()); + while(change) { + change=false; + for(Iterator dit=descriptorset.iterator();dit.hasNext();) { + Descriptor d=(Descriptor)dit.next(); + if (d instanceof ReservedSetDescriptor) + continue; + int totalsize=0; + for(int i=0;i