备注
此 API 已过时。替代为 unordered_set 类。
检索中 hash_set 用于排序元素值比较对象的副本。
value_compare value_comp( ) const;
返回值
返回 hash_set 使用对元素,是函数模板的参数的 Compare对象。
有关 Compare的更多信息,请参见 hash_set 类 主题的"备注"节。
备注
存储的对象定义成员函数:
bool operator(_xVal 的const Key&,const Key& _yVal);
如果后者返回 true,_xVal 之前和与排序顺序的 _yVal 不等于。
注意和 value_comparekey_compare 模板参数是的同义词。Compare 两个类型。hash_set 和 hash_multiset 类提供,它们用于 hash_map 和类 hash_multimap 的兼容性是相同的,因此,这些不同的。
在Visual C++ .NET 2003中,成员<hash_map> 和 <hash_set> 头文件不再在std命名空间,而是已经进入了stdext命名空间。 有关更多信息,请参见 stdext 命名空间。
示例
// 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;
}
}
Output
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.
要求
Header: <hash_set>
**命名空间:**stdext