Closed gicappa closed 7 years ago
Hi @gicappa, it's a nice implementation. Do you consider this example as illustrative for the "Java 8 way"?
In such case I suggest you some minor changes:
In the Main
:
28: To uniform with other examples define ordered
and occurrences
variables, I prefer clearness over shortness.
38: You can write a collector to produce low
and high
lists
In the OccurrenceCountInMap
:
17: This is an example but there is no reason to reorder a just ordered datas, moreover using a binary tree with ordered datas is the worst case. I suggest you to use an HashMap
.
43: You miss the IDENTITY_FINISH
and UNORDERED
(TreeMap, you should use LinkedHashMap
) characteristics and if you rewrite combiner
you can add CONCURRENT
characteristic.
Hi @fvasco, given that I'm in the admin mailing list and I saw the last line of your email of the 28 June 16:58, I just thought to help with a more functional way using a Collector and avoiding all the nasty forEach without rewriting the existing code that was already using the TreeMap.
So please feel free to apply all the changes you deem necessary to my pull request to fulfil the "Java 8 way" you began.
I'd rather prefer to contribute with some TurboPascal or other old language code if I'll find the time😄 Ciao,
gk
I just reintroduced some local variables named ordered and occurrences because it is a very quick change. HTH!
Just as an exercise I tried a more functional approach creating a specific counting collector and avoiding side effects.
At the end I'm not sure the solution is really better: some missing features in the java functional world and the heavy syntax notation don't help the overall readability.