Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83973 - trunk/boost/geometry/index/detail/rtree/visitors
From: adam.wulkiewicz_at_[hidden]
Date: 2013-04-19 20:56:20


Author: awulkiew
Date: 2013-04-19 20:56:19 EDT (Fri, 19 Apr 2013)
New Revision: 83973
URL: http://svn.boost.org/trac/boost/changeset/83973

Log:
geometry.index.rtree: unclear condition in nearest query iterative visitor replaced by shorter and cleaner one.
Text files modified:
   trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp | 9 ++++-----
   1 files changed, 4 insertions(+), 5 deletions(-)

Modified: trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp 2013-04-19 20:56:19 EDT (Fri, 19 Apr 2013)
@@ -503,10 +503,9 @@
         typedef typename rtree::elements_type<leaf>::type elements_type;
         elements_type const& elements = rtree::elements(n);
 
- // store neighbours old count before addition of new values
- typename std::vector< std::pair<value_distance_type, const Value *> >
- ::size_type old_neighbors_count = neighbors.size();
-
+ // store distance to the furthest neighbour
+ value_distance_type greatest_distance = max_count() <= neighbors.size() ? neighbors.back().first : std::numeric_limits<value_distance_type>::max();
+
         // search leaf for closest value meeting predicates
         for ( typename elements_type::const_iterator it = elements.begin() ; it != elements.end() ; ++it)
         {
@@ -527,7 +526,7 @@
                                                 ::template get<point_relation_tag>(distances);
 
                     // if there is not enough values or current value is further than currently furthest neighbour
- if ( old_neighbors_count < max_count() || 0 == old_neighbors_count || dist < neighbors[old_neighbors_count - 1].first )
+ if ( dist < greatest_distance )
                     {
                         neighbors.push_back(std::make_pair(dist, boost::addressof(*it)));
                     }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk