C++ Hash Tables
As we mentioned previously, the lookup operation is quite frequent in most applications. However, we may not always encounter positive integers, which are quite easy to hash. You are likely to encounter strings most of the time. Consider the example of an English language dictionary that we considered earlier. We can store the dictionary data by using the words as keys and the word definitions as the values. Another example is the hospital records database we considered in Chapter 1, Lists, Stacks, and Queues, where the patients' names may be used as keys, and other related information could be stored as values.
The simple modulo function we used earlier to calculate the hash values of integers does not work for strings. An easy option is to calculate the modulo of the sum of the ASCII values of all the characters. However, all the permutations of characters in a string would be quite vast, and this would create a lot of collisions.
C++ provides a function called std:...