• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hash function in HashMap method

 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic