![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
STL
醉小义
学习算法让自己有更大的提升
展开
-
sting用法1
# include原创 2015-10-10 14:31:06 · 635 阅读 · 0 评论 -
栈(stack)
# include <iostream># include <stack># include <vector># include <list># include <deque> using namespace std;/* 栈(stack) 后进先出 自适应容器 操作: empry-->是否为空 空返回true 不开返回false原创 2015-10-11 13:59:00 · 348 阅读 · 0 评论 -
类模板与函数对象
# include <iostream># include <vector># include <list># include <algorithm>using namespace std;//class absInt{// public :// int operator() (int val){//// }//};//与上面的等价struct absInt{ //重原创 2015-10-11 15:22:24 · 529 阅读 · 0 评论 -
优先级队列(priority_queue)
# include <iostream># include <queue># include <vector># include <deque> using namespace std;/* 优先级队列(priority_queue) 最大值优先级队列,最小值优先级队列 自适应容器 priority_queue允许对数据随机的操作,所有就不能用li原创 2015-10-11 14:51:18 · 768 阅读 · 0 评论 -
队列(queue)
# include <iostream># include <queue># include <list># include <deque> using namespace std;/* 队列(queue): 先进先出 定义: queue<int,deque<int> > q; queue<int,list<int> > q;原创 2015-10-11 14:25:22 · 1711 阅读 · 0 评论 -
list使用1
# include <iostream># include <list>using namespace std;void PrintListContents(const list<int> & listInput);int main(){ list<int> a; //在链表前添加数据 a.push_front(10); a.push_front(-23);原创 2015-10-10 17:12:56 · 487 阅读 · 0 评论 -
vector用法1
# include <iostream># include <vector># include <string>using namespace std;struct Dog{};int main(){ vector<int> ivec; vector<double> dvec; vector<string> svec; vector<Dog> dogvec;//自原创 2015-10-10 15:52:44 · 622 阅读 · 0 评论 -
map与multimap的用法
# include <iostream># include <map># include <string>using namespace std;/* map(映射)-->键不允许重读 multimap(多映射) -->键允许重复 红黑树 自动依靠key排序 基本操作 insert count find原创 2015-10-10 22:45:55 · 690 阅读 · 0 评论 -
set用法1
# include <iostream># include <set>using namespace std;/* set(集)-->不重复 multiset(多集) -->允许重复 红黑数(熟读快) 大数据使用方便,自动排序 缺点:插入慢 不能通过find进行修改 *///声明一个函数模板 template <typename Cont原创 2015-10-10 21:03:15 · 543 阅读 · 0 评论 -
deque的用法
# include <iostream># include <deque> # include <algorithm> using namespace std; /* deque是一个动态数组 deque与vector非常类似 deque可以在数组开头和末尾插入和删除数据, vector值可以在末尾添加 */int main(){ deque<int> a原创 2015-10-10 16:34:40 · 534 阅读 · 0 评论 -
vector使用2
# include <iostream># include <vector># include <string>using namespace std;struct Dog{};int main(){ /* vector动态数组 vector<int> ivec;//ivec是空的 cout<<ivec.size()<<endl; //这样写错误原创 2015-10-10 16:15:52 · 512 阅读 · 0 评论 -
list用法2
# include <iostream># include <list>using namespace std; void PrintListContents(const list<int> & listInput);int main(){ list<int> a; a.push_front(4); a.push_front(3); list<int>::itera原创 2015-10-10 22:57:44 · 320 阅读 · 0 评论 -
set用法3删除
# include <iostream># include <set>using namespace std;typedef multiset<int> MSETINT;int main(){ MSETINT a; a.insert(67); a.insert(88); a.insert(88); a.insert(123); a.insert原创 2015-10-10 21:38:35 · 476 阅读 · 0 评论 -
set用法2之查找
# include <iostream># include <set>using namespace std;//宏定义 typedef set<int> SETINT;int main(){ SETINT a; a.insert(23); a.insert(-1); a.insert(78); a.insert(100); a.insert(5)原创 2015-10-10 21:15:24 · 779 阅读 · 0 评论 -
string用法2
# include <iostream># include <string># include <algorithm>using namespace std;int main(){ string strSTLString("Hello world"); /* 关于String类型的字符串的输出 */ //1. //size_t 就是无原创 2015-10-10 15:09:55 · 378 阅读 · 0 评论 -
类模板与板书对象2
# include <iostream># include <vector># include <algorithm>using namespace std; template <typename numberType>struct IsMultiple{ numberType m_Divisor;//几的倍数 //构造函数 IsMultiple(const原创 2015-10-11 15:41:46 · 372 阅读 · 0 评论