hash Class

计算值的哈希代码。

template<class Ty>
    struct hash
        : public unary_function<Ty, size_t> {
    size_t operator()(Ty _Val) const;
    };

备注

成员函数定义一个哈希函数,应用于映射类型 Ty 的值设置为索引值的分布。 成员运算符返回 _Val的哈希代码,适用于模板选件类 unordered_mapunordered_multimapunordered_setunordered_multiset的。 Ty 能为任何数据类型、stringwstringerror_codeerror_conditionu16stringu32string

示例

 

// std_tr1__functional__hash.cpp 
// compile with: /EHsc 
#include <functional> 
#include <iostream> 
#include <unordered_set> 
 
int main() 
    { 
    std::unordered_set<int, std::hash<int> > c0; 
    c0.insert(3); 
    std::cout << *c0.find(3) << std::endl; 
 
    return (0); 
    } 
 
  

要求

标头: <functional>

命名空间: std

请参见

参考

<unordered_map>

unordered_multimap Class

unordered_multiset Class

<unordered_set>