次の方法で共有


hash_map::upper_bound (STL/CLR)

指定したキーに一致する範囲の末尾を検索します。

    iterator upper_bound(key_type key);

パラメーター

  • key
    検索するキー値。

解説

このメンバー関数は key と同じバケットにハッシュし、keyに並べる等価である被制御シーケンスの最後の要素 X が決まります。 そのような要素が存在しない場合、または X が被制御シーケンスの最後の要素である場合、hash_map::end (STL/CLR)();を返します それ以外の場合は 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>

名前空間: の 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)