-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
Implement HashMap.map, fix HashSet.equals #505
Conversation
@Override | ||
public <U> Set<U> map(Function<? super Entry<K, V>, ? extends U> mapper) { | ||
return null; | ||
Objects.requireNonNull(mapper, "mapper is null"); | ||
return foldLeft(HashSet.empty(), (acc, entry) -> acc.add(mapper.apply(entry))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the functional route to do it. I think that mr. Odersky would be satisfied ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Regarding OK, so I will close this one, as |
Yes, the Euler tests are great for testing Javaslang. Please implement the equals method in this PR I suggested above. I will pull it then. HashMap needs no separate PR. Thx! |
I will take care now of flatMap and map in general as described here: #488 (comment) I can pull this into master today... |
If you execute a Stream.groupBy, followed by Stream.map, which tries to access the entry.{key,value} it will crash with an NPE.
As a "side effect" of running tests for `HashMap.map`, a problem with `HashSet.equals` was identified and fixed.
Thanks to @danieldietrich, HashSet.equals was further improved, eliminating the risk of ClassCastException.
62beeca
to
f140aff
Compare
Done, coverage increased by 0.2% :) |
Implement HashMap.map, fix HashSet.equals
Many thanks :) For your minimal example all should be ok. Currently it is not clear why the Iterator.equals failed - we will further investigate. The order of similar elements may change in general (having more than one element) because the Map (or HAMT) has a key set with no guarantee of order. |
As a "side effect" of running tests for
HashMap.map
,a problem with
HashSet.equals
was identified and fixed.Fixes #503 and #504.