Files
hello-algo/ja/codes/cpp/chapter_hashing/array_hash_map_test.cpp
Ikko Eltociear Ashimine 954c45864b docs: add Japanese translate documents (#1812)
* docs: add Japanese documents (`ja/docs`)

* docs: add Japanese documents (`ja/codes`)

* docs: add Japanese documents

* Remove pythontutor blocks in ja/

* Add an empty at the end of each markdown file.

* Add the missing figures (use the English version temporarily).

* Add index.md for Japanese version.

* Add index.html for Japanese version.

* Add missing index.assets

* Fix backtracking_algorithm.md for Japanese version.

* Add avatar_eltociear.jpg. Fix image links on the Japanese landing page.

* Add the Japanese banner.

---------

Co-authored-by: krahets <krahets@163.com>
2025-10-17 05:04:43 +08:00

52 lines
1.4 KiB
C++

/**
* File: array_hash_map_test.cpp
* Created Time: 2022-12-14
* Author: msk397 (machangxinq@gmail.com)
*/
#include "./array_hash_map.cpp"
/* ドライバーコード */
int main() {
/* ハッシュテーブルを初期化 */
ArrayHashMap map = ArrayHashMap();
/* 追加操作 */
// キー値ペア(key, value)をハッシュテーブルに追加
map.put(12836, "Ha");
map.put(15937, "Luo");
map.put(16750, "Suan");
map.put(13276, "Fa");
map.put(10583, "Ya");
cout << "\nAfter adding, the hash table is\nKey -> Value" << endl;
map.print();
/* クエリ操作 */
// ハッシュテーブルにキーを入力、値を取得
string name = map.get(15937);
cout << "\nEnter student ID 15937, found name " << name << endl;
/* 削除操作 */
// ハッシュテーブルからキー値ペア(key, value)を削除
map.remove(10583);
cout << "\nAfter removing 10583, the hash table is\nKey -> Value" << endl;
map.print();
/* ハッシュテーブルを走査 */
cout << "\nTraverse key-value pairs Key->Value" << endl;
for (auto kv : map.pairSet()) {
cout << kv->key << " -> " << kv->val << endl;
}
cout << "\nIndividually traverse keys Key" << endl;
for (auto key : map.keySet()) {
cout << key << endl;
}
cout << "\nIndividually traverse values Value" << endl;
for (auto val : map.valueSet()) {
cout << val << endl;
}
return 0;
}