Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81935 - in sandbox-branches/geometry/index: boost/geometry/extensions/index boost/geometry/extensions/index/rtree test/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2012-12-14 06:58:41


Author: awulkiew
Date: 2012-12-14 06:58:40 EST (Fri, 14 Dec 2012)
New Revision: 81935
URL: http://svn.boost.org/trac/boost/changeset/81935

Log:
Added assign() to the rtree interface. Fixed compilation error in static_vector.
Text files modified:
   sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp | 29 +++++++++++++
   sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp | 2
   sandbox-branches/geometry/index/test/rtree/test_rtree.hpp | 85 ++++++++++++++++++++++++++++++++++-----
   3 files changed, 104 insertions(+), 12 deletions(-)

Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp 2012-12-14 06:58:40 EST (Fri, 14 Dec 2012)
@@ -409,6 +409,35 @@
     }
 
     /*!
+ Assign new elements to the rtree. This method replaces the content of the rtree.
+
+ \note Exception-safety: strong
+
+ \param first The beginning of the range of values.
+ \param last The end of the range of values.
+ */
+ template <typename Iterator>
+ inline void assign(Iterator first, Iterator last)
+ {
+ rtree foo(first, last, this->parameters(), this->translator(), this->get_allocator());
+ this->swap(foo);
+ }
+
+ /*!
+ Assign new elements to the rtree. This method replaces the content of the rtree.
+
+ \note Exception-safety: strong
+
+ \param rng The range of values.
+ */
+ template <typename Range>
+ inline void assign(Range const& rng)
+ {
+ rtree foo(rng, this->parameters(), this->translator(), this->get_allocator());
+ this->swap(foo);
+ }
+
+ /*!
     Find values meeting spatial predicates, e.g. intersecting some box.
 
     \note Exception-safety: strong

Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp 2012-12-14 06:58:40 EST (Fri, 14 Dec 2012)
@@ -31,7 +31,7 @@
     BOOST_MPL_ASSERT_MSG(
         (0 < Capacity),
         INVALID_CAPACITY,
- static_vector);
+ (static_vector));
 
 public:
     typedef Value value_type;

Modified: sandbox-branches/geometry/index/test/rtree/test_rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/test_rtree.hpp (original)
+++ sandbox-branches/geometry/index/test/rtree/test_rtree.hpp 2012-12-14 06:58:40 EST (Fri, 14 Dec 2012)
@@ -911,7 +911,7 @@
 // rtree removing
 
 template <typename Value, typename Algo, typename Box>
-void test_remove_clear(bgi::rtree<Value, Algo> & tree, std::vector<Value> const& input, Box const& qbox)
+void test_remove(bgi::rtree<Value, Algo> & tree, std::vector<Value> const& input, Box const& qbox)
 {
     typedef bgi::rtree<Value, Algo> T;
 
@@ -973,20 +973,82 @@
         BOOST_CHECK( output.size() == tree.size() - values_to_remove.size() );
         test_compare_outputs(t, output, expected_output);
     }
+}
+
+template <typename Value, typename Algo, typename Box>
+void test_clear_assign(bgi::rtree<Value, Algo> & tree, std::vector<Value> const& input, Box const& qbox)
+{
+ typedef bgi::rtree<Value, Algo> T;
+
+ std::vector<Value> values_to_remove;
+ tree.spatial_query(qbox, std::back_inserter(values_to_remove));
+ BOOST_CHECK(0 < values_to_remove.size());
 
     //clear
     {
+ T t(tree);
+
         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);
+ t.spatial_query(bgi::intersects(qbox), std::back_inserter(expected_output));
+ size_t s = t.size();
+ t.clear();
+ BOOST_CHECK(t.empty());
+ BOOST_CHECK(t.size() == 0);
+ t.insert(input);
+ BOOST_CHECK(t.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);
+ t.spatial_query(bgi::intersects(qbox), std::back_inserter(output));
+ test_exactly_the_same_outputs(t, output, expected_output);
+ }
+
+ //assign iterators
+ {
+ T t(tree);
+
+ BOOST_CHECK(t.size() == tree.size());
+
+ std::vector<Value> expected_output;
+ t.spatial_query(t.box(), std::back_inserter(expected_output));
+
+ std::vector<Value> values_to_remove;
+ t.spatial_query(bgi::intersects(qbox), std::back_inserter(values_to_remove));
+ t.remove(values_to_remove);
+
+ BOOST_CHECK(t.size() == tree.size() - values_to_remove.size());
+
+ t.assign(input.begin(), input.end());
+
+ BOOST_CHECK(t.size() == tree.size());
+
+ std::vector<Value> output;
+ t.spatial_query(t.box(), std::back_inserter(output));
+
+ test_exactly_the_same_outputs(t, output, expected_output);
+ }
+
+ //assign range
+ {
+ T t(tree);
+
+ BOOST_CHECK(t.size() == tree.size());
+
+ std::vector<Value> expected_output;
+ t.spatial_query(t.box(), std::back_inserter(expected_output));
+
+ std::vector<Value> values_to_remove;
+ t.spatial_query(bgi::intersects(qbox), std::back_inserter(values_to_remove));
+ t.remove(values_to_remove);
+
+ BOOST_CHECK(t.size() == tree.size() - values_to_remove.size());
+
+ t.assign(input);
+
+ BOOST_CHECK(t.size() == tree.size());
+
+ std::vector<Value> output;
+ t.spatial_query(t.box(), std::back_inserter(output));
+
+ test_exactly_the_same_outputs(t, output, expected_output);
     }
 }
 
@@ -1025,7 +1087,8 @@
     test_copy_assignment_swap_move(tree, qbox);
 
     test_create_insert(tree, input, qbox);
- test_remove_clear(tree, input, qbox);
+ test_remove(tree, input, qbox);
+ test_clear_assign(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