Please enable JavaScript.
Coggle requires JavaScript to display documents.
HashMap (strucutre (Entry<K,V> : key-value pair model (K key : key…
HashMap
strucutre
table: Array of Entry<K,V> : store key-value pairs.
Length is power of 2, default 16, double when expanding.
-
Entry<K,V> : key-value pair model
Entry<K,V> next : reference to next entry
-
int hash : hash value computed by hash(), stored to make compare faster
-
loadFactor : high water mark where to extend table size, default 0.75
-
-
How to
-
find entry of given key
compare:
- hash
- key1 == key2
- key1.equals(key2)
remove a key-value pair
- find prev and next of the entry to remove
- if entry to remove is head in the linkedlist, set head to next
- otherwise set prev.next = next
-