Why not allow an external interface to provide hashCode/equals for a HashMap?

前端 未结 9 1823
闹比i
闹比i 2020-12-17 15:28

With a TreeMap it\'s trivial to provide a custom Comparator, thus overriding the semantics provided by Comparable objects added to the

9条回答
  •  春和景丽
    2020-12-17 15:58

    Trove4j has the feature I'm after and they call it hashing strategies.

    Their map has an implementation with different limitations and thus different prerequisites, so this does not implicitly mean that an implementation for Java's "native" HashMap would be feasible.

提交回复
热议问题