From HashMap
docs we can read:
Note that using many keys with the same hashCode() is a sure way to slow down performance of any hash table. To ameliorate impact, when keys are Comparable, this class may use comparison order among keys to help break ties.
I know that if the key implements Comparable
interface, on many hash collision, the bucket can transform from List
to TreeSet
.
Is it possible to set the capacity, or check when it will transform?