code:
// // author: lin yiqian
// created: 2009/08/24
// describe: stl vector 使用demo
// #include
#include
using
namespace std;
typedef vector int_vec;
// 列印vector
void printvector(int_vec vecint)
cout << endl;
}
// 逆向列印vector
void printvectorreversse(int_vec vecint)
cout << endl;
}
void main(void)
int_vec vecint2(10, 3);
cout << "vecint2(10, 3): "; printvector(vecint2);
// erase()
// size()
// capacity()
// max_size()
int_vec vecint3(vecint2);
cout << "vecint3(vecint2): "; printvector(vecint3);
// insert()
// reverse()
int_vec vecint4(vecint3.begin()+2, vecint3.end()-5);
cout << "vecint4(vecint3.begin()+2, vecint3.end()-5): "; printvector(vecint4);
// assign()
// pop_back() & push_back()
// at() & operator - get value
// operator cmp
// swap()
// front() & back()
// empty()
// clear()
system("pause");
}
STL容器使用DEMO multimap
code author lin yiqian created 2009 08 24 describe stl multimap 使用demo include include include using namespace std typedef multimap str mmap 列印multima...
STL容器使用DEMO multiset
code author lin yiqian created 2009 08 24 describe stl multiset 使用demo include include using namespace std typedef multiset int mset 列印set void prints...
STL容器使用總結
include include include include include include 優先佇列,大的元素自動排在隊頭 include key唯一,重複會覆蓋 多重對映,允許有重複的key include 集合 相當於沒有value的對映using namespace std void pu...