lower_bound()upper_bound() 是方便的在有序数组中二分查找的函数,并且在STL其他数据结构中也提供该方法(如mapset)。
但是两函数并不是二分查找“小于”和“大于”的第一个元素。
lower_bound(first, last, val)大于等于val的第一个元素
upper_bound(first, last, val)严格大于val的第一个元素

lower_bound()

lower_bound - C++ Reference

Returns an iterator pointing to the first element in the range [first,last) which does not compare less than val.

not compare less than 不小于

upper_bound()

upper_bound - C++ Reference

Returns an iterator pointing to the first element in the range [first,last) which compares greater than val.

compares greater than 大于

lower_bound()和upper_bound()的更多相关文章

  1. STL源码学习----lower_bound和upper_bound算法

    转自:http://www.cnblogs.com/cobbliu/archive/2012/05/21/2512249.html 先贴一下自己的二分代码: #include <cstdio&g ...

  2. [STL] lower_bound和upper_bound

    STL中的每个算法都非常精妙, ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一 ...

  3. vector的插入、lower_bound、upper_bound、equal_range实例

    对于这几个函数的一些实例以便于理解: #include <cstdlib> #include <cstdio> #include <cstring> #includ ...

  4. STL中的lower_bound和upper_bound的理解

    STL迭代器表述范围的时候,习惯用[a, b),所以lower_bound表示的是第一个不小于给定元素的位置 upper_bound表示的是第一个大于给定元素的位置. 譬如,值val在容器内的时候,从 ...

  5. STL 源码分析《5》---- lower_bound and upper_bound 详解

    在 STL 库中,关于二分搜索实现了4个函数. bool binary_search (ForwardIterator beg, ForwardIterator end, const T& v ...

  6. lower_bound和upper_bound算法

    参考:http://www.cnblogs.com/cobbliu/archive/2012/05/21/2512249.html ForwardIter lower_bound(ForwardIte ...

  7. lower_bound 和 upper_bound

    Return iterator to lower bound Returns an iterator pointing to the first element in the range [first ...

  8. STL源码学习----lower_bound和upper_bound算法[转]

    STL中的每个算法都非常精妙,接下来的几天我想集中学习一下STL中的算法. ForwardIter lower_bound(ForwardIter first, ForwardIter last,co ...

  9. [转] STL源码学习----lower_bound和upper_bound算法

    http://www.cnblogs.com/cobbliu/archive/2012/05/21/2512249.html PS: lower_bound of value 就是最后一个 < ...

  10. STL algorithm算法lower_bound和upper_bound(31)

    lower_bound原型: function template <algorithm> std::lower_bound default (1) template <class F ...

随机推荐

  1. datagrid相关

    int rowID = Convert.ToInt32(dataGrid_OpenBoxScan.CurrentRowIndex.ToString());//得到所选行的行号              ...

  2. FPM八:FPM TREE

    先上效果图: 1,新建类:ZCL_FPM_TREE,并添加接口:IF_FPM_GUIBB,IF_FPM_GUIBB_TREE.激活所有方法 2.定义tree结构,在class的public secti ...

  3. 如何用StatSVN统计SVN服务器某项目的代码量

    startsvn下载地址: https://sourceforge.net/projects/statsvn/?source=typ_redirect svn下载地址: https://www.vis ...

  4. Centos系统 tomcat 中的应用与北京时间相差8小时

    解决方法: 在 catalina.sh中的 JAVA_OPTS 加上 -Duser.timezone=GMT+08  启动时 startup.sh 会调用 catalina.sh.

  5. eclipse设置序列化忽略生成serialVersionUID警告

    java中的类想要序列化必须实现java.io.Serializable接口,一般实现接口都会用警告信息,提示生成serialVersionUID,虽然我觉得这个应该生成才合理.这里还是记录一下取消生 ...

  6. shell 的 正则表达式

    shell的正则表达式规则 https://www.jb51.net/tools/shell_regex.html 常规字符 字符 描述 \ 将下一个字符标记为一个特殊字符.或一个原义字符.例如,“n ...

  7. properties文件属性值@Value注解为 java entity属性赋值

    一.使用@Value为 java entity类中的非static属性赋值 举个栗子,一目了然 1.1 properties文件 1.2 servlet.xml 文件增加的配置: 1.2.1 serv ...

  8. K8s Helm安装配置入门

    作为k8s现在主流的一种包部署方式,尽管不用,也需要进行一些了解.因为,它确实太流行了. 这一套太极拳打下来,感觉helm这种部署,目前还不太适合于我们公司的应用场景.它更适合需要手工编程各种yaml ...

  9. Windows下Redis安装配置和使用注意事项

    Windows下Redis安装配置和使用注意事项 一:下载 下载地址: https://github.com/microsoftarchive/redis/releases 文件介绍: 本文以3.2. ...

  10. Latex使用过程中的一些总结

    本文主要总结在使用Latex过程中遇到的一些问题及解决方案. 一:关于参考文献 1.如何在paper同一处用\cite命令同时引用多篇文献? 用\cite{bibtex1}\cite{bibtex2} ...