cpp-algo-cases/chapter_hashing/built_in_hash.cpp

30 lines
799 B
C++
Raw Normal View History

2024-02-20 16:13:23 +08:00
/**
* File: built_in_hash.cpp
* Created Time: 2023-06-21
* Author: krahets (krahets@163.com)
*/
#include "../utils/common.hpp"
/* Driver Code */
int main() {
int num = 3;
size_t hashNum = hash<int>()(num);
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> " << num << " <20>Ĺ<EFBFBD>ϣֵΪ " << hashNum << "\n";
bool bol = true;
size_t hashBol = hash<bool>()(bol);
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " << bol << " <20>Ĺ<EFBFBD>ϣֵΪ " << hashBol << "\n";
double dec = 3.14159;
size_t hashDec = hash<double>()(dec);
cout << "С<EFBFBD><EFBFBD> " << dec << " <20>Ĺ<EFBFBD>ϣֵΪ " << hashDec << "\n";
string str = "Hello <20>";
size_t hashStr = hash<string>()(str);
cout << "<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD> " << str << " <20>Ĺ<EFBFBD>ϣֵΪ " << hashStr << "\n";
// <20><> C++ <20>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD> std:hash() <20><><EFBFBD><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵Ĺ<CDB5>ϣֵ<CFA3><D6B5><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><E9A1A2><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD>ϣֵ<CFA3><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
}