set::lower_bound
描述 (Description)
它返回一个指向容器中第一个元素的迭代器,该元素在val之前不被认为是。
声明 (Declaration)
以下是std :: set :: lower_bound在各种C ++版本中的工作方式。
C++98
iterator lower_bound (const value_type& val) const;
C++11
iterator lower_bound (const value_type& val);
const_iterator lower_bound (const value_type& val) const;
返回值
它返回一个指向容器中第一个元素的迭代器,该元素在val之前不被认为是。
异常 (Exceptions)
如果抛出异常,则容器中没有更改。
时间复杂
时间复杂度取决于对数。
例子 (Example)
以下示例显示了std :: set :: lower_bound的用法。
#include <iostream>
#include <set>
int main () {
std::set<int> myset;
std::set<int>::iterator itlow,itup;
for (int i = 1; i < 10; i++) myset.insert(i*10);
itlow = myset.lower_bound (30);
myset.erase(itlow);
std::cout << "myset contains:";
for (std::set<int>::iterator it = myset.begin(); it!=myset.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
上述程序将正确编译和执行。
myset contains: 10 20 40 50 60 70 80 90