1、stable_partition穩定劃分和partition不穩定劃分。
#include <iostream>#include <algorithm>#include <vector>using namespace std;struct Student {char name[20];int age;};ostream & operator <<(ostream & os, const Student &s){os << "(" <<s.name <<" " <<s.age << ")";return os;}bool AgeCom(Student & s){return s.age < 30;}int main(int argc, char *argv[]){Student stu[] = {{"ZhangSan",29},{"LiSi",57},{"WangWu",49},{"ZhaoLiu",27}};copy(stu,stu+4,ostream_iterator<Student>(cout," "));cout <<endl;//不穩定的劃分vector<Student> vec(stu,stu+4);partition(vec.begin(),vec.end(), AgeCom);copy(vec.begin(),vec.end(),ostream_iterator<Student>(cout,""));cout << endl;//穩定的劃分vector<Student> vec2(stu,stu+4);stable_partition(vec2.begin(),vec2.end(),AgeCom);copy(vec.begin(),vec.end(),ostream_iterator<Student>(cout,""));cout << endl;}
2.TRACE宏
TRACE不是函數而是一個宏,作用就是在調試器的輸出視窗產生顯示來自你的程式的訊息。
在debug下才有效,Release下是沒用的,你可以把他看成printf 語句,不過這個語句在Release 下自動消失。
3.STL Containers
3.1 list中的方法如下:
陸續更新中...