hash_multiset::lower_bound
![]() |
---|
這個 API 已經過時。這個選項是 unordered_multiset Class。 |
傳回 Iterator 置於一 hash_multiset 的第一個項目具有等於或大於指定之索引鍵的索引鍵。
const_iterator lower_bound(
const Key& _Key
) const;
iterator lower_bound(
const Key& _Key
);
參數
- _Key
引數索引鍵與項目的排序鍵比較要搜尋的 hash_multiset 的。
傳回值
處理第一個項目位置中的 hash_multiset 與索引鍵等於或大於引數機碼,或解決成功最後一個項目位置 hash_multiset 的 iterator 或 const_iterator ,如果符合沒有為索引鍵中找到。
備註
在 Visual C++ .NET Pocket PC, <hash_map> 和 <hash_set> 標頭檔 (Header File) 的成員不在 std 命名空間,,而是移至 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