Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Operation on Set Container
//Operations on Ordered Sequences #include <iostream> #include <cstdio> #include <set> #include <iterator> #include <utility> #include <algorithm> using namespace std; typedef set<int, less<int> > ISet; typedef ISet::iterator iIterator; typedef multiset<int, less<int> >IMSet; typedef IMSet::iterator mIterator; int main() { initializer_list<int>d1 = {1, 2, 4, 6, 7, 4, 10, 9, 25, 44, 66, 16, 4, 9}; initializer_list<int>d2 = {4,6,7,8,9,10,4,11,16,22,25,29,22,32,33,34}; ISet setA(d1); ISet setB(d2); cout << "Set A:\t[ "; for(auto i: setA){ cout << i << " "; } cout << "]."; cout << "\nSet B:\t[ "; for(auto i: setB){ cout << i << " "; } cout << "]."; // Union of set A and set B // ISet uset; set_union(setA.begin(), setA.end(), setB.begin(), setB.end(), inserter(uset, uset.begin())); cout << "\n\nUnion of A & B\t[ "; for(auto i: uset){ cout << i << " "; } cout << "]."; ISet mset; merge(setA.begin(), setA.end(), setB.begin(), setB.end(), inserter(mset, mset.begin())); cout << "\n\nMerger of A & B\t[ "; for(auto i: mset){ cout << i << " "; } cout << "]."; // Intersection of sets A and B. // ISet iset; set_intersection(setA.begin(), setA.end(), setB.begin(), setB.end(), inserter(iset, iset.begin())); cout << "\n\nIntersection of A & B:\t[ "; for(auto i: iset){ cout << i << " "; } cout << "]."; // Multiset (Difference between merge() and set_union()) // IMSet msetA(d1); IMSet msetB(d2); cout << "\n\nMULTISETS\n"; cout << "\nSet A:\t["; for(auto i: msetA){ cout << i << " "; } cout << "]."; cout << "\nSet B:\t["; for(auto i: msetB){ cout << i << " "; } cout << "]."; IMSet muset; IMSet miset; set_union(msetA.begin(), msetA.end(), msetB.begin(), msetB.end(), inserter(muset, muset.begin())); merge(msetA.begin(), msetA.end(), msetB.begin(), msetB.end(), inserter(miset, miset.begin())); cout << "\n\nUnion:\t[ "; for(auto i : muset){ cout << i << " "; } cout << "]."; cout << "\nmerge:\t[ "; for(auto i : miset){ cout << i << " "; } cout << "]."; return 0; }
run
|
edit
|
history
|
help
0
Boost phoenix. e.g 2: functor
Assigment operator (easy)
typedef char*
without HLD range Quey can be handled by just using segment tree on the FLATTENED TREE (euler tour)
Stok sinifi
dsadasdsa
RegTokIt
virtual function
ISPrime
completeBubbleSort