c/c++语言开发共享lower_bound()和upper_bound()

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

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 大于

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/600742.html

(0)
上一篇 2021年5月9日
下一篇 2021年5月9日

精彩推荐