list literal gotcha and suggestion
abies at adres.pl
abies at adres.pl
Fri Oct 2 01:06:56 PDT 2009
"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).
Regards,
Artur Biesiadowski
More information about the coin-dev
mailing list