Store the neighbors found in a std::set, instead of a list sorted by insertion sort (in type NN_list). This makes insertion O(log n) instead of O(n).
Store the neighbors found in a std::set, instead of a list sorted by insertion sort (in type NN_list). This makes insertion O(log n) instead of O(n).