클래스 value_compare 클래스
Provides a function object that can compare the elements of a hash_map by comparing the values of their keys to determine their relative order in the hash_map.
class value_compare
: std::public binary_function<value_type, value_type, bool>
{
public:
bool operator( )(
const value_type& _Left,
const value_type& _Right ) const
{
return ( comp( _Left.first, _Right.first ) );
}
protected:
value_compare( const key_compare& c ) : comp (c) { }
key_compare comp;
};
설명
The comparison criteria provided by value_compare between value_types of whole elements contained by a hash_map is induced from a comparison between the keys of the respective elements by the auxiliary class construction. The member function operator uses the object comp of type key_compare stored in the function object provided by value_compare to compare the sort-key components of two elements.
For hash_sets and hash_multisets, which are simple containers where the key values are identical to the element values, value_compare is equivalent to key_compare; for hash_maps and hash_multimaps they are not, because the value of the type pair elements is not identical to the value of the element's key.
Visual C++.NET 2003에서, <hash_map> 및 <hash_set> 헤더 파일의 멤버는 더 이상 std 네임스페이스에 존재하지 않습니다. 대신 stdext 네임스페이스로 이동되었습니다. 자세한 내용은 stdext 네임스페이스를 참조하십시오.
예제
See the example for hash_map::value_comp for an example of how to declare and use value_compare.
요구 사항
헤더: <hash_map>
네임스페이스: stdext