hash_multimap::value_comp
참고
이 API는 사용되지 않습니다.unordered_multimap 클래스를 대신 사용하는 것이 좋습니다.
The member function returns a function object that determines the order of elements in a hash_multimap by comparing their key values.
value_compare value_comp( ) const;
반환 값
Returns the comparison function object that a hash_multimap uses to order its elements.
설명
For a hash_multimap m, if two elements e1(k1*, d1) and e2(k2, d*2) are objects of type value_type, where k1 and k2 are their keys of type key_type and d1 and d2 are their data of type mapped_type, then m.value_comp( )(e1, e2) is equivalent to m.key_comp( ) (k1, k2). A stored object defines the member function
bool operator(value_type& _Left, value_type& _Right);
which returns true if the key value of _Left precedes and is not equal to the key value of _Right in the sort order.
Visual C++.NET 2003에서, <hash_map> 및 <hash_set> 헤더 파일의 멤버는 더 이상 std 네임스페이스에 존재하지 않습니다. 대신 stdext 네임스페이스로 이동되었습니다. 자세한 내용은 stdext 네임스페이스를 참조하십시오.
예제
// hash_multimap_value_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> >
>::value_compare vc1 = hm1.value_comp( );
hash_multimap <int,int>::iterator Iter1, Iter2;
Iter1= hm1.insert ( hash_multimap <int, int> :: value_type ( 1, 10 ) );
Iter2= hm1.insert ( hash_multimap <int, int> :: value_type ( 2, 5 ) );
if( vc1( *Iter1, *Iter2 ) == true )
{
cout << "The element ( 1,10 ) precedes the element ( 2,5 )."
<< endl;
}
else
{
cout << "The element ( 1,10 ) does "
<< "not precede the element ( 2,5 )."
<< endl;
}
if( vc1( *Iter2, *Iter1 ) == true )
{
cout << "The element ( 2,5 ) precedes the element ( 1,10 )."
<< endl;
}
else
{
cout << "The element ( 2,5 ) does "
<< "not precede the element ( 1,10 )."
<< endl;
}
}
Output
The element ( 1,10 ) precedes the element ( 2,5 ).
The element ( 2,5 ) does not precede the element ( 1,10 ).
요구 사항
헤더: <hash_map>
네임스페이스: stdext