commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Berin Loritsch" <blorit...@apache.org>
Subject RE: [collections] Avalon excalibur collections migration status
Date Wed, 10 Jul 2002 13:40:47 GMT
> From: Michael A. Smith [mailto:mas@apache.org] 
> 
> speaking of the hashing algorithm, it looks like you 
> implemented it, but 
> there were no comments added on where it came from: 
> 
> -        final int hash = key.hashCode() % m_buckets.length;
> +        int hash = key.hashCode();
> +        
> +        hash += ~(hash << 9);
> +        hash ^=  (hash >>> 14);
> +        hash +=  (hash << 4);
> +        hash ^=  (hash >>> 10);
> +        
> +        hash %= m_buckets.length;
> +
> 
> Was this based on some reference you found somewhere on 
> implementing a 
> hashing algorithm that isn't dependent on number of buckets, 
> or was it 
> chosen based on emperical evidence?  When I started working on the 
> DynamicBucketMap, I looked into better hashing algorithms in 
> my trusty 
> algorithms book, and didn't see anything quite like what you used.  


;) I cheated.  I could tell you my sources, but you have them too...
Look in your src.jar in your JDK for HashMap....

But shhh....

They actually did "return hash & entries.length" which proved to be
slower for some reason.


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message