Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84108 - trunk/boost/geometry/index/detail/rtree/visitors
From: adam.wulkiewicz_at_[hidden]
Date: 2013-05-02 08:23:02


Author: awulkiew
Date: 2013-05-02 08:23:01 EDT (Thu, 02 May 2013)
New Revision: 84108
URL: http://svn.boost.org/trac/boost/changeset/84108

Log:
geometry.index: query_visitor_incremental - index to current value replaced by pair of iterators
Text files modified:
   trunk/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp | 23 ++++++++++++-----------
   1 files changed, 12 insertions(+), 11 deletions(-)

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-05-02 08:23:01 EDT (Thu, 02 May 2013)
@@ -90,13 +90,14 @@
 
     typedef typename rtree::elements_type<internal_node>::type::const_iterator internal_iterator;
     typedef typename rtree::elements_type<leaf>::type leaf_elements;
+ typedef typename rtree::elements_type<leaf>::type::const_iterator leaf_iterator;
 
     static const unsigned predicates_len = index::detail::predicates_length<Predicates>::value;
 
     inline spatial_query_incremental(Translator const& t, Predicates const& p)
         : m_translator(::boost::addressof(t))
         , m_pred(p)
- , m_values(0), m_value_index(0)
+ , m_values(0)
     {}
 
     inline void operator()(internal_node const& n)
@@ -109,40 +110,40 @@
 
     inline void operator()(leaf const& n)
     {
- m_values = boost::addressof(rtree::elements(n));
- m_value_index = 0;
+ m_values = ::boost::addressof(rtree::elements(n));
+ m_current = rtree::elements(n).begin();
+ m_last = rtree::elements(n).end();
     }
 
     const_reference dereference() const
     {
         BOOST_ASSERT_MSG(m_values, "not dereferencable");
- return (*m_values)[m_value_index];
+ return *m_current;
     }
 
     void increment()
     {
         if ( m_values )
- ++m_value_index;
+ ++m_current;
 
         for (;;)
         {
             // if leaf is choosen, move to the next value in leaf
             if ( m_values )
             {
- if ( m_value_index < m_values->size() )
+ if ( m_current != m_last )
                 {
                     // return if next value is found
- Value const& v = (*m_values)[m_value_index];
+ Value const& v = *m_current;
                     if ( index::detail::predicates_check<index::detail::value_tag, 0, predicates_len>(m_pred, v, (*m_translator)(v)) )
                         return;
 
- ++m_value_index;
+ ++m_current;
                 }
                 // no more values, clear current leaf
                 else
                 {
                     m_values = 0;
- m_value_index = 0;
                 }
             }
             // if leaf isn't choosen, move to the next leaf
@@ -171,7 +172,7 @@
 
     friend bool operator==(spatial_query_incremental const& l, spatial_query_incremental const& r)
     {
- return (l.m_values == r.m_values) && (l.m_value_index == r.m_value_index);
+ return (l.m_values == r.m_values) && (l.m_values == 0 || l.m_current == r.m_current );
     }
 
 private:
@@ -182,7 +183,7 @@
 
     std::vector< std::pair<internal_iterator, internal_iterator> > m_internal_stack;
     const leaf_elements * m_values;
- size_type m_value_index;
+ leaf_iterator m_current, m_last;
 };
 
 } // namespace visitors


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