Start here · Essential guide
Hash Sets in C++ With std::unordered_set
Learn how std::unordered_set works in C++: inserting, finding, erasing and looping over unique elements, with code examples and common mistakes to avoid.
Strings, Containers and Memory
How std::unordered_set works and how hash sets compare with maps and lists.
Start here · Essential guide
Learn how std::unordered_set works in C++: inserting, finding, erasing and looping over unique elements, with code examples and common mistakes to avoid.
Yes, C# has HashSet<T>, but C++ uses std::unordered_set for the same job. Here is a name mapping and a short example that compares the two languages.
A HashSet is a collection of unique items found by hashing. Learn how hashing works and how std::unordered_set stores items in C++, with a small example.
Neither HashSet nor HashMap is faster in general. A set stores only keys and a map stores key-value pairs, so the right pick depends on your data.
Use a hash set when you need fast membership checks and unique items; use a list when order, indexing or duplicates matter. Compare C# and C++ examples.
Related topics