Dictionaries
The topic of Chapter 6, Dictionaries and Sets, was related to dictionaries and sets. First, let’s recap a dictionary, which allows mapping keys to values and performing fast lookups. A dictionary uses a hash function and can be understood as a collection of pairs, each consisting of a key and a value.
There are two built-in versions of a dictionary – non-generic (Hashtable
) and generic (Dictionary
). The sorted variant of a dictionary (SortedDictionary
) is available, as well. All of them were described in detail.
The mechanism of a hash table is presented in the following illustration:
Figure 10.6 – Illustration of mapping keys to particular values
Due to the great performance of the hash table, such a data structure is frequently used in many real-world applications, such as for associative arrays, database indices, or cache systems. Within this book, you saw how to create a phone book to store entries where a person...