set::upper_bound (STL/CLR)

查找与指定键匹配的范围。

    iterator upper_bound(key_type key);

参数


  • 要搜索的键值。

备注

成员函数决定具有相同顺序的 key的控制序列中的最后一个 X 元素。 如果不存在此类元素,或者,如果 X 位于控制序列中的最后一个元素,则返回(); set::end (STL/CLR)否则它返回指定除 X外的第一个元素的次数的迭代器。 使用其当前找到的元素序列的开头与指定的键在控制序列。

示例

// cliext_set_upper_bound.cpp 
// compile with: /clr 
#include <cliext/set> 
 
typedef cliext::set<wchar_t> Myset; 
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(); 
 
    System::Console::WriteLine("upper_bound(L'x')==end() = {0}", 
        c1.upper_bound(L'x') == c1.end()); 
 
    System::Console::WriteLine("*upper_bound(L'a') = {0}", 
        *c1.upper_bound(L'a')); 
    System::Console::WriteLine("*upper_bound(L'b') = {0}", 
        *c1.upper_bound(L'b')); 
    return (0); 
    } 
 
  

要求

标头: <cliext/set>

命名空间: cliext

请参见

参考

set (STL/CLR)

set::count (STL/CLR)

set::equal_range (STL/CLR)

set::find (STL/CLR)

set::lower_bound (STL/CLR)