Last active
August 6, 2021 20:37
-
-
Save aozturk/7337032 to your computer and use it in GitHub Desktop.
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
// 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; | |
}; |
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.