| Author |
Hashing
|
sandeep Talari
Ranch Hand
Joined: Dec 24, 2007
Posts: 63
|
|
|
please anybody help me regarding the Hashing process , what is the concept behind the hashmap,hashtable and hashset can anybody help in neat explained manner.Point is how hashmap,hashtable and hashset rely on hashing
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
For fast lookups, objects are stored in so-called buckets. Each bucket contains objects with the exact same hash code. If the value for a key is looked up, its hash code is calculated first. Then the bucket for that hash code is retrieved. This will decrease the number of objects to search through - instead of checking every single object in the map / set, only the objects in the one bucket will be checked. The better your hash code, the better objects are distributed among buckets, and the faster your map / set becomes. That also shows the reason why the hash code for equal objects should be the same as well - otherwise, the object will not be found. It also shows another issue: you cannot modify objects stored in the map / set (keys for maps only) in such a way that the hash code will change, or it will never be found again.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Hashing
|
|
|