STL:map中的lower_bound和upper_bound
2015-11-09 23:00
288 查看
今天在做leetcode的Longest Increasing Subsequence题目时,需要用到二分查找,于是翻看了《STL源码剖析》这本书,发现map里面有lower_bound和upper_bound这两个函数。用法如下:
map<int,int> m;
int x=10;
map<int,int>::iterator ite;
ite=m.lower_bound(x);//返回比第一个大于或等于x的值的位置
,当m为空时,返回m.begin()
ite=m.upper_bound(x);//返回比最后一个大于或等于x的值的位置
map<int,int> m;
int x=10;
map<int,int>::iterator ite;
ite=m.lower_bound(x);//返回比第一个大于或等于x的值的位置
,当m为空时,返回m.begin()
ite=m.upper_bound(x);//返回比最后一个大于或等于x的值的位置
相关文章推荐
- java查看工具jhat-windows
- newmat10库的编译
- Android开源BezierView:仿QQ未读消息99+条的红色气泡
- 帮助命令
- 锂电池无需3次激活
- 1109
- 10.Curator队列
- [Leetcode]Ugly Number
- Photos框架学习备忘
- Delete a DesktopGroup
- TinyOS06:Avrora的Mailing List
- Oracle14~23
- UIDatePicker
- AudioManager的简单使用
- Oracle分页
- 从头认识java-7.8 接口与工厂模式
- 数据结构与算法javascript描述(五) 选择排序
- 算法作业1 3D最近点对问题
- UIPickerView
- Java基础(14):网络编程之socket