This is a combination of both.
There is a basic, contiguous array that supports HashMap . Elements of this array are actually linked lists. Each time you add a key-value pair to a card, the key is hashed, and a linked list entry is added to the corresponding slot in the support array (i.e., the slot corresponding to the value of the hash key).
For example, a map that maps k to v might look like this:
0 1 2 3 4 5 6 7
+ --- + --- + --- + --- + --- + --- + --- + --- +
| | | | | | | | |
+ -X - + - X - + - β - + - X - + - X - + - X - + - X - + - X- +
β
β
+ --- +
| k |
| - |
| v |
+ --- +
There is a long βtableβ that supports the map, and a record that supports the specific k -to- v pairing.
You are probably best off looking at the HashMap source for yourself.
source share