[ 
https://issues.apache.org/jira/browse/GEOMETRY-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17527268#comment-17527268
 ] 

Matt Juntunen commented on GEOMETRY-146:
----------------------------------------

{{neighborEntriesFullBaseline}} was a baseline comparison method that simply 
iterated through the _entire_ map and pulled out the ones that were within the 
max distance. It was basically like this:
{code:java}
Vector3D refPt = ...
double maxDist  = ...

List<Entry<Vector3D, Integer>> neighbors = new ArrayList<>();
for (Entry<Vector3D, Integer> entry : map.entrySet()) {
    if (entry.getKey().distance(refPt) <= maxDist) {
        neighbors.add(entry);
    }
}
{code}
No optimizations or anything. I was completely dumbfounded that this was faster 
than anything else but I was unable to see anything wrong with the tests. The 
tests above are with maps with about ~8000 entries. The main culprit I could 
see was the use of streams vs raw iterators. For example, {{neighborEntries}} 
and {{neighborEntriesFullStreamBaseline}} use streams.

> PointSet/Map closest points
> ---------------------------
>
>                 Key: GEOMETRY-146
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-146
>             Project: Commons Geometry
>          Issue Type: New Feature
>            Reporter: Matt Juntunen
>            Priority: Major
>             Fix For: 1.1
>
>
> Add methods to the new {{PointSet}} and {{PointMap}} interfaces to allow 
> querying of points in order of distance from a query point.
> {code:java}
> PointSet<P> {
>     // find the closest point to pt or null if empty 
>     P closest(P pt);
>     // iterate through points in order, with points closest to pt coming first
>     Iterable<P> closestFirst(P pt);
>     // find the farthest point from pt or null if emtpy
>     P farthest(P pt);
>     // iterate through point in order, with points farthest from pt coming 
> first
>     Iterable<P> farthestFirst(P pt);
> }
> {code}
> {{PointMap}} should have similar methods providing access to the map keys and 
> entries.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to