cb33a_c++_STL_算法_查找算法_(6)binary_search_includes
//针对已序区间的查找算法,如set,multiset关联容器-自动排序
binary_search(b,e,v),begin,end,value--返回bool,不会告诉具体找到的位置。只能找一个
if (binary_search(iset.begin(), iset.end(), 5))//返回bool
binary_search(b,e,v,p) begin,end, value,parameter(谓词)

includes(b,e,sb,se)--begin,end,second begin,second end.可以找多个,不连续的。查找对象必须是排序的,顺序存放的数据。
if(includes(iset.begin(),iset.end(),search.begin(),search.end()))
include (b,e,sb,se,p)--p,parameter,谓词

lower_bound()--找到后,可以返回位置

 /*cb33a_c++_STL_算法_查找算法_(6)binary_search_includes
//针对已序区间的查找算法,如set,multiset关联容器-自动排序
binary_search(b,e,v),begin,end,value--返回bool,不会告诉具体找到的位置。只能找一个
if (binary_search(iset.begin(), iset.end(), 5))//返回bool
binary_search(b,e,v,p) begin,end, value,parameter(谓词) includes(b,e,sb,se)--begin,end,second begin,second end.可以找多个,不连续的。查找对象必须是排序的,顺序存放的数据。
if(includes(iset.begin(),iset.end(),search.begin(),search.end()))
include (b,e,sb,se,p)--p,parameter,谓词 lower_bound()--找到后,可以返回位置
*/ #include <iostream>
#include <algorithm>
#include <list>
#include <set>
#include <vector> using namespace std; int main()
{
list<int> ilist;
for (int i = ; i <= ; ++i)
ilist.insert(ilist.end(), i);//从后面插入
ilist.push_back();
set<int> iset;
for (int ii = ; ii <= ; ++ii)
iset.insert(iset.end(), ii);
iset.insert(iset.end(),);//即使在最后插入的0,它也会自动排序,0会移动到最前面的 for (list<int>::iterator iter = ilist.begin(); iter != ilist.end(); ++iter)
cout << *iter << ' ';
cout << endl;
cout << "set容器结果查看" << endl;
for (set<int>::iterator iter = iset.begin(); iter != iset.end(); ++iter)
cout << *iter << ' ';
cout << endl; if (binary_search(iset.begin(), iset.end(), ))//返回bool
cout << "找到了" << endl;
else
cout << "没找到" << endl; vector<int> search; //
search.push_back();
search.push_back();
search.push_back();
if(includes(iset.begin(),iset.end(),search.begin(),search.end()))
cout<<"iset里面找 search vector的,3,4,7。同时都找到了"<<endl;
//只要包含 3,4,7,就算找到了
//注意,vector如果没有顺序排放,就会出错的。3,7,4就不可以。
//已序区间,就是已经排序的区域。默认排序的,或者自动排序的容器
else
cout << "没找到" << endl; return ;
}

cb33a_c++_STL_算法_查找算法_(6)binary_search_includes的更多相关文章

  1. cb34a_c++_STL_算法_查找算法_(7)_lower_bound

    cb34a_c++_STL_算法_查找算法_(7)_lower_bound//针对已序区间的查找算法,如set,multiset关联容器-自动排序lower_bound()--第一个可能的位置uppe ...

  2. cb32a_c++_STL_算法_查找算法_(5)adjacent_find

    cb32a_c++_STL_算法_查找算法_(5)adjacent_findadjacent_find(b,e),b,begin(),e,end()adjacent_find(b,e,p),p-par ...

  3. cb31a_c++_STL_算法_查找算法_(4)find_first_of

    cb31a_c++_STL_算法_查找算法_(4)find_first_offind_first_of(b,e,sb,se),sb,second begin, se,second end();find ...

  4. cb30a_c++_STL_算法_查找算法_(3)search_find_end

    cb30a_c++_STL_算法_查找算法_(3)search_find_endsearch()pos = search(ideq.begin(), ideq.end(), ilist.begin() ...

  5. cb29a_c++_STL_算法_查找算法_(2)search_n

    cb29a_c++_STL_算法_查找算法_(2)search_n//比如:连续查找连续的n个8search_n(b,e,c,v),迭代器b,begin(),e,end().连续的c个vpos=sea ...

  6. cb28a_c++_STL_算法_查找算法_(1)find_find_if

    cb28a_c++_STL_算法_查找算法_(1)find_find_iffind() //线性查找,比较慢.pos1 = find(ilist.begin(), ilist.end(), 5);fi ...

  7. STL_算法_查找算法(lower_bound、upper_bound、equal_range)

    C++ Primer 学习中. .. 简单记录下我的学习过程 (代码为主) //全部容器适用(O(log(n)))    已序区间查找算法 lower_bound()        //找第一个符合的 ...

  8. STL_算法_查找算法(find、find_if)

    C++ Primer 学习中. .. 简单记录下我的学习过程 (代码为主) find . find_if /**********************线性查找O(n) find(); find_if ...

  9. STL_算法_查找算法(binary_search、includes)

    C++ Primer 学习中.. . 简单记录下我的学习过程 (代码为主) 全部容器适用(O(log(n)))     已序区间查找算法 binary_search             //二分查 ...

随机推荐

  1. (一) Vue在创建的时候 入口文件 及相关的路由配置(及子路由配置)

    1. 首先明确一点  在书写之前尽量保持相关的文件知道含义 比如 components 啥的 知道是要放什么东西 在这里介绍一下   由于 vue 不是系统学习 所以很多的创建方式可能不一样  就是有 ...

  2. 当.Net成为大厂门槛代码小白该何去何从?

    掌握.Net已成为进入大厂的通行牌.越来越多的互联网软件公司开始使用.Net Core,根据去年数据显示腾讯.网易.顺丰.携程.中通.申通.同程艺龙.微医.233网校.问卷星.金蝶等关键业务已经在往. ...

  3. SpringCloud Alibaba 简介

    SpringCloud Aliababa简介 SpringCloud Alibaba是阿里巴巴集团开源的一套微服务架构解决方案. 微服务架构是为了更好的分布式系统开发,将一个应用拆分成多个子应用,每一 ...

  4. Springboot整合MybatisPlus(超详细)完整教程~

    新建springboot项目 开发工具:idea2019.2,maven3 pom.xml <dependency> <groupId>org.springframework. ...

  5. 9.快照持久化和AOF持久化

    持久化功能redis为了内部数据的安全考虑,会把本身的数据以文件形式保存到硬盘中一份,在服务器重启之后会把硬盘中的数据恢复到内存(redis)的里边. 数据保存到硬盘的过程就称为“持久化”效果. re ...

  6. strlen 老瓶装新酒

    前言 - strlen 概述 无意间扫到 glibc strlen.c 中代码, 久久不能忘怀. 在一无所知的编程生涯中又记起点点滴滴: 编程可不是儿戏 ❀, 有些难, 也有些不舍. 随轨迹一同重温, ...

  7. 离散数学 II(最全面的知识点汇总)

    离散数学 II(知识点汇总) 目录 离散数学 II(知识点汇总) 代数系统 代数系统定义 例子 二元运算定义 运算及其性质 二元运算的性质 封闭性 可交换性 可结合性 可分配性 吸收律 等幂性 消去律 ...

  8. day07 作业

    作业(必做题):#1. 使用while循环输出1 2 3 4 5 6 8 9 10count=0while count<11: if count==7: count+=1 continue pr ...

  9. 【RT-Thread笔记】OneNet软件包的使用

    去年,RT-Thread发布了RT-Thread Studio初版RT-ThreadStudio的使用体验,经过不断更新迭代之后,来到了V1.1.0,咱也来拥抱一下新版本. 本篇笔记咱们以接入OneN ...

  10. Java实现 蓝桥杯 算法提高 欧拉函数(数学)

    试题 算法提高 欧拉函数 问题描述 老师出了一道难题,小酱不会做,请你编个程序帮帮他,奖金一瓶酱油: 从1-n中有多少个数与n互质? |||||╭══╮ ┌═════┐ ╭╯让路║═║酱油专用车║ ╰ ...