#Hashing (Hashing Values)

By Dietmar Kühl

Hashing values is an important technique for efficient associative containers. It has multiple independent dimensions of considerations. None of these considerations is generally well understood. This presentation scratches the surface of the following areas:

  • Using hash functions for associative containers.

  • Hashing byte sequences into hash values and assessing the quality of hash functions.

  • Extracting byte sequences from values and hashing the resulting byte sequences.

  • Things to consider for a default hashing function.

The creation of containers and hashing functions is typically done by specialists. The primary intention of discussing them is to give an idea why applications should stay away from custom implementations. On the other hand provision of hash values for user-defined types is rather common-place to support their use as keys of associative containers. Thus, this presentation will have an emphasis on the important aspects for providing hash values for user-defined types:

  • The relation between equality and hash values.

  • Taking care of sequences to avoid collisions for empty sequences.

  • Interaction of hash values between different types ("transparency").

The code examples use C++. However, the various considerations are language independent and their understanding will be useful when using other programming languages, too.