简体   繁体   English

upper_bound() 做什么?

[英]what do upper_bound() do?

I am begineer and I dont understand the following.我是初学者,我不明白以下内容。

In the code在代码中代码

I got the output我得到了 output

输出

Now my question is since the upper_bound() operator gives the index of greater value how did the output gave the answer of upperbound as 7 and not 1.现在我的问题是,因为upper_bound()运算符给出了更大值的索引,所以 output 是如何将上界的答案给出为 7 而不是 1 的。

Both the upper_bound and lower_bound functions require the range to be partitioned according to the value you are looking for, essentially being sorted. upper_boundlower_bound函数都需要根据您要查找的值对范围进行分区,本质上是排序。 Since your vector does not meet this criterion, you cannot expect logical results.由于您的矢量不符合此标准,因此您不能期望得到合乎逻辑的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM