a HashMap
is O(1) average, so it is supposed to be faster, and for large maps will probably have better throughput.
However, a HashMap
requires rehashing when Load Balance become too high. rehashing is O(n), so at any time of the program's life, you may suffer unexpectedly performance loss due to rehash, which might be critical in some apps [high latency]. So think twice before using HashMap
if latency is an issue!
a HashMap
is also vulnerable to poor hashing functions, which might cause O(n), if many items in use are hashed into the same place.