-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SortedSet#intersect does not always return elements from this #1666
Comments
Hi! I think we might be able to fix this issue by gently removing this part of the optimization code in https://github.com/eclipse/eclipse-collections/blob/master/eclipse-collections/src/main/java/org/eclipse/collections/impl/utility/internal/SetIterables.java#L77-L82 |
It makes sense to me. I'd like to get @mohrezaei's opinion too since there was a similar change in #1661 that raised performance concerns. |
So clearly the behavior and the doc are inconsistent. It should be noted that this can only happen if the set's sense of equality is different from whatever way the returned set's elements are being compared to elements from So there are two ways to fix this:
I would generally favor (2), for the following reasons:
We could even be very explicit in the doc and suggest using |
Context
According to the JavaDocs
SortedSet#intersect
should always return members from this:https://eclipse.dev/collections/javadoc/11.1.0/org/eclipse/collections/api/set/sorted/ImmutableSortedSet.html#intersect(org.eclipse.collections.api.set.SetIterable)
Issue
However, testing reveals that elements of the smallest of the 2 sets are returned instead. Not only contradicts this the API documentation, but this is counterintuitive as well.
In addition, when replacing
intersect
with theselect(Set::contains)
combination, the same functionality works as expected.Reproduction
Following test suite contains 4 test cases:
Technologies used:
The text was updated successfully, but these errors were encountered: