multimap::lower_bound
描述 (Description)
C ++函数std::multimap::lower_bound()返回一个指向第一个元素的迭代器,该元素不小于键k 。
声明 (Declaration)
以下是std :: multimap :: lower_bound()函数形式std :: map头的声明。
C++98
iterator lower_bound (const key_type& k);
const_iterator lower_bound (const key_type& k) const;
参数 (Parameters)
k - 要搜索的密钥。
返回值
如果object是常量限定的,则method返回一个常量迭代器,否则返回非常量迭代器。
异常 (Exceptions)
如果抛出异常,对容器没有影响。
时间复杂
对数即O(log n)
例子 (Example)
以下示例显示了std :: multimap :: lower_bound()函数的用法。
#include <iostream>
#include <map>
using namespace std;
int main(void) {
/* Multimap with duplicates */
multimap<char, int> m {
{'a', 1},
{'a', 2},
{'b', 3},
{'c', 4},
{'d', 5}
};
auto it = m.lower_bound('a');
cout << "Lower bound is" << endl;
cout << it->first << " = " << it->second << endl;
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 -
Lower bound is
a = 1