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

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

I'm not sure if we can make this work well. We can definitely make it _work_, 
but without access to the private details of the data structures the 
{{EntrySetSelector}} interfaces would be left to iterate through the entire map 
in order to find the correct entries. 

I've thought about the names some more and I've come up with what I consider 
better alternatives based on the antonym pair _near_/_far_ (as opposed to 
_close_/_far_).

{code:java}
PointSet<P> {
        P nearest(P pt);
        
        P nearestWithinRadius(P pt, double radius);

        P farthest(P pt);

        Collection<P> nearToFar(P pt);
        
        Collection<P> farToNear(P pt);
}

PointMap<P, V> {
        Map.Entry<P, V> nearestEntry(P pt);
        
        Map.Entry<P, V> nearestEntryWithinRadius(P pt, double radius);
        
        Map.Entry<P, V> farthestEntry(P pt);

        Collection<Map.Entry<P, V>> entriesNearToFar(P pt);
        
        Collection<Map.Entry<P, V>> entriesFarToNearP pt);
}
{code}

These names are concise and (to me, at least) provide a good mental image of 
the operation.

> 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.1#820001)

Reply via email to