#include <bits/stdc++.h>
using namespace std;
// #CPP_STL #Sets #BasicProblem
// https://www.geeksforgeeks.org/set-in-cpp-stl/
int main() {
// A set stores elements in sorted order
// Does NOT contain duplicates
set<int> s;
// =====(IMP)==========
// use unordered_set if sorted order is not required
s.insert(25);
s.insert(25); // Only one 25 will be added to set
s.insert(28);
s.insert(22);
s.insert(2);
for(auto it=s.begin();it!=s.end();it++){
cout<<*it<<" "; // *it = value at it
}
cout<<endl;
//================( find(element) )===========================
// s.find returns iterator if found, else returns s.end()
auto it=s.find(28);
if(it!=s.end()){
cout<<"28 is found"<<endl;
}
//=================(find if an element is present)==================
// =================(s.count(element)==========================
if (hashset.count(2) <= 0) {
cout << "Key 2 is not in the hash set." << endl;
}
//=================( erase(iterator) )=============================
if(s.find(28)!=s.end()){ // check if element is present before trying to delete
s.erase(s.find(28)); // trying to delete a non-existent element returns error
}
for(auto it=s.begin();it!=s.end();it++){
cout<<*it<<" "; // *it = value at it
}
cout<<endl;
it=s.find(28);
if(it!=s.end()){
cout<<"28 is found"<<endl;
}else{
cout<<"28 is not found"<<endl;
}
it=s.find(38);
if(it!=s.end()){
cout<<"38 is found"<<endl;
}else{
cout<<"38 is not found"<<endl;
}
return 0;
}