hash_multiset::equal_range (STL/CLR)
尋找符合指定的索引鍵的範圍。
cliext::pair<iterator, iterator> equal_range(key_type key);
參數
- Key - 索引鍵
若要搜尋的索引鍵值。
備註
The member function returns a pair of iterators cliext::pair<iterator, iterator>( hash_multiset::lower_bound (STL/CLR)(key), hash_multiset::upper_bound (STL/CLR)(key)). 您可以用它來判斷目前在受控制序列中符合指定的索引鍵的項目範圍。
範例
// cliext_hash_multiset_equal_range.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
typedef Myhash_multiset::pair_iter_iter Pairii;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// display results of failed search
Pairii pair1 = c1.equal_range(L'x');
System::Console::WriteLine("equal_range(L'x') empty = {0}",
pair1.first == pair1.second);
// display results of successful search
pair1 = c1.equal_range(L'b');
for (; pair1.first != pair1.second; ++pair1.first)
System::Console::Write(" {0}", *pair1.first);
System::Console::WriteLine();
return (0);
}
需求
標頭: < cliext/hash_set >
Namespace: cliext
請參閱
參考
hash_multiset::count (STL/CLR)