Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81775 - in sandbox-branches/geometry/index_dev: boost/geometry/extensions/index/rtree test/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2012-12-07 17:22:50


Author: awulkiew
Date: 2012-12-07 17:22:49 EST (Fri, 07 Dec 2012)
New Revision: 81775
URL: http://svn.boost.org/trac/boost/changeset/81775

Log:
fixed error in rtree's clear(), test added.
Text files modified:
   sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/rtree.hpp | 21 +++++++--------------
   sandbox-branches/geometry/index_dev/test/rtree/test_rtree.hpp | 19 +++++++++++++++++--
   2 files changed, 24 insertions(+), 16 deletions(-)

Modified: sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/rtree.hpp (original)
+++ sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/rtree.hpp 2012-12-07 17:22:49 EST (Fri, 07 Dec 2012)
@@ -146,7 +146,7 @@
         }
         catch(...)
         {
- this->raw_destroy(*this, true);
+ this->raw_destroy(*this);
             throw;
         }
     }
@@ -176,7 +176,7 @@
         }
         catch(...)
         {
- this->raw_destroy(*this, true);
+ this->raw_destroy(*this);
             throw;
         }
     }
@@ -188,7 +188,7 @@
     */
     inline ~rtree()
     {
- this->raw_destroy(*this, true);
+ this->raw_destroy(*this);
     }
 
     /*!
@@ -586,7 +586,7 @@
     */
     inline void clear()
     {
- this->raw_destroy(*this, false);
+ this->raw_destroy(*this);
     }
 
     /*!
@@ -775,19 +775,12 @@
 
     \param t The container which is going to be destroyed.
     */
- inline void raw_destroy(rtree & t, bool destroy_root = true)
+ inline void raw_destroy(rtree & t)
     {
         if ( t.m_root )
         {
- if ( destroy_root )
- {
- detail::rtree::visitors::destroy<value_type, options_type, translator_type, box_type, allocators_type> del_v(t.m_root, t.m_allocators);
- detail::rtree::apply_visitor(del_v, *t.m_root);
- }
- else
- {
- detail::rtree::clear_node<value_type, options_type, translator_type, box_type, allocators_type>::apply(*t.m_root, t.m_allocators);
- }
+ detail::rtree::visitors::destroy<value_type, options_type, translator_type, box_type, allocators_type> del_v(t.m_root, t.m_allocators);
+ detail::rtree::apply_visitor(del_v, *t.m_root);
 
             t.m_root = 0;
         }

Modified: sandbox-branches/geometry/index_dev/test/rtree/test_rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index_dev/test/rtree/test_rtree.hpp (original)
+++ sandbox-branches/geometry/index_dev/test/rtree/test_rtree.hpp 2012-12-07 17:22:49 EST (Fri, 07 Dec 2012)
@@ -801,7 +801,7 @@
 // rtree removing
 
 template <typename Value, typename Algo, typename Box>
-void test_remove(bgi::rtree<Value, Algo> & tree, Box const& qbox)
+void test_remove_clear(bgi::rtree<Value, Algo> & tree, std::vector<Value> const& input, Box const& qbox)
 {
     typedef bgi::rtree<Value, Algo> T;
 
@@ -863,6 +863,21 @@
         BOOST_CHECK( output.size() == tree.size() - values_to_remove.size() );
         test_compare_outputs(t, output, expected_output);
     }
+
+ //clear
+ {
+ std::vector<Value> expected_output;
+ tree.spatial_query(bgi::intersects(qbox), std::back_inserter(expected_output));
+ size_t s = tree.size();
+ tree.clear();
+ BOOST_CHECK(tree.empty());
+ BOOST_CHECK(tree.size() == 0);
+ tree.insert(input);
+ BOOST_CHECK(tree.size() == s);
+ std::vector<Value> output;
+ tree.spatial_query(bgi::intersects(qbox), std::back_inserter(output));
+ test_exactly_the_same_outputs(tree, output, expected_output);
+ }
 }
 
 // run all tests for a single Algorithm and single rtree
@@ -900,7 +915,7 @@
     test_copy_assignment_swap_move(tree, qbox);
 
     test_create_insert(tree, input, qbox);
- test_remove(tree, qbox);
+ test_remove_clear(tree, input, qbox);
 
     // empty tree test
 


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