Implementation of HashMap in Java
-
Implemented the HashMap<K,V> class here.
-
Here, the class is Hash<K,V> which takes in the (key,value) pair and is kept generic. I have used the Open separate chaining method to implement the Hash<K,V> class.
-
Methods implemented here are:
a) put(K key, V value)
b) get(K key)
c) removeKey(K key)
d) size()
e) reHash()
f) loadFactor() -
The loadFactor threshold is set to 0.7. If loadFactor exceeds 0.7, reHash() function is called to rehash the keys.