mikael-s-persson/ReaK — Issue #10: Sorted KNN
Author: daviddoria
Created: 2012-02-17 19:52:57+00:00
State: open

Is there a trivial change that could be made to this function:

inline void min_dist_linear_search(ForwardIterator first,
ForwardIterator last,
OutputContainer& output,
GetDistanceFunction distance,
CompareFunction compare,
unsigned int max_neighbors = 1,
DistanceValue radius = std::numeric_limits::infinity())

to make the results (in the OutputContainer) ordered by their distance? I.e. you could take the output.begin() and know it was the 'best match'? The only way I can think to do it is to use a "parallel sort" like this : http://programmingexamples.net/wiki/CPP/ParallelSort . And its not clear to me that the 'output_dist' vector is in sync with 'output' anyway, so maybe the distances don't even stay associated with the objects long enough to even parallel sort them? I guess I'm looking for something like std::set mixed with the "out of the object value" idea of the boost indirect queue.