随笔分类 - STL
STL-map/multimap 简述
摘要:1 #include <iostream> 2 #include <cstdio> 3 #include <map> 4 5 using namespace std; 6 7 8 int main() 9 { 10 // map && multimap 11 // 键值映射容器,一对一,一对多 12
阅读全文
STL-set&&multiset 集合
摘要:1 #include <iostream> 2 #include <cstdio> 3 #include <set> 4 5 // 仿函数的原型 6 //struct greaters 7 //{ 8 // bool operator()(const int &left,const int &rig
阅读全文
STL-优先级队列-priority_queue
摘要:头文件是<queue> 操作很简单 #include <iostream> #include <cstdio> #include <queue> using namespace std; int main() { // 默认定义最大值优先级队列 priority_queue<int> p1; p1.
阅读全文
STL-list 链表
摘要:1 #include <iostream> 2 #include <list> 3 4 using namespace std; 5 6 int main() 7 { 8 // list可以在头部和尾部插入和删除元素 9 // 不能随机访问元素,迭代器只能++,不能一次性跳转 10 list<int
阅读全文
STL-queue 队列
摘要:1 #include <iostream> 2 #include <queue> 3 4 using namespace std; 5 6 int main() 7 { 8 // queue也很简单 9 // push,pop,size,front 10 queue<int> q1; 11 q1.p
阅读全文
STL-stack栈
摘要:1 #include <iostream> 2 #include <stack> 3 4 using namespace std; 5 6 int main() 7 { 8 // 栈比较简单 9 // push,pop,size,top 10 // 基本操作很少,很容易实现和使用 11 // 一般可
阅读全文
STL-deque 双端数组简析
摘要:1 #include <iostream> 2 #include <deque> 3 4 using namespace std; 5 6 int main() 7 { 8 // 插入 9 deque<int> de; 10 for(int i=0;i<5;++i) 11 { 12 de.push_
阅读全文
STL-vector
摘要:1 #include <iostream> 2 #include <cstdio> 3 #include <vector> 4 5 using namespace std; 6 7 // 注意:vector在尾部添加或移动元素非常快,在中间操作非常耗时,因为它需要移动元素 8 9 10 int ma
阅读全文
STL-string用法
摘要:1 #include <string> 2 #include <iostream> 3 #include <cstring> 4 #include <algorithm> 5 6 using namespace std; 7 8 int to_lower(int c) 9 { 10 if (isup
阅读全文
ACM常用STL容器
摘要:1 // STL(标准模板库),由三大部分组成:容器,算法,迭代器 2 3 4 // STL六大组件:container(容器),algorthm(算法),iterator(迭代器) 5 // function object(仿函数),adaptor(适配器),allocator(空间适配器) 6
阅读全文
浙公网安备 33010602011771号