随笔分类 - STL操作指南
摘要:六大组件:容器(类模板)、算法(函数模板)、迭代器(类模板,设计模式)、配置器(类模板)、配接器(容器适配器、函数配接器)、仿函数(类或类模板)。整个项目采用大多的是泛型编程的思想(模板机制)。使得多种数据类型在同一个算法或结构上都可以操作,在编译器就确定聚类数据类型。 (一)配置器 一般new都是
阅读全文
摘要:#include <iostream> using namespace std; #include <algorithm> #include <vector> void myprint5(int val) { cout << val << " "; } //一、set_intersection /*
阅读全文
摘要:#include <iostream> using namespace std; #include <algorithm> #include <vector> #include <numeric> void myprint4(int val) { cout << val << " "; } //一、
阅读全文
摘要:#include <iostream> using namespace std; #include <algorithm> #include <vector> void myprint3(int val) { cout << val << " "; } //一、replace /* replace(
阅读全文
摘要:#include <iostream> using namespace std; #include <algorithm> #include <vector> #include <time.h> #include <functional> //一、sort /* sort(iterator beg,
阅读全文
摘要:#include <iostream> using namespace std; #include <algorithm> #include <vector> //一、find /* 查找指定元素,找到返回指定元素的迭代器,找不到返回结束迭代器end() find(iterator beg, ite
阅读全文
摘要:#include <iostream> using namespace std; #include <algorithm> #include <vector> //一、for_each()实现遍历容器 /* for_each(iterator beg, iterator end, _func) be
阅读全文
摘要:#include <iostream> using namespace std; #include <map> #include <algorithm> void printMap(const map<int, int>& mp) { for (auto it = mp.begin(); it !=
阅读全文
摘要:#include <iostream> using namespace std; #include <set> #include <algorithm> void printSet(const set<int>& st) { for (auto it = st.begin(); it != st.e
阅读全文
摘要:#include <iostream> using namespace std; #include <string> #include <algorithm> //成对出现的数据,利用对组可以返回两个数据 /* 两种创建方式 pair<type, type> p(value1, value2); p
阅读全文
摘要:#include <iostream> using namespace std; #include <list> #include <algorithm> void printList(const list<int>& L) { for (auto it = L.begin(); it != L.e
阅读全文
摘要:#include <iostream> using namespace std; #include <queue> #include <algorithm> /* //一、构造函数 queue<T> que; 采用模板类实现,queue对象的默认构造形式 queue(const queue & qu
阅读全文
摘要:#include <iostream> using namespace std; #include <stack> #include <algorithm> /* //一、构造函数 stack<T> stk; 采用模板类实现,stack对象的默认构造形式 stack(const stack & st
阅读全文
摘要:#include <iostream> using namespace std; #include <deque> #include <algorithm> void printDeque(const deque<int>& d) { for (auto it = d.begin(); it !=
阅读全文
摘要:#include <iostream> using namespace std; #include <vector> void printVector(vector<int>& v) { for (auto it = v.begin(); it != v.end(); it++) { cout <<
阅读全文
摘要:#include <iostream> using namespace std; #include <string> //一、构造函数 /* string(); 创建一个空的字符串,例如string str; string(const char* s); 使用字符串s初始化 string(const
阅读全文