0

I was reading about hash-map resolving techniques and in one article the advantages and disadvantages were listed for separate chaining. Who decides which hash collision resolving technique is to be used? Is it purely internal, or is it configurable?

Raedwald
  • 46,613
  • 43
  • 151
  • 237
  • Who decides? The person creating the classes and code, of course. I'm not sure I really understand your question though. – Hovercraft Full Of Eels Dec 05 '18 at 04:29
  • Override `hashCode()`, return a constant value. What happens? Why? – Elliott Frisch Dec 05 '18 at 04:32
  • 2
    Collision resolution algorithm is done by whoever implements the Hashmap. You can see how OpenJDK 10 does it [here](http://hg.openjdk.java.net/jdk10/jdk10/jdk/file/777356696811/src/java.base/share/classes/java/util/HashMap.java#l624) for `setVal`, and nearby for `getNode`, the two most important methods under the hood there. – Amadan Dec 05 '18 at 04:35
  • No, it isn't configurable, it's purely internal. You can only specify load factor and initial capacity. – fps Dec 05 '18 at 13:09

1 Answers1

3

Simply study the interface (the public methods) of the HashMap class. There are no methods or constructors for you that alter conflict resolution behavior.

Thus the answer is: at least for the standard library class, that part is internal.

The only parameters that you can influence are capacity and the load factor, but they don't affect the conflict resolution strategy.

GhostCat
  • 137,827
  • 25
  • 176
  • 248