permaculture playing cards*
The moose likes Java in General and the fly likes Hash function in HashMap method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hash function in HashMap method" Watch "Hash function in HashMap method" New topic
Author

Hash function in HashMap method

Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 254

As per my understanding HashMap applies a supplemental hash function to a given hashCode, which defends against poor quality hash functions.
While looking in the HashMap code, I figured out that below method is being used for this purpose, Can any one help me in understanding below queries ? -

1-How does this function insure that a less number of buckets would be created than the range of integer?
2- How many maximum buckets would be made while using this hash function?
3- Why the programmer has used specific numbers ie 20, 12,7, 4 to be used in shift operation?
4- why the programmer has used right shift and XOR operator?



Regards
Salil Verma


Regards
Salil Verma
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hash function in HashMap method