I am wondering why does Hashtable avoid using negative hashcode ?
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
Where (hash & 0x7FFFFFFF)
makes the signed bit to be 0 to positive, but why couldn't we treat the signed 32 bit integer as unsigned ? or even use the modular tricks to make it become positive. For example,
public static long int_mod(int hashcode, int tab_length){
return (hashcode % tab_length + tab_length) % tab_length;
}