hash_multiset::upper_bound

备注

此 API 已过时。替代为 unordered_multiset 类

迭代器返回到 hash_multiset 的第一个元素与大于指定的键大的密钥。

const_iterator upper_bound( 
   const Key& _Key 
) const; 
iterator upper_bound( 
   const Key& _Key 
);

参数

  • _Key
    参数用键元素的排序关键字进行比较从搜索的 hash_multiset 的。

返回值

迭代器const_iterator 键处理参数比第一个元素在一个位置 hash_multiset 使用的关键或大于最后一个元素成功解决的位置。hash_multiset,如果与对于找到键。

备注

在Visual C++ .NET 2003中,成员<hash_map><hash_set> 头文件不再在std命名空间,而是已经进入了stdext命名空间。 有关更多信息,请参见 stdext 命名空间

示例

// hash_multiset_upper_bound.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multiset <int> hms1;
   hash_multiset <int> :: const_iterator hms1_AcIter, hms1_RcIter;
   
   hms1.insert( 10 );
   hms1.insert( 20 );
   hms1.insert( 30 );

   hms1_RcIter = hms1.upper_bound( 20 );
   cout << "The first element of hash_multiset hms1" << endl
        << " with a key greater than 20 is: "
        << *hms1_RcIter << "." << endl;

   hms1_RcIter = hms1.upper_bound( 30 );

   // If no match is found for the key, end( ) is returned
   if ( hms1_RcIter == hms1.end( ) )
      cout << "The hash_multiset hms1 doesn't have an element "
           << "\n with a key greater than 30." << endl;
   else
      cout << "The element of hash_multiset hms1"
           << "with a key > 40 is: "
           << *hms1_RcIter << "." << endl;

   // An element at a specific ___location in the hash_multiset can be
   // found by using a dereferenced iterator addressing the ___location
   hms1_AcIter = hms1.begin( );
   hms1_RcIter = hms1.upper_bound( *hms1_AcIter );
   cout << "The first element of hms1\n with a key greater than "
        << endl << "that of the initial element of hms1 is: "
        << *hms1_RcIter << "." << endl;
}
  

要求

Header: <hash_set>

**命名空间:**stdext

请参见

参考

hash_multiset 类

标准模板库