diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp index e092766ebbb..d86f5146e1a 100644 --- a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp +++ b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp @@ -638,9 +638,7 @@ Search(const size_t k, nodes.pop(); // Reset bounds of this node. - node->Stat().FirstBound() = SortPolicy::WorstDistance(); - node->Stat().SecondBound() = SortPolicy::WorstDistance(); - node->Stat().LastDistance() = 0.0; + node->Stat().Reset(); // Then add the children. for (size_t i = 0; i < node->NumChildren(); ++i) diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_stat.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_stat.hpp index dfcc5ad743b..433ea6486a7 100644 --- a/src/mlpack/methods/neighbor_search/neighbor_search_stat.hpp +++ b/src/mlpack/methods/neighbor_search/neighbor_search_stat.hpp @@ -57,6 +57,17 @@ class NeighborSearchStat auxBound(SortPolicy::WorstDistance()), lastDistance(0.0) { } + /** + * Reset statistic parameters to initial values. + */ + void Reset() + { + firstBound = SortPolicy::WorstDistance(); + secondBound = SortPolicy::WorstDistance(); + auxBound = SortPolicy::WorstDistance(); + lastDistance = 0.0; + } + //! Get the first bound. double FirstBound() const { return firstBound; } //! Modify the first bound.