* create
```
#include <unordered_set>
using namespace std;
int main () {
unordered_set<int> a; // default constructor
unordered_set<int> b(a); // copy constructor
unordered_set<int> c(move(a)); // move constructor
unordered_set<int> d{1,2,3}; // initializer list constructor
// unordered_set has no fill constructor
unordered_set<int> f(a.begin(),a.end()); // range constructor
unordered_set<int>* g = new unordered_set<int>{1,2,3}; // new operator
delete g;
}
```
* iterator
```
#include <iostream>
#include <unordered_set>
using namespace std;
int main (){
unordered_set<int> s{1,2,3,4,5,1};
for (auto it=s.begin(); it!=s.end(); ++it)
cout<<*it<<",";
auto it=s.begin(); it++; it--;
cout<<endl;
for (auto it=s.cbegin(); it!=s.cend(); ++it)
cout<<*it<<",";
cout<<endl;
}
/*
5,4,3,2,1,
5,4,3,2,1,
*/
```
* add
```
#include <iostream>
#include <unordered_set>
using namespace std;
int main ()
{
unordered_set<int> m;
m.insert(1);
m.emplace(1);
for (auto &i:m)
cout<<i<<";";
cout<<endl;
}
// 1;
```
* change
```
#include <iostream>
#include <unordered_set>
using namespace std;
void p(unordered_set<int>& a) {
for(auto &i:a) cout<<i<<";";
cout<<endl;
}
int main ()
{
unordered_set<int> a{1,2,3,4,5};
unordered_set<int> a1(a), a2(a);
a.swap(a1);
p(a);
}
```
* query
```
#include <iostream>
#include <unordered_set>
using namespace std;
int main() {
unordered_set<int> s{1,2,3,4,5,6};
auto it=s.find(2);
if(it!=s.end()) cout<<"found"<<endl;
cout<<s.count(2)<<endl;
auto r=s.equal_range(3);
for(auto it=r.first; it!=r.second; it++)
cout<<*it<<",";
cout<<endl;
cout<<s.empty()<<endl;
cout<<s.size()<<endl;
cout<<s.max_size()<<endl;
}
/*
found
1
3,
0
6
576460752303423487
*/
```
* delete
```
#include <unordered_set>
using namespace std;
int main () {
unordered_set<int> s{1,2,3,4,5,1,2,3};
s.erase(s.begin());
s.erase(4);
s.clear();
}
```