Added methods equals() and hashCode() to prefetchpair
authoradash <adash>
Thu, 18 Oct 2007 18:55:15 +0000 (18:55 +0000)
committeradash <adash>
Thu, 18 Oct 2007 18:55:15 +0000 (18:55 +0000)
Robust/src/Analysis/Prefetch/PrefetchPair.java

index 1c23f82fbf26c459eba5f8038f48c9deca7ebf01..707a44bd07da8b11249e4c70f3ebd45ff999785c 100644 (file)
@@ -5,23 +5,57 @@ import IR.*;
 
 public class PrefetchPair {
        TempDescriptor td;
-       FieldDescriptor fd;
-       public float num;
+       FieldDescriptor[] fd;
+       int arryindex;
 
        public PrefetchPair() {
        }
 
-       public PrefetchPair(TempDescriptor td, float prob) {
+       public PrefetchPair(TempDescriptor td) {
                this.td = td;
-               num = prob;
+       }
+
+       public PrefetchPair(TempDescriptor td, int index) {
+               this.td = td;
+               fd = new FieldDescriptor[index];
+               arryindex = index;
        }
 
        public TempDescriptor getTemp() {
                return td;
        }
 
+       public FieldDescriptor getField(int index) {
+               return fd[index];
+       }
+
+       public int  getIndex() {
+               return arryindex;
+       }
+
+       public int hashCode() {
+               int hashcode = td.hashCode(); 
+               for(int i=0; i<arryindex; i++) {
+                       hashcode = hashcode ^ fd[i].hashCode();
+               }
+               return hashcode;
+       }
+
        public String toString() {
                //if(getTemp()!=null)
                return"<"+getTemp()+">";
        }
+
+       public boolean equals(Object o) {
+               if(o instanceof PrefetchPair) {
+                       PrefetchPair pp = (PrefetchPair) o;
+                       if(td != pp.td)
+                               return false;
+                       for(int i=0; i< arryindex; i++) {
+                               if(!fd[i].equals(pp.fd[i]))
+                                       return false;
+                       }
+               }
+               return false;
+       }
 }