次の方法で共有


hash_multiset::value_comp

[!メモ]

この API は、互換性のために残されています。代わりに unordered_multiset クラスです。

hash_multisetで使用されている順序の要素の値の比較のオブジェクトのコピーを取得します。

value_compare value_comp( ) const;

戻り値

コンテナー要素のハッシュを計算してから、並べ替えに使用される関数オブジェクトを含むhash_multisetのテンプレート パラメーター Traitsを返します。

Traits の詳細に hash_multiset Class のトピックを参照してください。

解説

格納されているオブジェクトには、メンバー関数を定義します:

bool operator ( _yVal**[const]Key&**_xVal、const Key&) ;

_xVal の並べ替え順序の _yVal と一致させる前および true を返すかが。

key_comparevalue_compare の両方がテンプレート パラメーターのシノニム **[Traits]**であることに注意してください。どちらの型も明確なhash_map、およびhash_multimapのクラスとの互換性のために、同一であるhash_multisetとhash_multisetのクラスに提供されます。

Visual C++ .NET 2003では、<hash_map><hash_set> ヘッダー ファイルのメンバーはstdの名前空間に存在しなくなりましたが、ではなくstdextの名前空間に型。詳細については、「The stdext Namespace」を参照してください。

使用例

// 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

標準テンプレート ライブラリ