The dictionary data structure
As we have already learned, a set is a collection of distinct elements (non-repeated elements). A dictionary is used to store [key, value] pairs, where the key could be used to find a particular element. A dictionary is very similar to a set; a set stores a [key, key] collection of elements, and a dictionary stores a [key, value] collection of elements. A dictionary is also known as a map, symbol table, and an associative array.
In computer science, dictionaries are often used to store the reference address of objects. For example, if we open theChrome
| Developer tools
in the Memory
tab and run a snapshot
, we will be able to see some objects and their respective address references in the memory (represented by@<number>
). We can see this scenario in the following screenshot:
In this chapter, we will also cover some examples of how to use the dictionary data structure in real world projects: a dictionary itself (the words and their definitions) and an address...