Skip to content

Commit

Permalink
Merge pull request #13 from kn1cht/fix-incorrect-result
Browse files Browse the repository at this point in the history
Fix insertion bug in node_query_
  • Loading branch information
crvs authored Jul 9, 2024
2 parents a1baa5b + ed20caf commit 21d5a30
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions KDTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ void KDTree::node_query_(
auto const insert_it =
std::upper_bound(k_nearest_buffer.begin(), k_nearest_buffer.end(),
node_distance, detail::compare_node_distance);
if (insert_it == k_nearest_buffer.end() ||
insert_it->first != std::next(insert_it)->first) {
if (insert_it != k_nearest_buffer.end() ||
k_nearest_buffer.size() < num_nearest) {
k_nearest_buffer.insert(insert_it, node_distance);
}
while (k_nearest_buffer.size() > num_nearest) {
Expand Down

0 comments on commit 21d5a30

Please sign in to comment.