hash_set::value_comp
[!UWAGA]
Ten interfejs API jest nieaktualny.Alternatywą jest unordered_set — Klasa.
Pobiera kopię obiektu porównania używany do kolejności wartości elementu hash_set.
value_compare value_comp( ) const;
Wartość zwracana
Zwraca obiekt funkcji korzystającej z hash_set Aby zamówić jego elementów, który jest parametr szablonu Compare.
Aby uzyskać więcej informacji na temat Compare, zobacz sekcję Uwagi hash_set — Klasa tematu.
Uwagi
Obiektu przechowywana definiuje funkcję członka:
bool operator(const Key&_xVal, const Key& _yVal);
która oblicza true Jeśli _xVal poprzedza i nie jest równa _yVal w kolejności sortowania.
Należy zauważyć, że zarówno value_compare i key_compare są synonimami dla parametru szablonu Compare.Oba typy są dostarczane dla klas hash_set i hash_multiset, gdzie są one identyczne, dla zachowania zgodności z klasy hash_map i hash_multimap, gdzie są one różne.
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_set_value_comp.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_set <int, hash_compare < int, less<int> > > hs1;
hash_set <int, hash_compare < int, less<int> > >::value_compare
vc1 = hs1.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 hs1."
<< endl;
}
else
{
cout << "vc1( 2,3 ) returns value of false, "
<< "where vc1 is the function object of hs1."
<< endl;
}
hash_set <int, hash_compare < int, greater<int> > > hs2;
hash_set<int, hash_compare < int, greater<int> > >::value_compare
vc2 = hs2.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 hs2."
<< endl;
}
else
{
cout << "vc2( 2,3 ) returns value of false, "
<< "where vc2 is the function object of hs2."
<< endl;
}
}
Dane wyjściowe
vc1( 2,3 ) returns value of true, where vc1 is the function object of hs1.
vc2( 2,3 ) returns value of false, where vc2 is the function object of hs2.
Wymagania
Nagłówek: <hash_set>
Przestrzeń nazw: stdext