Files
hello-algo/ru/codes/cpp/chapter_hashing/built_in_hash.cpp
T
Yudong JinandClaude Opus 5.5 6d19673be3 Fix demo comments and labels that contradict the code (#2048)
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]>
2026-11-23 21:50:05 +08:00

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)
// Вычисление хеша для массивов и объектов нужно реализовывать самостоятельно
}