Skip to content

Instantly share code, notes, and snippets.

@aozturk
Last active August 6, 2021 20:37
Show Gist options
  • Save aozturk/2369022 to your computer and use it in GitHub Desktop.
Save aozturk/2369022 to your computer and use it in GitHub Desktop.
Test and example usage of the simple yet complete HashMap class
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;
@aozturk
Copy link
Author

aozturk commented Nov 6, 2013

You might visit my blog post http://blog.aozturk.me/simple-hash-map-hash-table-implementation-in-c for through explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment