diff --git a/doc/generated/rtree_functions.qbk b/doc/generated/rtree_functions.qbk index f757938e1..f91bfe149 100644 --- a/doc/generated/rtree_functions.qbk +++ b/doc/generated/rtree_functions.qbk @@ -15,6 +15,7 @@ [[[link group__rtree__functions_1gaec0b88a9d8b408753e3069134f1598c7 `size(rtree<...> const &)`]][Get the number of values stored in the index. ]] [[[link group__rtree__functions_1ga459e3d404fec7cbd66794714cbdd129e `empty(rtree<...> const &)`]][Query if there are no values stored in the index. ]] [[[link group__rtree__functions_1gadb11fdb8e75ba7652286ec6750b49c4f `bounds(rtree<...> const &)`]][Get the box containing all stored values or an invalid box if the index has no values. ]] +[[[link group__rtree__functions_1ga043d21dc24c57fcabc5ee85093eb8b15 `swap(rtree<...> &, rtree<...> &)`]][Exchanges the contents of the container with those of other. ]] ] [#group__rtree__functions_1gac0ac9ed0e01f7494a5a3059e75d3c5cc] @@ -346,5 +347,27 @@ It calls [^`rtree::envelope()`].[heading Synopsis] The box containing all stored values or an invalid box. [endsect] +[#group__rtree__functions_1ga043d21dc24c57fcabc5ee85093eb8b15] +[section swap(rtree<...> &, rtree<...> &)] +Exchanges the contents of the container with those of other. + +[heading Description] +It calls [^[link classboost_1_1geometry_1_1index_1_1rtree_1aad0285d25f96341a8dd6cc22feb3bd73 rtree::swap()]].[heading Synopsis] +[pre +`template<``typename Value``,` + `typename Options``,` + `typename Translator``,` + `typename Allocator``>` +`void boost::geometry::index::swap``(``rtree< Value, Options, Translator, Allocator > &` `l``,` `rtree< Value, Options, Translator, Allocator > &` `r``)` +] + +[heading Parameter(s)] +[table +[[Type][Name][Description]] +[[`rtree< Value, Options, Translator, Allocator > &`][ `l` ][The first rtree. ]] +[[`rtree< Value, Options, Translator, Allocator > &`][ `r` ][The second rtree. ]] +] +[endsect] + [endsect] diff --git a/doc/html/geometry_index/r_tree/introduction.html b/doc/html/geometry_index/r_tree/introduction.html index 17f4bf92e..00e5b8943 100644 --- a/doc/html/geometry_index/r_tree/introduction.html +++ b/doc/html/geometry_index/r_tree/introduction.html @@ -214,7 +214,8 @@ Dependencies

- R-tree depends on Boost.Move, Boost.Container, Boost.Tuple. + R-tree depends on Boost.Move, Boost.Container, Boost.Tuple, + Boost.Utility, Boost.MPL.

diff --git a/doc/html/geometry_index/r_tree/reference.html b/doc/html/geometry_index/r_tree/reference.html index 447bf5d61..604920011 100644 --- a/doc/html/geometry_index/r_tree/reference.html +++ b/doc/html/geometry_index/r_tree/reference.html @@ -47,7 +47,7 @@ boost::geometry::index::rtree

- + The R-tree spatial index.

@@ -3268,6 +3268,19 @@ The R-tree spatial index.

+ + +

+ swap(rtree<...> + &, rtree<...> &) +

+ + +

+ Exchanges the contents of the container with those of other. +

+ +
@@ -4492,6 +4505,106 @@ The R-tree spatial index. The box containing all stored values or an invalid box.

+
+ +

+ Exchanges the contents of the container with those of other. +

+
+ + Description +
+

+ It calls rtree::swap(). +

+
+ + Synopsis +
+
template<typename Value,
+         typename Options,
+         typename Translator,
+         typename Allocator>
+void boost::geometry::index::swap(rtree< Value, Options, Translator, Allocator > & l, rtree< Value, Options, Translator, Allocator > & r)
+
+
+ + Parameter(s) +
+
+++++ + + + + + + + + + + + + + + + + + +
+

+ Type +

+
+

+ Name +

+
+

+ Description +

+
+

+ rtree< + Value, + Options, + Translator, + Allocator > + & +

+
+

+ l +

+
+

+ The first rtree. +

+
+

+ rtree< + Value, + Options, + Translator, + Allocator > + & +

+
+

+ r +

+
+

+ The second rtree. +

+
+

@@ -4503,7 +4616,7 @@ The R-tree spatial index. boost::geometry::index::linear

- + Linear r-tree creation algorithm parameters.

@@ -4578,7 +4691,7 @@ Linear r-tree creation algorithm parameters. boost::geometry::index::quadratic

- + Quadratic r-tree creation algorithm parameters.

@@ -4653,7 +4766,7 @@ Quadratic r-tree creation algorithm parameters. boost::geometry::index::rstar

- + R*-tree creation algorithm parameters.

@@ -4757,7 +4870,7 @@ R*-tree creation algorithm parameters. boost::geometry::index::runtime::linear

- + Linear r-tree creation algorithm parameters.

@@ -4893,7 +5006,7 @@ Linear r-tree creation algorithm parameters. boost::geometry::index::runtime::quadratic

- + Quadratic r-tree creation algorithm parameters.

@@ -5029,7 +5142,7 @@ Quadratic r-tree creation algorithm parameters. boost::geometry::index::runtime::rstar

- + R*-tree creation algorithm parameters.

@@ -6609,7 +6722,7 @@ R*-tree creation algorithm parameters. boost::geometry::index::translator::def

- + The default translator.

@@ -6679,7 +6792,7 @@ The default translator. boost::geometry::index::translator::index

- + The index translator.

diff --git a/doc/html/index.html b/doc/html/index.html index c4603e5a2..422519f60 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -51,7 +51,7 @@ - +

Last revised: February 17, 2013 at 14:52:29 GMT

Last revised: February 19, 2013 at 19:29:30 GMT


diff --git a/doc/rtree/introduction.qbk b/doc/rtree/introduction.qbk index 4da39d38a..d309dc6f4 100644 --- a/doc/rtree/introduction.qbk +++ b/doc/rtree/introduction.qbk @@ -57,7 +57,7 @@ Key features of this implementation of the __rtree__ are: [heading Dependencies] -R-tree depends on *Boost.Move*, *Boost.Container*, *Boost.Tuple*. +R-tree depends on *Boost.Move*, *Boost.Container*, *Boost.Tuple*, *Boost.Utility*, *Boost.MPL*. [heading Contributors] diff --git a/include/boost/geometry/index/adaptors/query.hpp b/include/boost/geometry/index/adaptors/query.hpp index d1647bcb6..472b3693b 100644 --- a/include/boost/geometry/index/adaptors/query.hpp +++ b/include/boost/geometry/index/adaptors/query.hpp @@ -56,6 +56,15 @@ struct query Predicates const& predicates; }; +template +index::adaptors::detail::query_range +operator|( + Index const& si, + index::adaptors::detail::query const& f) +{ + return index::adaptors::detail::query_range(si, f.predicates); +} + } // namespace detail /*! @@ -74,15 +83,6 @@ queried(Predicates const& pred) } // namespace adaptors -template -index::adaptors::detail::query_range -operator|( - Index const& si, - index::adaptors::detail::query const& f) -{ - return index::adaptors::detail::query_range(si, f.predicates); -} - }}} // namespace boost::geometry::index #endif // BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index 35a114eab..c57830576 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -133,6 +133,7 @@ private: typedef typename detail::rtree::leaf::type leaf; typedef typename allocators_type::node_pointer node_pointer; + typedef ::boost::container::allocator_traits allocator_traits_type; public: @@ -256,9 +257,10 @@ public: \li When memory allocation for Node fails. */ inline rtree(rtree const& src) - : m_members(src.m_members.translator(), src.m_members.parameters(), src.m_members.allocators()) + : m_members(src.m_members.translator(), + src.m_members.parameters(), + allocator_traits_type::select_on_container_copy_construction(src.get_allocator())) { - //TODO use Boost.Container allocator_traits_type::select_on_container_copy_construction() this->raw_copy(src, *this, false); } @@ -350,7 +352,12 @@ public: if ( this == &src ) return *this; - //TODO use Boost.Container allocator_traits_type::propagate_on_container_move_assignment + typedef boost::mpl::bool_< + allocator_traits_type::propagate_on_container_copy_assignment::value + > propagate; + if ( propagate::value && !(m_members.allocators() == src.m_members.allocators()) ) + this->raw_destroy(*this); + assign_cond(m_members.allocators(), src.m_members.allocators(), propagate()); // It uses m_allocators this->raw_copy(src, *this, true); @@ -376,21 +383,25 @@ public: if ( this == &src ) return *this; -//TODO use Boost.Container allocator_traits_type::propagate_on_container_move_assignment - if ( m_members.allocators() == src.m_members.allocators() ) { - m_members.translator() = src.m_members.translator(); - m_members.parameters() = src.m_members.parameters(); - this->raw_destroy(*this); + m_members.translator() = src.m_members.translator(); + m_members.parameters() = src.m_members.parameters(); boost::swap(m_members.values_count, src.m_members.values_count); boost::swap(m_members.leafs_level, src.m_members.leafs_level); boost::swap(m_members.root, src.m_members.root); + + typedef boost::mpl::bool_< + allocator_traits_type::propagate_on_container_move_assignment::value + > propagate; + rtree::move_cond(m_members.allocators(), src.m_members.allocators(), propagate()); } else { +// TODO - shouldn't here propagate_on_container_copy_assignment be checked like in operator=(const&)? + // It uses m_allocators this->raw_copy(src, *this, true); } @@ -947,12 +958,12 @@ private: \param src The source R-tree. \param dst The destination R-tree. - \param copy_all_internals If true, translator and parameters will also be copied. + \param copy_tr_and_params If true, translator and parameters will also be copied. \par Exception-safety strong */ - inline void raw_copy(rtree const& src, rtree & dst, bool copy_all_internals) const + inline void raw_copy(rtree const& src, rtree & dst, bool copy_tr_and_params) const { detail::rtree::visitors::copy copy_v(dst.m_members.allocators()); @@ -960,7 +971,7 @@ private: if ( src.m_members.root ) detail::rtree::apply_visitor(copy_v, *src.m_members.root); // MAY THROW (V, E: alloc, copy, N: alloc) - if ( copy_all_internals ) + if ( copy_tr_and_params ) { dst.m_members.translator() = src.m_members.translator(); // SHOULDN'T THROW dst.m_members.parameters() = src.m_members.parameters(); @@ -1049,6 +1060,18 @@ private: return result.finish(); } + template + static inline void assign_cond(T &, T const&, boost::mpl::bool_ const&) {} + + template + static inline void assign_cond(T & l, T const& r, boost::mpl::bool_ const&) { l = r; } + + template + inline void move_cond(T &, T &, boost::mpl::bool_ const&) {} + + template + inline void move_cond(T & l, T & r, boost::mpl::bool_ const&) { l = ::boost::move(r); } + struct members_holder : public translator_type , public Parameters @@ -1359,6 +1382,22 @@ bounds(rtree const& tree) return tree.bounds(); } +/*! +\brief Exchanges the contents of the container with those of other. + +It calls \c rtree::swap(). + +\ingroup rtree_functions + +\param l The first rtree. +\param r The second rtree. +*/ +template +inline void swap(rtree & l, rtree & r) +{ + return l.swap(r); +} + }}} // namespace boost::geometry::index #include