您的位置:首页 > 其它

STL库函数 持续更新

2015-08-15 21:08 246 查看
*容器 (1)顺序容器 vector[顺序表直接访问] depue[前后直接访问] list[双向链表]

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: