注释:
binary_search:判断是否存在某个对象
lower_bound: 返回>=对象的第一个位置,lower_bound(2)=3, lower_bound(3)=3
目标对象存在即为目标对象的位置,不存在则为后一个位置.
upper_bound: 返回>对象的第一个位置, upper_bound(2)=3,upper_bound(3)=4
无论是否存在都为后一个位置.
本文深入探讨了C++标准库中的sort函数及upper_bound、lower_bound函数的使用方法,通过实例展示了如何进行元素排序及查找特定元素的位置。同时,介绍了upper_bound和lower_bound函数的区别以及在不同场景下的应用,帮助开发者更高效地进行数据处理。
注释:
binary_search:判断是否存在某个对象
lower_bound: 返回>=对象的第一个位置,lower_bound(2)=3, lower_bound(3)=3
目标对象存在即为目标对象的位置,不存在则为后一个位置.
upper_bound: 返回>对象的第一个位置, upper_bound(2)=3,upper_bound(3)=4
无论是否存在都为后一个位置.

被折叠的 条评论
为什么被折叠?