clean up some equal methods
[IRC.git] / Robust / src / Analysis / Prefetch / PairMap.java
1 /*
2  * PairMap.java
3  * Author: Alokika Dash adash@uci.edu
4  * Date: 11-24-2007
5  */
6
7 package Analysis.Prefetch;
8 import IR.Flat.*;
9 import java.util.*;
10 import IR.*;
11
12 /**
13  * Descriptor
14  * This class is used to represent mappings between Prefetch sets of a parent and
15  * child flatnode m(PSchildnode --> PSparentnode) Such analysis  is used to insert
16  * prefetches during static analysis
17  */
18
19 public class PairMap {
20     public HashMap<PrefetchPair, PrefetchPair>  mappair;
21     
22     public PairMap() {
23         mappair = new HashMap<PrefetchPair, PrefetchPair>();
24     }
25     
26     public void addPair(PrefetchPair ppKey, PrefetchPair ppValue) {
27         mappair.put(ppKey, ppValue);
28     }
29     
30     public void removePair(PrefetchPair ppKey) {
31         mappair.remove(ppKey);
32     }
33     
34     public PrefetchPair getPair(PrefetchPair ppKey) {
35         if(mappair != null) 
36             return mappair.get(ppKey);
37         return null;
38     }
39     
40     public int hashCode() {
41         return mappair.hashCode();
42     }
43     
44     public int size() {
45         return mappair.size();
46     }
47     
48     public boolean contains(PrefetchPair ppKey) {
49         if(mappair.containsKey(ppKey))
50             return true;
51         return false;
52     }
53
54     public String toString() {
55         String label = null;
56         Set mapping = mappair.entrySet();
57         Iterator it = mapping.iterator();
58         label = "Mappings are:  ";
59         for(;it.hasNext();) {
60             Object o = it.next();
61             label += o.toString() + " , ";
62         }
63         return label;
64     }
65
66     public boolean equals(Object o) {
67         if(o instanceof PairMap) {
68             PairMap pm = (PairMap) o;
69             return mappair.equals(pm.mappair);
70         }
71         return false;
72     }
73     
74     public boolean isEmpty() {
75         return mappair.isEmpty();
76     }
77 }