You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Phil Steitz <ph...@gmail.com> on 2009/02/09 12:15:04 UTC

[math] When are OpenIntToDoubleHashMap instances equal? WAS Re: svn commit: r742257 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/linear/ java/org/apache/commons/math/util/ test/org/apache/commons/math/linear/

billbarker@apache.org wrote:

 Do we need this?
> +        if (mask != other.mask)
> +            return false;
>   
...


Or this?
> +        if (!Arrays.equals(states, other.states)){
>   
It would seem reasonable to me that two OpenIntToDoubleHashMaps would be 
equal iff they contain they contain the same entries and have the same 
default (missingEntries).   Including the private fields above in equals 
will make it more sensitive than that.  Since mask relates to capacity, 
I guess it could make sense to include that in equals comparisons, but 
unless I am misunderstanding how put works, I think that including 
states in the comparison could make two instances unequal if their 
entries have been added in different orders.  Do we want this?

Phil

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [math] When are OpenIntToDoubleHashMap instances equal? WAS Re: svn commit: r742257 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/linear/ java/org/apache/commons/math/util/ test/org/apache/commons/math/linear/

Posted by Bill Barker <wb...@wilshire.com>.
Ok, sort of letting eclipse take over. More comments inline.

"Phil Steitz" <ph...@gmail.com> wrote in message 
news:49901038.2070009@gmail.com...
> billbarker@apache.org wrote:
>
> Do we need this?
>> +        if (mask != other.mask)
>> +            return false;
>>   .

as the code stands now, unnecessary. The value can't be currently changed. 
More than happy to remove the check.

> ...
>
>
> Or this?
>> +        if (!Arrays.equals(states, other.states)){
>>
> It would seem reasonable to me that two OpenIntToDoubleHashMaps would be 
> equal iff they contain they contain the same entries and have the same 
> default (missingEntries).   Including the private fields above in equals 
> will make it more sensitive than that.  Since mask relates to capacity, I 
> guess it could make sense to include that in equals comparisons, but 
> unless I am misunderstanding how put works, I think that including states 
> in the comparison could make two instances unequal if their entries have 
> been added in different orders.  Do we want this?
>

I'm thinking probably not.  I agree with your def of equals for 
OpenIntToDoubleHashMap, so will change it.

> Phil 




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org