{"action":"created","issue":{"url":"https://api.github.com/repos/javaslang/javaslang/issues/1317","repository_url":"https://api.github.com/repos/javaslang/javaslang","labels_url":"https://api.github.com/repos/javaslang/javaslang/issues/1317/labels{/name}","comments_url":"https://api.github.com/repos/javaslang/javaslang/issues/1317/comments","events_url":"https://api.github.com/repos/javaslang/javaslang/issues/1317/events","html_url":"https://github.com/javaslang/javaslang/pull/1317","id":153329408,"number":1317,"title":"Added support for navigable fields in SortedMap/TreeMap","user":{"login":"eduardmanas","id":10696876,"avatar_url":"https://avatars.githubusercontent.com/u/10696876?v=3","gravatar_id":"","url":"https://api.github.com/users/eduardmanas","html_url":"https://github.com/eduardmanas","followers_url":"https://api.github.com/users/eduardmanas/followers","following_url":"https://api.github.com/users/eduardmanas/following{/other_user}","gists_url":"https://api.github.com/users/eduardmanas/gists{/gist_id}","starred_url":"https://api.github.com/users/eduardmanas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduardmanas/subscriptions","organizations_url":"https://api.github.com/users/eduardmanas/orgs","repos_url":"https://api.github.com/users/eduardmanas/repos","events_url":"https://api.github.com/users/eduardmanas/events{/privacy}","received_events_url":"https://api.github.com/users/eduardmanas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":31,"created_at":"2016-05-05T21:23:15Z","updated_at":"2016-06-26T10:55:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/javaslang/javaslang/pulls/1317","html_url":"https://github.com/javaslang/javaslang/pull/1317","diff_url":"https://github.com/javaslang/javaslang/pull/1317.diff","patch_url":"https://github.com/javaslang/javaslang/pull/1317.patch"},"body":"1) Added support for navigable fields in `SortedMap`/`TreeMap`- Added `descendingIterator()`/`descendingKeySet()` methods\r\n- Added `descendingMap()` method to create a map with reversed order\r\n- Added `subMap()`/`headMap()`/`tailMap()` methods to create a subMap view of this map\r\n- Added `floor`/`ceiling`/`higher`/`lower` methods to navigate the sorted map\r\n\r\n2) Refactored `RedBlackTree` to:\r\n- support ascending/descending sub-trees\r\n- support descending iterator\r\n- Changed hierarchy structure:\r\n```\r\n    RedBlackTree  <----- Node  <--- ValueNode\r\n\t               \\            \\-- Empty\r\n\t\t            \\\r\n\t                 \\-- AbstractSubTreeView  <----  AscendingSubTreeView\r\n\t\t\t\t\t                           \\---  DescendingSubTreeView\r\n\r\n```\r\n3) Added `TreeMapBenchmark`\r\n- Measure `TreeMap` and new navigable methods performance versus Java/Scala implementation\r\n- Created `BenchmarkPerformanceReporter` to show nice looking performance comparison reports."},"comment":{"url":"https://api.github.com/repos/javaslang/javaslang/issues/comments/228595480","html_url":"https://github.com/javaslang/javaslang/pull/1317#issuecomment-228595480","issue_url":"https://api.github.com/repos/javaslang/javaslang/issues/1317","id":228595480,"user":{"login":"eduardmanas","id":10696876,"avatar_url":"https://avatars.githubusercontent.com/u/10696876?v=3","gravatar_id":"","url":"https://api.github.com/users/eduardmanas","html_url":"https://github.com/eduardmanas","followers_url":"https://api.github.com/users/eduardmanas/followers","following_url":"https://api.github.com/users/eduardmanas/following{/other_user}","gists_url":"https://api.github.com/users/eduardmanas/gists{/gist_id}","starred_url":"https://api.github.com/users/eduardmanas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduardmanas/subscriptions","organizations_url":"https://api.github.com/users/eduardmanas/orgs","repos_url":"https://api.github.com/users/eduardmanas/repos","events_url":"https://api.github.com/users/eduardmanas/events{/privacy}","received_events_url":"https://api.github.com/users/eduardmanas/received_events","type":"User","site_admin":false},"created_at":"2016-06-26T10:55:39Z","updated_at":"2016-06-26T10:55:39Z","body":"`Next will be the sub views and the navigable Set. For other collections we decided not to implement views that keep all underlying elements. The memory footprint at runtime matters. E.g. when having a Map that contains 1.000.000 entries and we create a sub map of 1 entry, we do not want to keep 1.000.000 elements in memory in the case the original map is not referenced any more after that operation.`\r\n\r\nLet's leave this discussion for the future PR, but personally I think it would be a mistake not to optimise for speed. \r\n\r\nIn a nutshell, we can optimise either for speed or for memory. If we optimise for memory as you suggest, we are basically alienating all developers that require speed (and that includes most developers migrating from `java.util.TreeMap`).\r\n\r\nIf we optimise for speed, we can still have the option to cater for those developers needing to optimise for memory. We could for example make it clear in the javadoc that `subMap` has been optimised for speed, same as JDK implementation, as if you are concerned about memory usage, you could do something like this:\r\n`TreeMap.of(myMap.subMap(fromKey, toKey))`\r\n\r\nor even something like this if we wanted:\r\n`myMap.subMap(fromKey, toKey)).normalize()`\r\n"}}
{"actor":{"display_login":"eduardmanas"}}