1 19 20 package edu.umd.cs.findbugs.ba; 21 22 import java.util.HashMap ; 23 import java.util.Iterator ; 24 25 32 public class CompactLocationNumbering { 33 private HashMap <Location, Integer > locationToNumberMap; 34 private HashMap <Integer , Location> numberToLocationMap; 35 36 41 public CompactLocationNumbering(CFG cfg) { 42 this.locationToNumberMap = new HashMap <Location, Integer >(); 43 this.numberToLocationMap = new HashMap <Integer , Location>(); 44 build(cfg); 45 } 46 47 53 public int getSize() { 54 return locationToNumberMap.size(); 55 } 56 57 65 public int getNumber(Location location) { 66 return locationToNumberMap.get(location).intValue(); 67 } 68 69 75 public Location getLocation(int number) { 76 return numberToLocationMap.get((Integer )(number)); 77 } 78 79 private void build(CFG cfg) { 80 int count = 0; 81 for (Iterator <Location> i = cfg.locationIterator(); i.hasNext(); ) { 82 Integer number = (Integer )(count++); 83 Location location = i.next(); 84 locationToNumberMap.put(location, number); 85 numberToLocationMap.put(number, location); 86 } 87 } 88 } 89 | Popular Tags |