//the usage of multimap is as same as the map
#include<iostream>#include<map>#include<string>using namespace std;typedef map<int,string> MAP_INT_STR;typedef pair<int,string> PAIR_INT_STR;template<typename ITERATOR>void print_map_item(ITERATOR it){ cout<<(*it).first<<","<<(*it).second<<endl;}i...
//map's constructor,and the multimap's constructor is as some as the map's#include<iostream>#include<map>#include<iterator>using namespace std;int main(void){ typedef pair<int,int> Int_Pair; map<int,int>::iterator Iter; map<int,int> map1; //empty map map<int,int,less<int> > map2; ...
//multiset
#include<iostream>#include<set>#include<algorithm>using namespace std;int main(void){ multiset<int> mul1; //default constructor int arr[] = {0,0,1,1,2,3,4,5}; multiset<int> mul2(arr,arr+8); multiset<int> mul3(mul2); multiset<int>::iterator Iter; multiset<int>::...
#include<iostream>#include<set>using namespace std;int main(void){ set<int> s1; int arr[] = {0,0,0,0,1,1,2,3}; set<int> s2(arr,arr+8); //construct from a range set<int> s3(s2); set<int>::iterator Iter; set<int>::reverse_iterator RevIter; if (s1.empty()) cout<<"set s1 is em...
//set//multiset's constructor is as same as the set#include<iostream>#include<set>using namespace std;int main(void){ set<int>::iterator Iter; //set<int>::iterator s1_Iter,s2_Iter,s3_Iter,s4_Iter,s5_Iter,s6_Iter; set<int> s0; //create an empty set s0 of key type integer set<int,less...
#include<iostream>#include<list>#include<algorithm>using namespace std;int main(void){ list<int> c1,c2,c3,c4; list<int>::iterator c1_Iter,c2_Iter,c3_Iter,w_Iter,f_Iter,l_Iter; c1.push_back(10),c1.push_back(10), c1.push_back(20), c1.push_back(30); c2.push_back('u'), c2.push_back('a'), ...
//Deque(dounle_ended queues]
#include<iostream>#include<deque>#include<string>#include<iterator>#include<algorithm>using namespace std;int main(void){ deque<int> c1; //defauilt constructor deque<int> c2(10,4); //create a deque with 10 copies of 4 deque<int> c3(c2); ...
#include<iostream>#include<vector>#include<algorithm>#include<iterator>using namespace std;void Pause(){ char c; cout<<"\npress return to continue: "; cin.get(c); cout<<endl;}int main(){ vector<int> v(10,0); ostream_iterator<int> out(cout," "); //定义一个输出迭代器 copy(v.begin(),v.e...