top | item 24660802

(no title)

jp3141 | 5 years ago

Javas implementation of HashMap uses a tree on hash collision.

[0] https://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/...

discuss

order

quickthrower2|5 years ago

If the bin is big enough to warrant it, according to your link.

Thanks for the link!

I imagine they do this as the user space can define hash algorithms and someone is gonna just return zero every now and then out of laziness :-)

virgilp|5 years ago

You also need a comparable() key presumably - which you often have, but not always (a comparable() key is not strictly required by a hashtable).