Collection - HashMap (Hash table)
A hash map is an implementation of a map that stores the data in buckets.
The distribution of the data to a bucket is via the hash value of the key map entry (hence a HashMap).
A hash map is used
- Iteration over collection views requires time proportional to:
- the capacity of the HashMap instance (the number of buckets)
- plus its size (the number of key-value mappings).
- capacity: The capacity is the number of buckets in the hash table.
The load factor is a measure of how full the hash table is allowed to get before its capacity is automatically increased.
A load factor of .75 offers a good tradeoff between time and space costs.
When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the hash table is rehashed (that is, internal data structures are rebuilt) so that the hash table has approximately twice the number of buckets.