1 package gov.nasa.jpf.jvm; 20 21 import java.util.Hashtable ; 22 23 24 31 class DynamicMap { 32 static Hashtable mapping = new Hashtable (); 33 static int counter = 0; 34 35 public static int getEntry (DynamicMapIndex dmi) { 36 return ((Integer ) mapping.get(dmi)).intValue(); 37 } 38 39 public static synchronized int addEntry (DynamicMapIndex dmi) { 40 int idx; 41 Integer index = (Integer ) mapping.get(dmi); 42 43 if (index != null) { 44 return index.intValue(); 45 } 46 47 idx = counter; 48 mapping.put(dmi.clone(), new Integer (idx)); counter++; 50 51 return idx; 52 } 53 54 public static boolean hasEntry (DynamicMapIndex dmi) { 55 return mapping.containsKey(dmi); 56 } 57 58 public static synchronized void init () { 59 mapping = new Hashtable (); 60 counter = 0; 61 } 62 } | Popular Tags |