Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix insertion bug in node_query_ #13

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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