Add C++, Python, Go code for chapter_hashing

This commit is contained in:
machangxin
2022-12-14 17:18:32 +08:00
parent e5e6553f82
commit aeb4e6077d
10 changed files with 792 additions and 8 deletions

View File

@ -1,7 +1,7 @@
/*
* File: PrintUtil.hpp
* Created Time: 2021-12-19
* Author: Krahets (krahets@163.com)
* Author: Krahets (krahets@163.com), msk397 (machangxinq@gmail.com)
*/
#pragma once
@ -277,4 +277,19 @@ class PrintUtil {
}
cout << "[" + s.str() + "]" << '\n';
}
/**
* @brief Print a HashMap
*
* @tparam TKey
* @tparam TValue
* @param map
*/
// 定义模板参数 TKey 和 TValue用于指定键值对的类型
template <typename TKey, typename TValue>
static void printHashMap(unordered_map<TKey,TValue> map) {
for (auto kv : map) {
cout << kv.first << " -> " << kv.second << '\n';
}
}
};