Skip to content

Preserve ordering function when converting to a TreeMap#110

Merged
mperry merged 2 commits into
functionaljava:masterfrom
dobesv:to-mutable-map-comparator
Mar 22, 2015
Merged

Preserve ordering function when converting to a TreeMap#110
mperry merged 2 commits into
functionaljava:masterfrom
dobesv:to-mutable-map-comparator

Conversation

@dobesv

@dobesv dobesv commented Feb 20, 2015

Copy link
Copy Markdown
Contributor

fj.data.TreeMap was using the default Comparator instance in toMutableMap(). The biggest problem with this is that the default comparator requires that keys implement Comparable, whereas fj.data.TreeMap does not require keys to implement Comparable. Even when keys do implement Comparable, the user may have used a different ordering in their fj.data.TreeMap which can be preserved in the resulting java.util.TreeMap.

mperry added a commit that referenced this pull request Mar 22, 2015
Preserve ordering function when converting to a TreeMap
@mperry
mperry merged commit ce69370 into functionaljava:master Mar 22, 2015
@mperry

mperry commented Mar 22, 2015

Copy link
Copy Markdown
Contributor

Thanks for this @dobesv. Sorry about the delay in merging this. Looking at this it looks like the need to reverse the keys arises from foldMap on Set doing the right branch before the left. I suspect this should be done in the opposite order. Thoughts?

@mperry mperry added this to the v4.4 milestone May 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants