set::equal_range (STL/CLR)

查找与指定的键的范围。

    cliext::pair<iterator, iterator> equal_range(key_type key);

参数


  • 搜索的键值。

备注

成员函数返回迭代器 cliext::pair<iterator, iterator>(set::lower_bound (STL/CLR)(key),set::upper_bound (STL/CLR)(key))对。 使用该当前确定与指定的键元素的大小控件序列。

示例

// cliext_set_equal_range.cpp 
// compile with: /clr 
#include <cliext/set> 
 
typedef cliext::set<wchar_t> Myset; 
typedef Myset::pair_iter_iter Pairii; 
int main() 
    { 
    Myset 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/设置>

命名空间: cliext

请参见

参考

set (STL/CLR)

set::count (STL/CLR)

set::find (STL/CLR)

set::lower_bound (STL/CLR)

set::upper_bound (STL/CLR)