A Reminder of HashSets for Beginner Devs

There are a handful of uses for HashSets. For example, when you do NOT want duplicate values or when you want to transform a list containing duplicate values into a set.

A HashSet is an object based on a 'key/value' pair that contains unique elements (i.e. no duplicate values). In a HashSet, the hash code (used to store the data) is calculated from a hash function based on the key (an ex: f() = key % 10 assuming key is an integer)

% = mod

Now, you will most likely have duplicate values stored in the same hash code. This is where linear probing (array implementation) and separate chaining (pointers implementation) come in.

Fortunately for us, most if not all programming languages have in built-in libraries for this such as: Python: the set() method or assigning a set object to a variable Java: import java.util.HashSet and create a new HashSet from that library

So, though you will most likely not need to build a HashSet from scratch, it is important to know what they are, how they work, and when to use them.