mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-24 23:50:45 +08:00
Fix Chinese wording that contradicted the demo code: the C++ std::hash scope, the Rust node-value hash label, the Go Pop comment and the Go stack test comment. Russian sources and all six editions' snippets follow; the Go heap snippets drop the repository-only PrintHeap call. Co-Authored-By: Claude Opus 5.5 <[email protected]>
30 lines
1.2 KiB
C++
30 lines
1.2 KiB
C++
/**
|
|
* File: built_in_hash.cpp
|
|
* Created Time: 2023-06-21
|
|
* Author: krahets ([email protected])
|
|
*/
|
|
|
|
#include "../utils/common.hpp"
|
|
|
|
/* Driver Code */
|
|
int main() {
|
|
int num = 3;
|
|
size_t hashNum = hash<int>()(num);
|
|
cout << "Хеш-значение целого числа " << num << " = " << hashNum << "\n";
|
|
|
|
bool bol = true;
|
|
size_t hashBol = hash<bool>()(bol);
|
|
cout << "Хеш-значение булева значения " << bol << " = " << hashBol << "\n";
|
|
|
|
double dec = 3.14159;
|
|
size_t hashDec = hash<double>()(dec);
|
|
cout << "Хеш-значение десятичного числа " << dec << " = " << hashDec << "\n";
|
|
|
|
string str = "Hello Algo";
|
|
size_t hashStr = hash<string>()(str);
|
|
cout << "Хеш-значение строки " << str << " = " << hashStr << "\n";
|
|
|
|
// В C++ встроенный std::hash() предоставляет вычисление хеша только для базовых типов данных и некоторых типов стандартной библиотеки (например, std::string)
|
|
// Вычисление хеша для массивов и объектов нужно реализовывать самостоятельно
|
|
}
|