harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [classlib] Some further study on hashcode and HashMap
Date Wed, 04 Jul 2007 19:23:16 GMT
Jimmy,Jing Lv wrote:
> 2007/7/4, Tim Ellison <t.p.ellison@gmail.com>:
>> Sorry for being so dumb, but how can you devise an expression that will
>> produce a better bucket index from a hashcode if you don't know anything
>> about the characteristics of the hashcode?
>>
> 
> Ah, I really don't know how to produce a better bucket index from a
> hashcode if I don't know anything about the characteristics of the
> hashcode. So I just take hypothesis that the hashcode should be random
> itself, and in this scenario can we go further to do some tuning.
> All suggestion here is used for HashMap implementation, as we dicussed
> before (maybe also good for hash-related classes ;) )

Ok, just checking ;-)
So how about I commit the proposed changes to make the numBuckets a
power of two, with a hashCode modification that does the simple right
shift to accommodate the existing VM identityHashCode implementations?

   int bucket = (hashCode >>> 2) & (numBuckets - 1);

Once the VMs improve their hashcode implementation this will still work
as well, but we can remove the shift too.

Regards,
Tim

Mime
View raw message