2

Could you please explain and give me some examples of its real life usage?

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
Alpha Sisyphus
  • 1,508
  • 3
  • 19
  • 33

3 Answers3

0

Giving hashtable support for a Java class. Look at the api. An hash function is used to distinguish entities of a same type in a quick way: with hash you don't need to compare all field inside an object every time you are comparing it to another one. Once generating its hash (fingerprint), if you use a hash function that avoids collision, it becomes a quickly method to compare objects because you need only to compare the hash.

Heisenbug
  • 38,762
  • 28
  • 132
  • 190
0

It returns a hashCode for an object which is used in Hashing Based DataStructure (For example : HashMap)

See Also

jmj
  • 237,923
  • 42
  • 401
  • 438
0

Basically if you wish to create a data structure to store objects and have an access time of O(1) you create a hash table. You hash elements of the object into a key which is unique based on the order of characters etc. Once this is done you can access the data quickly. This is usually used for data structures containing strings without a index value being stored with them therefore you wouldn't need to use the "vector" function in c++ or its equivilant in java.

oorosco
  • 246
  • 3
  • 14