list literal gotcha and suggestion
Mark Thornton
mthornton at optrak.co.uk
Fri Oct 2 01:19:19 PDT 2009
abies at adres.pl wrote:
>
> "Joseph D. Darcy" <Joe.Darcy at Sun.COM> napisał(a):
>
> > A class cannot simultaneously satisfy the List and Set contracts for
> > equals; various properties fail to hold such as (a.equals(b) &&
> > a.equals(c) ==> b.equals(c)):
> > if listset.equals(list) && listset.equals(set), list.equals(set) will
> > *not* be true.
>
>
> Even easier example is hashCode - list starts with 1 for empty and is doing *31 for each element, while set starts with 0 and is just sum of elements' hashcodes (to avoid being iteration order dependent).
>
>
>
Yes, I realised that problem after turning off my machine last night. Pity.
Mark
More information about the coin-dev
mailing list