7 ms·
Javas implementation of HashMap uses a tree on hash collision. [0] https://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/util/Hash
by jp3141 6y ago
Javas implementation of HashMap uses a tree on hash collision.
[0] https://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/util/HashMap.java#l156 https://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/...
- quickthrower2 6y agoIf 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 :-)
- deleted 6y ago[deleted]
- virgilp 6y agoYou also need a comparable() key presumably - which you often have, but not always (a comparable() key is not strictly required by a hashtable).