hash_multiset::value_comp

备注

此 API 已过时。另一种方法是 unordered_multiset Class

检索在 hash_multiset 使用于顺序元素值比较对象的副本。

value_compare value_comp( ) const;

返回值

返回 hash_multiset 模板参数 Traits,包含函数对象用于哈希和访问容器的顺序元素。

有关 Traits 的更多信息 hash_multiset Class 请参见主题。

备注

存储的对象定义一个成员函数:

bool operator(constKey&_xVal, const Key& _yVal);

后者返回 true if _xVal precedes and is not equal to _yVal 不相等按排序顺序。

请注意 key_comparevalue_compare 是模板参数的 Traits同义词。 两个类型为 hash_multiset 和 hash_multiset 选件类提供,它们用于 hash_map 和 hash_multimap 选件类的兼容性是相同的,因此,它们是不同的。

在 Visual C++ .NET 2003 中,<hash_map><hash_set> 标头文件的成员中不再标准,命名空间,而是将 stdext 命名空间。 有关更多信息,请参见 stdext 命名空间

示例

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

int main( )
{
   using namespace std;
   using namespace stdext;
   
   hash_multiset <int, hash_compare < int, less<int> > > hms1;
   hash_multiset <int, hash_compare < int, less<int> > >::value_compare
      vc1 = hms1.value_comp( );
   bool result1 = vc1( 2, 3 );
   if( result1 == true )
   {
      cout << "vc1( 2,3 ) returns value of true, "
           << "where vc1 is the function object of hms1."
           << endl;
   }
   else
   {
      cout << "vc1( 2,3 ) returns value of false, "
           << "where vc1 is the function object of hms1."
           << endl;
   }

   hash_multiset <int, hash_compare < int, greater<int> > > hms2;
   hash_multiset<int, hash_compare < int, greater<int> > >::
           value_compare vc2 = hms2.value_comp( );
   bool result2 = vc2( 2, 3 );
   if( result2 == true )
   {
      cout << "vc2( 2,3 ) returns value of true, "
           << "where vc2 is the function object of hms2."
           << endl;
   }
   else
   {
      cout << "vc2( 2,3 ) returns value of false, "
           << "where vc2 is the function object of hms2."
           << endl;
   }
}
  
  

要求

标头: <hash_set>

命名空间: stdext

请参见

参考

hash_multiset Class

标准模板库