STL库函数 持续更新
2015-08-15 21:08
246 查看
*容器 (1)顺序容器 vector[顺序表直接访问] depue[前后直接访问] list[双向链表]
vector 检索(用operator[ ])速度快
View Code
二.lower_bound();upper_bound()
lower_bound(a,a+n,k)在已排好序的a中利用二分法找出ai>=k的最小指针(返回值);upper_bound(a,a+n,k).......ai<=k;两个联合起来就是找k;
vector 检索(用operator[ ])速度快
#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { string s = "helllo"; if (s.find("e") == string::npos) //yes cout << "no" << endl; else cout << "yes" << endl; if (s.find("z") == string::npos) //no cout << "no" << endl; else cout << "yes" << endl; }
View Code
二.lower_bound();upper_bound()
lower_bound(a,a+n,k)在已排好序的a中利用二分法找出ai>=k的最小指针(返回值);upper_bound(a,a+n,k).......ai<=k;两个联合起来就是找k;
相关文章推荐
- LeetCode(59)Length of Last Word
- Windows 10 IoT Core 正式版进阶体验
- JAVA基础(二)
- Objective-C:OC内部可变对象和不可变对象的深(复制)拷贝问题思考:
- Summarize code for the three presentation experiments
- 使用链路聚合进行负载分担
- 黑马程序员——Java基础03
- HDU 4450 Draw Something
- 欧拉路AND欧拉回路
- hdu 2814
- bootstrap轮播和百叶窗
- JS/PHP 浮点数精确运算
- Cocos2dx——瓦片地图(Tiled Map)
- BestCoder Round #51 (div.2) 1001 找规律+判素数
- Light 1008
- NSDate的使用方法
- 《數據結構與算法分析:C語言描述》習題2.11代碼及自己的想法
- MFC学习笔记
- 更改eclipse的编辑器样式风格
- 西安Uber优步司机奖励政策(8月10日到8月16日)