lower_bound()和upper_bound() 是方便的在有序陣列中二分查找的函式,并且在STL其他資料結構中也提供該方法(如map和set),
但是兩函式并不是二分查找“小于”和“大于”的第一個元素,
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 大于
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/82027.html
標籤:C++
上一篇:洛谷P2085——最小函式值
下一篇:各種排序(一)
