![]() |
---|
此 API 已过时。另一种方法是 unordered_multiset Class。 |
返回迭代器到一 hash_multiset 的第一个元素与等于或大于指定的键的键。
const_iterator lower_bound(
const Key& _Key
) const;
iterator lower_bound(
const Key& _Key
);
参数
- _Key
参数键与一个元素的排序关键字进行比较从要搜索的 hash_multiset 的。
返回值
解决第一个元素位置在一 hash_multiset 的密钥等于或大于参数键,或者解决成功最后一个元素的位置。hash_multiset 的 迭代器 或 const_iterator,如果与未作为项中。
备注
在 Visual C++ .NET 2003 中,<hash_map> 和 <hash_set> 标头文件的成员中不再标准,命名空间,而是将 stdext 命名空间。有关更多信息,请参见 stdext 命名空间。
示例
// hash_multiset_lower_bound.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
int main() {
using namespace std;
using namespace stdext;
hash_multiset <int> hms1;
hash_multiset <int> :: const_iterator hms1_AcIter, hms1_RcIter;
hms1.insert( 10 );
hms1.insert( 20 );
hms1.insert( 30 );
hms1_RcIter = hms1.lower_bound( 20 );
cout << "The element of hash_multiset hms1 with a key of 20 is: "
<< *hms1_RcIter << "." << endl;
hms1_RcIter = hms1.lower_bound( 40 );
// If no match is found for the key, end( ) is returned
if ( hms1_RcIter == hms1.end( ) )
cout << "The hash_multiset hms1 doesn't have an element "
<< "with a key of 40." << endl;
else
cout << "The element of hash_multiset hms1 with a key of 40 is: "
<< *hms1_RcIter << "." << endl;
// An element at a specific ___location in the hash_multiset can be found
// by using a dereferenced iterator that addresses the ___location
hms1_AcIter = hms1.end( );
hms1_AcIter--;
hms1_RcIter = hms1.lower_bound( *hms1_AcIter );
cout << "The element of hms1 with a key matching "
<< "that of the last element is: "
<< *hms1_RcIter << "." << endl;
}
Output
The element of hash_multiset hms1 with a key of 20 is: 20.
The hash_multiset hms1 doesn't have an element with a key of 40.
The element of hms1 with a key matching that of the last element is: 30.
要求
标头: <hash_set>
命名空间: stdext