From 56ad76197269888504dd07ac173693bec613c046 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 4 Feb 2009 08:57:22 +0000 Subject: [PATCH] bug fixes --- .../src/ClassLibrary/DistributedHashMap.java | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/Robust/src/ClassLibrary/DistributedHashMap.java b/Robust/src/ClassLibrary/DistributedHashMap.java index 9c398b0b..aa00ae4d 100644 --- a/Robust/src/ClassLibrary/DistributedHashMap.java +++ b/Robust/src/ClassLibrary/DistributedHashMap.java @@ -13,28 +13,35 @@ public class DistributedHashMap { this.secondcapacity=secondcapacity; } - private static unsigned int hash1(unsigned int hashcode, int length) { + private static int hash1(int hashcode, int length) { int value=hashcode%length; - return value; + if (value<0) + return -value; + else + return value; } - private static unsigned int hash2(unsigned int hashcode, int length1, int length2) { + private static int hash2(int hashcode, int length1, int length2) { int value=(hashcode*31)%length2; - return value; + if (value<0) + return -value; + else + return value; } void resize(int index) { DHashEntry[] oldtable=table[index].array; int newCapacity=oldtable.length*2+1; - table[index].array=global new DHashEntry[newCapacity]; + DHashEntry []newtable=global new DHashEntry[newCapacity]; + table[index].array=newtable; for(int i=0; i