2

I'm currently learning about hash table. Hashing integers are easy, but my assignment is to hash strings. I have given strings:

25674316-6058714                
56105665-7450612                
96917015-1417157                
48189873-3313151    

I have to hash them to fit into array of buckets[4]. How do I hash strings?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
jvsper
  • 41
  • 4

1 Answers1

4

With the standard libraries hash function:

std::string stringToHash = "25674316-6058714";
size_t result = std::hash<std::string>()(stringToHash);
Matthias247
  • 9,836
  • 1
  • 20
  • 29