|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83945 - in trunk/boost/geometry/index/detail/rtree: linear visitors
From: adam.wulkiewicz_at_[hidden]
Date: 2013-04-17 20:06:36
Author: awulkiew
Date: 2013-04-17 20:06:35 EDT (Wed, 17 Apr 2013)
New Revision: 83945
URL: http://svn.boost.org/trac/boost/changeset/83945
Log:
geometry.index rtree: error fixed in linear redistribute_elements, errors fixed in experimental spatial query iterator and visitor.
Text files modified:
trunk/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp | 5 +++--
trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp | 24 ++++++++++++++++--------
2 files changed, 19 insertions(+), 10 deletions(-)
Modified: trunk/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp 2013-04-17 20:06:35 EDT (Wed, 17 Apr 2013)
@@ -293,8 +293,9 @@
// choose group which box content have to be enlarged least or has smaller content or has fewer elements
if ( content_increase1 < content_increase2 ||
- ( content_increase1 == content_increase2 && content1 < content2 ) ||
- ( content1 == content2 && elements1.size() <= elements2.size() ) )
+ ( content_increase1 == content_increase2 &&
+ ( content1 < content2 ||
+ ( content1 == content2 && elements1.size() <= elements2.size() ) ) ) )
{
elements1.push_back(elem); // MAY THROW, STRONG (copy)
box1 = enlarged_box1;
Modified: trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp 2013-04-17 20:06:35 EDT (Wed, 17 Apr 2013)
@@ -121,14 +121,17 @@
void increment()
{
+ if ( values )
+ ++value_index;
+
for (;;)
{
+ // if leaf is choosen, move to the next value in leaf
if ( values )
{
- // ERROR: infinite loop - value_index isn't incremented
-
for ( ;; ++value_index )
{
+ // no more values, clear current leaf
if ( values->size() <= value_index )
{
values = 0;
@@ -136,6 +139,7 @@
break;
}
+ // return if next value is found
Value const& v = (*values)[value_index];
if ( index::detail::predicates_check<index::detail::value_tag, 0, predicates_len>(pred, v, tr(v)) )
return;
@@ -143,19 +147,25 @@
}
// move to the next leaf if values aren't set
- for ( ; !values ; ++internal_stack.back().first )
+ while ( !values )
{
+ // return if there is no more nodes to traverse
if ( internal_stack.empty() )
return;
+ // no more children in current node, remove it from stack
if ( internal_stack.back().first == internal_stack.back().second )
{
internal_stack.pop_back();
continue;
}
- if ( index::detail::predicates_check<index::detail::bounds_tag, 0, predicates_len>(pred, 0, internal_stack.back().first->first) )
- rtree::apply_visitor(*this, *(internal_stack.back().first->second));
+ internal_iterator it = internal_stack.back().first;
+ ++internal_stack.back().first;
+
+ // next node is found, push it to the stack
+ if ( index::detail::predicates_check<index::detail::bounds_tag, 0, predicates_len>(pred, 0, it->first) )
+ rtree::apply_visitor(*this, *(it->second));
}
}
}
@@ -181,16 +191,14 @@
typedef visitors::spatial_query_incremental<Value, Options, Translator, Box, Allocators, Predicates> visitor_type;
typedef typename visitor_type::node_pointer node_pointer;
- // WARNING! If const Value is passed to rebind it won't compile for interprocess' allocator
typedef typename Allocators::allocator_type::template rebind<Value>::other allocator_type;
public:
-
typedef std::input_iterator_tag iterator_category;
typedef const Value value_type;
typedef Value const& reference;
typedef typename allocator_type::difference_type difference_type;
- typedef typename allocator_type::pointer pointer;
+ typedef typename allocator_type::const_pointer pointer;
inline spatial_query_iterator(Translator const& t, Predicates const& p)
: m_visitor(t, p)
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