自己按照stl实现了一个: http://www.cplusplus.com/reference/algorithm/binary_search/ 这里有个注释,如何判断两个元素相同: Two elements, a and bare considered equivalent if (!(a<b) && !(b<a)) lower_bound返回!(*it<val) ,所以binary_search 只要再判断 !(val<*it) 即可. template…
http://www.cplusplus.com/reference/algorithm/upper_bound/左闭右开 Return iterator to lower bound Returns an iterator pointing to the first element in the range [first,last) which does not compare less than val. Return iterator to upper bound Returns an i…