HashSet<T>
The .NET collection of unique items that answers 'have I seen this one already?' in constant time.
In more detail
It keeps no order and uses each item's hash code to find it. Adding a duplicate is ignored, so spreading an array into a HashSet drops repeats.
Related terms
- collection — An object that holds a group of items, such as a list, dictionary, set or array.
- Dictionary<TKey, TValue> — The .NET collection that maps unique keys to values and finds a value by its key in constant time by hashing the key.
- GetHashCode — The method that returns a number summarising an object, used by hash-based collections such as Dictionary and HashSet to find it quickly.
Taught in
- Classes, Interfaces, and Object-Oriented C# — Modern .NET Core, C# & Enterprise Microservices
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices