multimap::equal_range (STL/CLR)
尋找符合指定的索引鍵的範圍。
pair_iter_iter equal_range(key_type _Keyval);
參數
- _Keyval
若要搜尋的索引鍵值。
備註
The method returns a pair of iterators - multimap::lower_bound (STL/CLR)(_Keyval), multimap::upper_bound (STL/CLR)(_Keyval).您可以用它來判斷目前在受控制序列中符合指定的索引鍵的項目範圍。
範例
// cliext_multimap_equal_range.cpp
// compile with: /clr
#include <cliext/map>
typedef cliext::multimap<wchar_t, int> Mymultimap;
typedef Mymultimap::pair_iter_iter Pairii;
int main()
{
Mymultimap c1;
c1.insert(Mymultimap::make_value(L'a', 1));
c1.insert(Mymultimap::make_value(L'b', 2));
c1.insert(Mymultimap::make_value(L'c', 3));
// display contents " [a 1] [b 2] [c 3]"
for each (Mymultimap::value_type elem in c1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
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} {1}]",
pair1.first->first, pair1.first->second);
System::Console::WriteLine();
return (0);
}
需求
標頭: < cliext/地圖 >
Namespace: cliext