map && multimap

//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...
2008-08-17 14:34 | 阅读 4384 次 | 评论 0 条

construct map &amp;&amp; multimap

//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; ...
2008-08-17 14:30 | 阅读 4469 次 | 评论 0 条

Multiset

//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>::...
2008-08-17 14:28 | 阅读 4118 次 | 评论 0 条

Set

#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...
2008-08-17 14:26 | 阅读 4050 次 | 评论 0 条

construct Set &amp;&amp; Multiset

//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...
2008-08-17 14:24 | 阅读 5031 次 | 评论 0 条

List

#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'), ...
2008-08-17 14:21 | 阅读 3926 次 | 评论 0 条

Deque

//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); ...
2008-08-17 14:16 | 阅读 3633 次 | 评论 0 条

Vector

#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...
2008-08-17 14:12 | 阅读 3490 次 | 评论 0 条
浏览56192次
最新评论