Sdílet prostřednictvím


hash_multiset::key_comp

[!POZNÁMKA]

Toto rozhraní API je zastaralé.Alternativou je unordered_multiset – třída.

Získá kopii porovnání objekt použitý k pořadí klíče hash_multiset.

key_compare key_comp( ) const;

Vrácená hodnota

Vrátí parametr šablony hash_multiset Traits, který obsahuje funkce objekty, které používají hodnoty hash a pořadí prvků kontejneru.

Další informace o Traits najdete hash_multiset – třída téma.

Poznámky

Uložené objektu definuje členskou funkci:

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

která vrátí true li _xVal předchází a není rovno _yVal v pořadí řazení.

Všimněte si, že obě key_compare a value_compare jsou synonyma pro parametr šablony znaky.Oba typy jsou k dispozici pro hash_multiset a hash_multiset třídy, jsou-li shodné pro kompatibilitu s hash_map a hash_multimap tříd, kde se liší.

V aplikaci Visual C++ .NET 2003, členové hlavičkových souborů tříd <hash_map> a <hash_set> již nejsou v oboru názvů std, ale byly přesunuty do oboru názvů stdext.Další informace naleznete v tématu Obor názvů stdext.

Příklad

// hash_multiset_key_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> > >::key_compare kc1
          = hms1.key_comp( ) ;
   bool result1 = kc1( 2, 3 ) ;
   if( result1 == true )
   {
      cout << "kc1( 2,3 ) returns value of true, "
           << "where kc1 is the function object of hms1."
           << endl;
   }
   else
   {
      cout << "kc1( 2,3 ) returns value of false "
           << "where kc1 is the function object of hms1."
        << endl;
   }

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

Výsledek

kc1( 2,3 ) returns value of true, where kc1 is the function object of hms1.
kc2( 2,3 ) returns value of false, where kc2 is the function object of hms2.

Požadavky

Záhlaví:<hash_set>

Obor názvů: stdext

Viz také

Referenční dokumentace

hash_multiset – třída

Standardní knihovna šablon