Ok so I have points
which is a List<GeoPoint>
The following piece of code is written using java 8 functional API.
It takes the points, calculates for each point its matching cluster , and then groups them point by the ClusterKey
. Eventually we end up with a Map<ClusterKey, List<GeoPoint>
Here it is:
points.
parallelStream().unordered().
collect(groupingByConcurrent(Functions::calcClusterKey))