You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Set initialization
set <int> s;
cout << endl;
// Set insertion
cout << "Insertion in set " << endl;
cout << endl;
for (int i = 0; i < n; i++)
{
s.insert(a[i]);
}
// Set display
cout << "Display of set element" << endl;
for (auto i = s.begin(); i != s.end(); i++)
{
cout << *i << "";
}
// Unordered Set initialization
unordered_set <int> s1;
cout << endl;
// Unordered set insertion
cout << "Insertion in unordered set " << endl;
for (int i = 0; i < n; i++)
{
s1.insert(a[i]);
}
// Unordered set display
cout << "Display of unordered set element" << endl;
for (auto i = s1.begin(); i != s1.end(); i++)
{
cout << *i << "";
}
// List initialization
list <int> LI;
list <int>::iterator it;
// Inserts elements at end of list
LI.push_back(4);
// Inserts elements at beginning of list
LI.push_front(3);
// Returns reference to first element of list
it = LI.begin();
// Inserts 1 before first element of list
LI.insert(it,1);
// List traversalfor(it = LI.begin();it!=LI.end();it++)
{
cout<<*it<<"";
}
cout<<endl;
// Reverse elements of list
LI.reverse();
// Removes all occurrences of 5 from list
LI.remove(5);
// Removes last element from list
LI.pop_back();
// Removes first element from list
LI.pop_front();