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

Gilles Sadowski commented on GEOMETRY-146:
------------------------------------------

{quote}I now have the internal logic for these operations implemented in all 
spaces and dimensions. All that's left now is to decide on the public API [...]
{quote}
Discussion can continue on the latter; that does not preclude committing the 
former (but please include "WIP" in the commit message, and mark the relevant 
codes with "TBD", with a link to here).
{quote}I see what you're saying about having a general API but I don't have any 
more ideas at this time other than the one I posted more recently.
{quote}
You did not comment about what was wrong with my proposed API, i.e. one that 
would keep iteration an internal part of the "result set". Or maybe I'm missing 
some inherent roadblock to that approach (?).
{quote}These two operations must be separate since there is a significant 
performance benefit to obtaining a single result versus iterating through the 
available points.
{quote}
We should separate two issues into two discussions:
 * one about the "selector" API (and iteration over the result set), and
 * one about the performance gained by having a specific API for returning a 
single element (rather than a set).

You intentionally hid the internal implementation of {{{}PointMap{}}}, yet the 
"near"/"far" methods make one assume that such an implementation _must_ support 
specific iteration "modes"; hence I'm feeling uncomfortable with the 
(apparent?) inconsistency, at the "public" level.  Sorry that I cannot convey 
the feeling in a more concrete way at this moment...

Overall I wonder whether we can provide all the necessary functionality 
(including performance), within the [stream/functional 
approach|https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html]
 that seems to characterize all recent development in Java.

Out of curiosity, could you document (in the "examples" module) the actual use 
cases that require one or the other iteration direction? That would also help 
us test alternative APIs and where to draw the line between "public" and 
"internal".

> 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