> On May 8, 2020, at 1:49 PM, Stuart Marks <[email protected]> wrote: > > The containsAll() and equals() methods both use the membership contract of > the receiver, not the argument. Unfortunately, the equals() specification > says, > > Returns true if the specified object is also a set, the two sets have the > same size, and every member of the specified set is contained in this set > (or equivalently, every member of this set is contained in the specified > set). > > As should be clear from this discussion, the "equivalently" clause is > incorrect -- another spec bug. Changing Set.equals() in this way would make Set inconsistent with Object. Do you really think that is a good idea? Comparator<String> cc = (a, b) -> a.compareToIgnoreCase(b); Set<String> s1 = new HashSet<>(); Set<String> s2 = new TreeSet<>(cc); s1.add("hello"); s2.add("Hello"); s1.equals(s2) -> false s2.equals(s1) -> true s1.hashCode() == s2.hashCode() -> false
- Re: RFR [15] 6394757: rev2: AbstractSet.removeAll semantics ... Jason Mehrens
- Re: RFR [15] 6394757: rev2: AbstractSet.removeAll seman... Stuart Marks
- Re: RFR [15] 6394757: rev2: AbstractSet.removeAll s... Alan Snyder
- Re: RFR [15] 6394757: rev2: AbstractSet.removeA... Stuart Marks
- Re: RFR [15] 6394757: rev2: AbstractSet.rem... Alan Snyder
- Re: RFR [15] 6394757: rev2: AbstractSe... Stuart Marks
- Re: RFR [15] 6394757: rev2: Abstra... Alan Snyder
- Re: RFR [15] 6394757: rev2: Abstra... Alan Snyder
- Re: RFR [15] 6394757: rev2: Abstra... Stuart Marks
- Re: RFR [15] 6394757: rev2: Abstra... Alan Snyder
- Re: RFR [15] 6394757: rev2: Abstra... Alan Snyder
- Re: RFR [15] 6394757: rev2: Abstra... Jason Mehrens
- Re: RFR [15] 6394757: rev2: Abstra... Alan Snyder
- Re: RFR [15] 6394757: rev2: Abstra... Jason Mehrens
- Re: RFR [15] 6394757: rev2: Abstra... Alan Snyder
- Re: RFR [15] 6394757: rev2: Abstra... Jason Mehrens
- Re: RFR [15] 6394757: rev2: Abstra... Stuart Marks
- Re: RFR [15] 6394757: rev2: Abstra... Alan Snyder
- Re: RFR [15] 6394757: rev2: Abstra... Stuart Marks
- Re: RFR [15] 6394757: rev2: Abstra... Alan Snyder
- Re: RFR [15] 6394757: rev2: AbstractSet.removeAll s... Jason Mehrens
