hash_map::upper_bound (STL/CLR)

尋找符合指定的索引鍵的範圍的結尾。

    iterator upper_bound(key_type key);

參數

  • Key - 索引鍵
    若要搜尋的索引鍵值。

備註

成員函式會判斷最後一個項目X在受控制序列的雜湊為相同的桶key且有相同順序來key。如果沒有這類項目存在,或是X是最後一個項目,在受控制序列中,它會傳回hash_map::end (STL/CLR)()。 否則它會傳回 iterator,指派第一個項目,超過X。您可以用它來在受控制序列的比對指定的索引鍵中目前找出項目的序列結尾。

範例

// cliext_hash_map_upper_bound.cpp 
// compile with: /clr 
#include <cliext/hash_map> 
 
typedef cliext::hash_map<wchar_t, int> Myhash_map; 
int main() 
    { 
    Myhash_map c1; 
    c1.insert(Myhash_map::make_value(L'a', 1)); 
    c1.insert(Myhash_map::make_value(L'b', 2)); 
    c1.insert(Myhash_map::make_value(L'c', 3)); 
 
// display contents " [a 1] [b 2] [c 3]" 
    for each (Myhash_map::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
 
    System::Console::WriteLine("upper_bound(L'x')==end() = {0}", 
        c1.upper_bound(L'x') == c1.end()); 
 
    Myhash_map::iterator it = c1.upper_bound(L'a'); 
    System::Console::WriteLine("*upper_bound(L'a') = [{0} {1}]", 
        it->first, it->second); 
    it = c1.upper_bound(L'b'); 
    System::Console::WriteLine("*upper_bound(L'b') = [{0} {1}]", 
        it->first, it->second); 
    return (0); 
    } 
 
  

需求

標頭: < cliext/hash_map >

Namespace: cliext

請參閱

參考

hash_map (STL/CLR)

hash_map::count (STL/CLR)

hash_map::equal_range (STL/CLR)

hash_map::find (STL/CLR)

hash_map::lower_bound (STL/CLR)