Skip to content

Instantly share code, notes, and snippets.

@aozturk
Last active August 6, 2021 20:37
Show Gist options
  • Save aozturk/7337032 to your computer and use it in GitHub Desktop.
Save aozturk/7337032 to your computer and use it in GitHub Desktop.
// Hash node class template
template <typename K, typename V>
class HashNode {
public:
HashNode(const K &key, const V &value) :
key(key), value(value), next(NULL) {
}
K getKey() const {
return key;
}
V getValue() const {
return value;
}
void setValue(V value) {
HashNode::value = value;
}
HashNode *getNext() const {
return next;
}
void setNext(HashNode *next) {
HashNode::next = next;
}
private:
// key-value pair
K key;
V value;
// next bucket with the same key
HashNode *next;
};
@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