hash クラス

更新 : 2007 年 11 月

値のハッシュ コードを計算します。

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

解説

このメンバ演算子は、val のハッシュ コードを返します。テンプレート クラス unordered_map、unordered_multimap、unordered_set、および unordered_multiset での使用に適しています。Ty には、任意のスカラ型、string、または wstring を指定できます。

使用例

 

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

必要条件

ヘッダー : <functional>

名前空間 : std::tr1

参照

参照

<functional> (TR1)

<unordered_map>

unordered_multimap クラス

unordered_multiset クラス

<unordered_set>