#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
unordered_set <int> numbers;
numbers.insert(10);
numbers.insert(20);
numbers.insert(30);
numbers.insert(40);
cout << "total numbers of 10s are : " << numbers.count(10) << endl;
cout << "size of entire set is : " << numbers.size() << endl;
// travesing set using iterator.
cout << "printing entire set" << endl;
for( auto itr = numbers.begin(); itr != numbers.end(); itr++ )
{
cout << *itr << endl;
}
numbers.erase(10);
// erasing element.
cout << "set after erasing 10" << endl ;
for( auto itr = numbers.begin(); itr != numbers.end(); itr++ )
{
cout << *itr << endl;
}
unordered_set <int>::iterator itr = numbers.find(10);
itr = numbers.find(20);
if( itr != numbers.end() )
{
cout << "element is found :" << endl;
cout << *itr << endl;
cout << "the index number is : " << std::distance(numbers.begin(), itr ) << endl;
}
else
{
cout << "element not found "<< endl;
}
itr = numbers.find(10);
if( itr != numbers.end() )
{
cout << "element is found : " << endl;
cout << *itr << endl;
}
else
{
cout << "element not found" << endl;
}
return 0;
}