The hash table
In this section, we will learn about the HashTable class, also known as HashMap, a hash implementation of the Dictionary class.
Hashing consists of finding a value in a data structure in the shortest time possible. You learned in previous chapters that if we want to get a value from a data structure (using a get method), we need to iterate through the structure until we find it. When we use a hash function, we already know which position the value is in, so we can simply retrieve it. A hash function is a function that, given a key, will return an address in the table where the value is.
In computer science, the hash table has several use cases. It can be used as associative arrays, since it is an implementation of the dictionary. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access