Exemplo n.º 1
0
 private boolean put_table(java.lang.Object key, int val) {
   int index = hash(key);
   for (Entry e = map[index]; e != null; e = e.next) {
     if (e.key == key) {
       if (e.val != val) {
         throw wrapper.duplicateIndirectionOffset();
       }
       // if we get here we are trying to put in the same key/val pair
       // this is a no-op, so we just return
       return false;
     }
   }
   // this means the key is not present in our table
   // then it shouldnt be present in our reverse table either
   Entry newEntry = new Entry(key, val);
   newEntry.next = map[index];
   map[index] = newEntry;
   if (!noReverseMap) {
     int rindex = hash(val);
     newEntry.rnext = rmap[rindex];
     rmap[rindex] = newEntry;
   }
   return true;
 }