首页 > 其他 > 详细

lower_bound()和upper_bound()

时间:2019-12-07 00:23:28      阅读:84      评论:0      收藏:0      [点我收藏+]

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()

原文:https://www.cnblogs.com/KZNS/p/lowerbound-upperbound.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!