commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-786) "hashCode" in "Pair" class
Date Mon, 07 May 2012 10:03:49 GMT

    [ https://issues.apache.org/jira/browse/MATH-786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13269484#comment-13269484
] 

Gilles commented on MATH-786:
-----------------------------

bq. Of course the default value of the flag will be "true".

Probably better to be safe, and thus set the default to "false"!

I also add to the discussion that in most parts of Commons Math, we try to avoid dangerous
assumptions (cf. defensive copies).

Here we cannot make copies but still can offer both options (assume immutable or not). It
is still indeed the users' responsibility to use the object consistently with his stated assumption.

And, assuming mutability by default will also preserve compatibility with current behaviour
(were the hash code is not cached).

                
> "hashCode" in "Pair" class
> --------------------------
>
>                 Key: MATH-786
>                 URL: https://issues.apache.org/jira/browse/MATH-786
>             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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message