共用方式為


hash 類別

計算值的雜湊程式碼。

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); 
    } 
 
3

需求

標題: <functional>

命名空間: std

請參閱

參考

<unordered_map>

unordered_multimap 類別

unordered_multiset 類別

<unordered_set>