共用方式為


hash_multiset::value_comp

注意事項注意事項

這個 API 已經過時。這個選項是 unordered_multiset Class

擷取在 hash_multiset 用來解析命令項目值比較物件的複本。

value_compare value_comp( ) const;

傳回值

傳回 hash_multiset 樣板參數 Traits,包含函式物件用於雜湊和排序容器的項目。

如需 Traits 資訊請參閱 hash_multiset Class 主題。

備註

儲存物件定義成員函式:

bool operator( _yValconstKey&_xVal,的 const Key&);

要傳回 true ,如果 _xVal 前面並與在排序次序中的 _yVal 不相等。

請注意 key_comparevalue_compare 是樣板參數的 Traits同義資料表。兩個型別為 hash_multiset 和 hash_multiset 類別提供,因此對於使用 hash_map 和 hash_multimap 類別的相容性相同,,它們是不同的。

在 Visual C++ .NET Pocket PC, <hash_map><hash_set> 標頭檔 (Header File) 的成員不在 std 命名空間,,而是移至 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

標準樣板程式庫