Closed chriseidhof closed 6 years ago
I think this should be fine. If a lot of points are rejected, the algorithm will eventually explore all subtree's, as without setting 'bestNewDistance' it will always check on the other side.
You might loose some performance because more subtree's will be checked, but it will still find the point closest to your start that fits the condition. Whether the points that the space is split at are part of the actual nearest-check or not doesn't change the outcome.
You can make a PR where the condition is nil
or { _ in true}
by default if you like 🙃
(If you do, please do for both nearest
and the nearestK
algorithm implementations, I split them since the nearest
is easier to reason for without the neighbours
-collection need for k
neighbours)
See #31
Is it possible to have a conditional in the kNearest method?
I'm thinking of something like this:
It compiles and works, but I'm not sure if I'm breaking any invariants here...