Jump to content

C++: Difference between revisions

86 bytes added ,  30 June 2022
Line 550: Line 550:
Also known as maps or associative arrays.
Also known as maps or associative arrays.
====std::unordered_set====
====std::unordered_set====
[https://en.cppreference.com/w/cpp/container/unordered_set reference]<br>
<code>#include <unordered_set></code><br>
<code>#include <unordered_set></code><br>
This is a hashset.<br>
This is a hashset.<br>
<syntaxhighlight lang="cpp>
<syntaxhighlight lang="cpp>
std::unordered_set<int> my_set;
std::unordered_set<int> my_set;
// add things to myset
// Add
my_set.insert(5);
my_set.insert(5);
// Check contains
// Check contains
my_set.find(5) != my_set.end();
my_set.find(5) != my_set.end();
// Remove
my_set.erase(5);
</syntaxhighlight>
</syntaxhighlight>
====std::unordered_map====
====std::unordered_map====
;Custom Keys
;Custom Keys