Skip to content

Comment on Why Java's Object.hashCode() is unsafe for use in distributed systemsparent

Comments

From the implementation:

    * TreeBins use a special form of comparison for search and
     * related operations (which is the main reason we cannot use
     * existing collections such as TreeMaps). TreeBins contain
     * Comparable elements, but may contain others, as well as
     * elements that are Comparable but not necessarily Comparable<T>
     * for the same T, so we cannot invoke compareTo among them. To
     * handle this, the tree is ordered primarily by hash value, then
     * by getClass().getName() order, and then by Comparator order
     * among elements of the same class.  On lookup at a node, if
     * non-Comparable, both left and right children may need to be
     * searched in the case of tied hash values. (This corresponds to
     * the full list search that would be necessary if all elements
     * were non-Comparable and had tied hashes.)
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.