mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-19 12:24:34 +08:00
Add C++, Python, Go code for chapter_hashing
This commit is contained in:
@ -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';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user