Hi,
org.apache.pivot.collections.ArrayList, HashMap, HashSet are overriding
equals and hashCode.
When a new element is added(or removed), the value of hashCode will be
changed.
This is problematic for using the instance(ArrayList) in a dictionary like
java.util.HashMap as the key value.
Essentially we cannot use it for key value.

I wonder this is intentional or bug.
If you need to compare the value based comparison, it might be better not to
override equal but introduce another method(e.g, equivalent).

I had some bug related to this. It will create some surprise for the user
and it will not be easy to find the cause of the problem.
I think if the collection is immutable, the current code would make sense
though.

-- 
Cheers,
calathus

Reply via email to