change
authorbdemsky <bdemsky>
Thu, 12 Feb 2009 04:00:20 +0000 (04:00 +0000)
committerbdemsky <bdemsky>
Thu, 12 Feb 2009 04:00:20 +0000 (04:00 +0000)
Robust/src/ClassLibrary/DistributedHashMap.java

index b3aac7b384aa6717d5ce4f30b9455a6b49d1c69b..c6444a0499ebfb485885023802f7dbe46048a3cb 100644 (file)
@@ -122,13 +122,6 @@ public class DistributedHashMap {
       dhe=global new DistributedHashEntry(secondcapacity);
       table[index1]=dhe;
     }
-
-    dhe.count++;
-    if (dhe.count>(loadFactor*dhe.array.length)) {
-      //Resize the table
-      resize(index1);
-    }
-
     int index2=hash2(hashcode, table.length, dhe.array.length);
     DHashEntry ptr=dhe.array[index2];
 
@@ -136,17 +129,23 @@ public class DistributedHashMap {
       if (ptr.hashval!=hashcode&&ptr.key.equals(key)) {
        Object oldvalue=ptr.value;
        ptr.value=value;
-       dhe.count--;
        return oldvalue;
       }
       ptr=ptr.next;
     }
+
     DHashEntry he=global new DHashEntry();
     he.value=value;
     he.key=key;
     he.hashval=hashcode;
     he.next=dhe.array[index2];
     dhe.array[index2]=he;
+
+    dhe.count++;
+    if (dhe.count>(loadFactor*dhe.array.length)) {
+      //Resize the table
+      resize(index1);
+    }
     return null;
   }
 }