Last active
August 6, 2021 20:37
-
-
Save aozturk/2369022 to your computer and use it in GitHub Desktop.
Test and example usage of the simple yet complete HashMap class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct MyKeyHash { | |
unsigned long operator()(const int& k) const | |
{ | |
return k % 10; | |
} | |
}; | |
HashMap<int, string, MyKeyHash> hmap; | |
hmap.put(1, "val1"); | |
hmap.put(2, "val2"); | |
hmap.put(3, "val3"); | |
string value; | |
hmap.get(2, value); | |
cout << value << endl; | |
bool res = hmap.get(3, value); | |
if (res) | |
cout << value << endl; | |
hmap.remove(3); | |
res = hmap.get(3, value); | |
if (res) | |
cout << value << endl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You might visit my blog post http://blog.aozturk.me/simple-hash-map-hash-table-implementation-in-c for through explanation.