commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <>
Subject [jira] [Commented] (MATH-786) "hashCode" in "Pair" class
Date Thu, 10 May 2012 09:45:11 GMT


Gilles commented on MATH-786:

I'm inclined to agree with James here.
But if it is decided to keep the feature, then the Javadoc must be clarified.

# I put on this issue on someone else's behalf.
# Just after I clicked "submit issue", I realized the consistency problem: See my own first
# The discussion went on because _you_ were in favour of caching the hash code, without allowing
the current behaviour (no cache). IMO, not having the flag, and caching is the most dangerous

As for the comments on the clarity of the Javadoc, feel free to make it clearer for you.
IMHO, the class comment makes it quite obvious (for someone who knows what is meant by immutable
is this context) what the problem could be.

[1] (Initial) Question: Does someone see a way to make "Pair" truly immutable?
(Expected) Answer: No. It is thus not safe to cache the hash code value.
(Simple) Conclusion: "Won't fix".

* I'll remove the cache-related code.
* This issue at least served to point to the deficient behaviour of the class's "hashCode"
method previous implementation. The current one is better I think. Please review...

> "hashCode" in "Pair" class
> --------------------------
>                 Key: MATH-786
>                 URL:
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 3.0
>            Reporter: Gilles
>            Assignee: Gilles
>            Priority: Trivial
>             Fix For: 3.1
> Since "Pair" is supposed to be an immutable class, couldn't we cache the "hashCode" value
at construction? That would supposedly make it more efficient when used in maps.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message