Udostępnij za pośrednictwem


hash_multimap::key_comp

[!UWAGA]

Ten interfejs API jest nieaktualny.Alternatywą jest unordered_multimap — Klasa.

Pobiera kopię obiektu porównania używany do kluczy zamówienia w hash_multimap.

key_compare key_comp( ) const;

Wartość zwracana

Zwraca obiekt funkcja hash_multimap używa się w celu zamówienia jego elementów.

Uwagi

Obiektu przechowywana definiuje funkcję członka

bool operator(const Key&_Left**, const Key&_Right);**

która oblicza true Jeśli _Left poprzedza i nie jest równa _Right w kolejności sortowania.

W Visual C++ .NET 2003, elementy członkowskie plików nagłówka <hash_map> i <hash_set> nie są już w przestrzeni nazw std, ale raczej zostały przeniesione do przestrzeni nazw stdext.Zobacz Przestrzeń nazw stdext, aby uzyskać więcej informacji.

Przykład

// hash_multimap_key_comp.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   
   hash_multimap <int, int, hash_compare<int, less<int> > > hm1;
   hash_multimap <int, int, hash_compare<int, less<int> > 
      >::key_compare kc1 = hm1.key_comp( ) ;
   bool result1 = kc1( 2, 3 ) ;
   if( result1 == true )
   {
      cout << "kc1( 2,3 ) returns value of true,\n"
           << "where kc1 is the function object of hm1.\n"
           << endl;
   }
   else   
   {
      cout << "kc1( 2,3 ) returns value of false,\n"
           << "where kc1 is the function object of hm1.\n"
           << endl;
   }

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

Dane wyjściowe

kc1( 2,3 ) returns value of true,
where kc1 is the function object of hm1.

kc2( 2,3 ) returns value of false,
where kc2 is the function object of hm2.

Wymagania

Nagłówek: <hash_map>

Przestrzeń nazw: stdext

Zobacz też

Informacje

hash_multimap — Klasa

Standardowa biblioteka szablonów