comparison DEPENDENCIES/generic/include/boost/geometry/index/rtree.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
1 // Boost.Geometry Index 1 // Boost.Geometry Index
2 // 2 //
3 // R-tree implementation 3 // R-tree implementation
4 // 4 //
5 // Copyright (c) 2008 Federico J. Fernandez. 5 // Copyright (c) 2008 Federico J. Fernandez.
6 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. 6 // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
7 // 7 //
8 // Use, modification and distribution is subject to the Boost Software License, 8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt) 10 // http://www.boost.org/LICENSE_1_0.txt)
11 11
12 #ifndef BOOST_GEOMETRY_INDEX_RTREE_HPP 12 #ifndef BOOST_GEOMETRY_INDEX_RTREE_HPP
13 #define BOOST_GEOMETRY_INDEX_RTREE_HPP 13 #define BOOST_GEOMETRY_INDEX_RTREE_HPP
14 14
15 // STD
15 #include <algorithm> 16 #include <algorithm>
16 17
18 // Boost
17 #include <boost/tuple/tuple.hpp> 19 #include <boost/tuple/tuple.hpp>
18 #include <boost/move/move.hpp> 20 #include <boost/move/move.hpp>
19 21
20 #include <boost/geometry/geometry.hpp> 22 // Boost.Geometry
21 23 #include <boost/geometry/algorithms/detail/comparable_distance/interface.hpp>
24 #include <boost/geometry/algorithms/centroid.hpp>
25 #include <boost/geometry/algorithms/covered_by.hpp>
26 #include <boost/geometry/algorithms/disjoint.hpp>
27 #include <boost/geometry/algorithms/equals.hpp>
28 #include <boost/geometry/algorithms/intersects.hpp>
29 #include <boost/geometry/algorithms/overlaps.hpp>
30 #include <boost/geometry/algorithms/touches.hpp>
31 #include <boost/geometry/algorithms/within.hpp>
32
33 #include <boost/geometry/geometries/point.hpp>
34 #include <boost/geometry/geometries/box.hpp>
35
36 #include <boost/geometry/strategies/strategies.hpp>
37
38 // Boost.Geometry.Index
22 #include <boost/geometry/index/detail/config_begin.hpp> 39 #include <boost/geometry/index/detail/config_begin.hpp>
23 40
24 #include <boost/geometry/index/detail/assert.hpp> 41 #include <boost/geometry/index/detail/assert.hpp>
25 #include <boost/geometry/index/detail/exception.hpp> 42 #include <boost/geometry/index/detail/exception.hpp>
26 43
77 namespace boost { namespace geometry { namespace index { 94 namespace boost { namespace geometry { namespace index {
78 95
79 /*! 96 /*!
80 \brief The R-tree spatial index. 97 \brief The R-tree spatial index.
81 98
82 This is self-balancing spatial index capable to store various types of Values and balancing algorithms. 99 This is self-balancing spatial index capable to store various types of Values
100 and balancing algorithms.
83 101
84 \par Parameters 102 \par Parameters
85 The user must pass a type defining the Parameters which will 103 The user must pass a type defining the Parameters which will
86 be used in rtree creation process. This type is used e.g. to specify balancing algorithm 104 be used in rtree creation process. This type is used e.g. to specify balancing
87 with specific parameters like min and max number of elements in node. 105 algorithm with specific parameters like min and max number of elements in node.
88 106
89 \par 107 \par
90 Predefined algorithms with compile-time parameters are: 108 Predefined algorithms with compile-time parameters are:
91 \li <tt>boost::geometry::index::linear</tt>, 109 \li <tt>boost::geometry::index::linear</tt>,
92 \li <tt>boost::geometry::index::quadratic</tt>, 110 \li <tt>boost::geometry::index::quadratic</tt>,
97 \li \c boost::geometry::index::dynamic_linear, 115 \li \c boost::geometry::index::dynamic_linear,
98 \li \c boost::geometry::index::dynamic_quadratic, 116 \li \c boost::geometry::index::dynamic_quadratic,
99 \li \c boost::geometry::index::dynamic_rstar. 117 \li \c boost::geometry::index::dynamic_rstar.
100 118
101 \par IndexableGetter 119 \par IndexableGetter
102 The object of IndexableGetter type translates from Value to Indexable each time r-tree requires it. Which means that this 120 The object of IndexableGetter type translates from Value to Indexable each time
103 operation is done for each Value access. Therefore the IndexableGetter should return the Indexable by 121 r-tree requires it. This means that this operation is done for each Value
104 const reference instead of a value. Default one can translate all types adapted to Point 122 access. Therefore the IndexableGetter should return the Indexable by
105 or Box concepts (called Indexables). It also handles <tt>std::pair<Indexable, T></tt> and 123 a reference type. The Indexable should not be calculated since it could harm
106 <tt>boost::tuple<Indexable, ...></tt>. For example, if <tt>std::pair<Box, int></tt> is stored in the 124 the performance. The default IndexableGetter can translate all types adapted
107 container, the default IndexableGetter translates from <tt>std::pair<Box, int> const&</tt> to <tt>Box const&</tt>. 125 to Point, Box or Segment concepts (called Indexables). Furthermore, it can
126 handle <tt>std::pair<Indexable, T></tt>, <tt>boost::tuple<Indexable, ...></tt>
127 and <tt>std::tuple<Indexable, ...></tt> when possible. For example, for Value
128 of type <tt>std::pair<Box, int></tt>, the default IndexableGetter translates
129 from <tt>std::pair<Box, int> const&</tt> to <tt>Box const&</tt>.
108 130
109 \par EqualTo 131 \par EqualTo
110 The object of EqualTo type compares Values and returns <tt>true</tt> if they're equal. It's similar to <tt>std::equal_to<></tt>. 132 The object of EqualTo type compares Values and returns <tt>true</tt> if they
111 The default EqualTo returns the result of <tt>boost::geometry::equals()</tt> for types adapted to some Geometry concept 133 are equal. It's similar to <tt>std::equal_to<></tt>. The default EqualTo
112 defined in Boost.Geometry and the result of operator= for other types. Components of Pairs and Tuples are compared left-to-right. 134 returns the result of <tt>boost::geometry::equals()</tt> for types adapted to
135 some Geometry concept defined in Boost.Geometry and the result of
136 <tt>operator==</tt> for other types. Components of Pairs and Tuples are
137 compared left-to-right.
113 138
114 \tparam Value The type of objects stored in the container. 139 \tparam Value The type of objects stored in the container.
115 \tparam Parameters Compile-time parameters. 140 \tparam Parameters Compile-time parameters.
116 \tparam IndexableGetter The function object extracting Indexable from Value. 141 \tparam IndexableGetter The function object extracting Indexable from Value.
117 \tparam EqualTo The function object comparing objects of type Value. 142 \tparam EqualTo The function object comparing objects of type Value.
118 \tparam Allocator The allocator used to allocate/deallocate memory, construct/destroy nodes and Values. 143 \tparam Allocator The allocator used to allocate/deallocate memory,
144 construct/destroy nodes and Values.
119 */ 145 */
120 template < 146 template <
121 typename Value, 147 typename Value,
122 typename Parameters, 148 typename Parameters,
123 typename IndexableGetter = index::indexable<Value>, 149 typename IndexableGetter = index::indexable<Value>,
169 typedef typename detail::rtree::internal_node<value_type, typename options_type::parameters_type, box_type, allocators_type, node_tag>::type internal_node; 195 typedef typename detail::rtree::internal_node<value_type, typename options_type::parameters_type, box_type, allocators_type, node_tag>::type internal_node;
170 typedef typename detail::rtree::leaf<value_type, typename options_type::parameters_type, box_type, allocators_type, node_tag>::type leaf; 196 typedef typename detail::rtree::leaf<value_type, typename options_type::parameters_type, box_type, allocators_type, node_tag>::type leaf;
171 197
172 typedef typename allocators_type::node_pointer node_pointer; 198 typedef typename allocators_type::node_pointer node_pointer;
173 typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type; 199 typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type;
174 typedef detail::rtree::node_auto_ptr<value_type, options_type, translator_type, box_type, allocators_type> node_auto_ptr; 200 typedef detail::rtree::subtree_destroyer<value_type, options_type, translator_type, box_type, allocators_type> subtree_destroyer;
175 201
176 friend class detail::rtree::utilities::view<rtree>; 202 friend class detail::rtree::utilities::view<rtree>;
177 #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL 203 #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
178 friend class detail::rtree::private_view<rtree>; 204 friend class detail::rtree::private_view<rtree>;
179 friend class detail::rtree::const_private_view<rtree>; 205 friend class detail::rtree::const_private_view<rtree>;
571 for ( ; first != last ; ++first ) 597 for ( ; first != last ; ++first )
572 this->raw_insert(*first); 598 this->raw_insert(*first);
573 } 599 }
574 600
575 /*! 601 /*!
576 \brief Insert a range of values to the index. 602 \brief Insert a value created using convertible object or a range of values to the index.
577 603
578 \param rng The range of values. 604 \param conv_or_rng An object of type convertible to value_type or a range of values.
579 605
580 \par Throws 606 \par Throws
581 \li If Value copy constructor or copy assignment throws. 607 \li If Value copy constructor or copy assignment throws.
582 \li If allocation throws or returns invalid value. 608 \li If allocation throws or returns invalid value.
583 609
585 This operation only guarantees that there will be no memory leaks. 611 This operation only guarantees that there will be no memory leaks.
586 After an exception is thrown the R-tree may be left in an inconsistent state, 612 After an exception is thrown the R-tree may be left in an inconsistent state,
587 elements must not be inserted or removed. Other operations are allowed however 613 elements must not be inserted or removed. Other operations are allowed however
588 some of them may return invalid data. 614 some of them may return invalid data.
589 */ 615 */
590 template <typename Range> 616 template <typename ConvertibleOrRange>
591 inline void insert(Range const& rng) 617 inline void insert(ConvertibleOrRange const& conv_or_rng)
592 { 618 {
593 BOOST_MPL_ASSERT_MSG((detail::is_range<Range>::value), PASSED_OBJECT_IS_NOT_A_RANGE, (Range)); 619 typedef boost::mpl::bool_
594 620 <
595 if ( !m_members.root ) 621 boost::is_convertible<ConvertibleOrRange, value_type>::value
596 this->raw_create(); 622 > is_conv_t;
597 623
598 typedef typename boost::range_const_iterator<Range>::type It; 624 this->insert_dispatch(conv_or_rng, is_conv_t());
599 for ( It it = boost::const_begin(rng); it != boost::const_end(rng) ; ++it )
600 this->raw_insert(*it);
601 } 625 }
602 626
603 /*! 627 /*!
604 \brief Remove a value from the container. 628 \brief Remove a value from the container.
605 629
656 result += this->raw_remove(*first); 680 result += this->raw_remove(*first);
657 return result; 681 return result;
658 } 682 }
659 683
660 /*! 684 /*!
661 \brief Remove a range of values from the container. 685 \brief Remove value corresponding to an object convertible to it or a range of values from the container.
662 686
663 In contrast to the \c std::set or <tt>std::map erase()</tt> method 687 In contrast to the \c std::set or <tt>std::map erase()</tt> method
664 it removes values equal to these passed as a range. Furthermore, this method removes only 688 it removes values equal to these passed as a range. Furthermore, this method removes only
665 one value for each one passed in the range, not all equal values. 689 one value for each one passed in the range, not all equal values.
666 690
667 \param rng The range of values. 691 \param conv_or_rng The object of type convertible to value_type or a range of values.
668 692
669 \return The number of removed values. 693 \return The number of removed values.
670 694
671 \par Throws 695 \par Throws
672 \li If Value copy constructor or copy assignment throws. 696 \li If Value copy constructor or copy assignment throws.
676 This operation only guarantees that there will be no memory leaks. 700 This operation only guarantees that there will be no memory leaks.
677 After an exception is thrown the R-tree may be left in an inconsistent state, 701 After an exception is thrown the R-tree may be left in an inconsistent state,
678 elements must not be inserted or removed. Other operations are allowed however 702 elements must not be inserted or removed. Other operations are allowed however
679 some of them may return invalid data. 703 some of them may return invalid data.
680 */ 704 */
681 template <typename Range> 705 template <typename ConvertibleOrRange>
682 inline size_type remove(Range const& rng) 706 inline size_type remove(ConvertibleOrRange const& conv_or_rng)
683 { 707 {
684 BOOST_MPL_ASSERT_MSG((detail::is_range<Range>::value), PASSED_OBJECT_IS_NOT_A_RANGE, (Range)); 708 typedef boost::mpl::bool_
685 709 <
686 size_type result = 0; 710 boost::is_convertible<ConvertibleOrRange, value_type>::value
687 typedef typename boost::range_const_iterator<Range>::type It; 711 > is_conv_t;
688 for ( It it = boost::const_begin(rng); it != boost::const_end(rng) ; ++it ) 712
689 result += this->raw_remove(*it); 713 return this->remove_dispatch(conv_or_rng, is_conv_t());
690 return result;
691 } 714 }
692 715
693 /*! 716 /*!
694 \brief Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box. 717 \brief Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box.
695 718
1072 Nothing. 1095 Nothing.
1073 */ 1096 */
1074 template <typename ValueOrIndexable> 1097 template <typename ValueOrIndexable>
1075 size_type count(ValueOrIndexable const& vori) const 1098 size_type count(ValueOrIndexable const& vori) const
1076 { 1099 {
1077 if ( !m_members.root ) 1100 // the input should be convertible to Value or Indexable type
1078 return 0; 1101
1079 1102 enum { as_val = 0, as_ind, dont_know };
1080 detail::rtree::visitors::count<ValueOrIndexable, value_type, options_type, translator_type, box_type, allocators_type> 1103 typedef boost::mpl::int_
1081 count_v(vori, m_members.translator()); 1104 <
1082 1105 boost::is_same<ValueOrIndexable, value_type>::value ?
1083 detail::rtree::apply_visitor(count_v, *m_members.root); 1106 as_val :
1084 1107 boost::is_same<ValueOrIndexable, indexable_type>::value ?
1085 return count_v.found_count; 1108 as_ind :
1109 boost::is_convertible<ValueOrIndexable, indexable_type>::value ?
1110 as_ind :
1111 boost::is_convertible<ValueOrIndexable, value_type>::value ?
1112 as_val :
1113 dont_know
1114 > variant;
1115
1116 BOOST_MPL_ASSERT_MSG((variant::value != dont_know),
1117 PASSED_OBJECT_NOT_CONVERTIBLE_TO_VALUE_NOR_INDEXABLE_TYPE,
1118 (ValueOrIndexable));
1119
1120 typedef typename boost::mpl::if_c
1121 <
1122 variant::value == as_val,
1123 value_type,
1124 indexable_type
1125 >::type value_or_indexable;
1126
1127 // NOTE: If an object of convertible but not the same type is passed
1128 // into the function, here a temporary will be created.
1129 return this->template raw_count<value_or_indexable>(vori);
1086 } 1130 }
1087 1131
1088 /*! 1132 /*!
1089 \brief Returns parameters. 1133 \brief Returns parameters.
1090 1134
1198 basic 1242 basic
1199 */ 1243 */
1200 inline void raw_insert(value_type const& value) 1244 inline void raw_insert(value_type const& value)
1201 { 1245 {
1202 BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist"); 1246 BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist");
1247 // CONSIDER: alternative - ignore invalid indexable or throw an exception
1203 BOOST_GEOMETRY_INDEX_ASSERT(detail::is_valid(m_members.translator()(value)), "Indexable is invalid"); 1248 BOOST_GEOMETRY_INDEX_ASSERT(detail::is_valid(m_members.translator()(value)), "Indexable is invalid");
1204 1249
1205 detail::rtree::visitors::insert< 1250 detail::rtree::visitors::insert<
1206 value_type, 1251 value_type,
1207 value_type, options_type, translator_type, box_type, allocators_type, 1252 value_type, options_type, translator_type, box_type, allocators_type,
1315 dst.m_members.indexable_getter() = src.m_members.indexable_getter(); 1360 dst.m_members.indexable_getter() = src.m_members.indexable_getter();
1316 dst.m_members.equal_to() = src.m_members.equal_to(); 1361 dst.m_members.equal_to() = src.m_members.equal_to();
1317 dst.m_members.parameters() = src.m_members.parameters(); 1362 dst.m_members.parameters() = src.m_members.parameters();
1318 } 1363 }
1319 1364
1320 // TODO use node_auto_ptr 1365 // TODO use subtree_destroyer
1321 if ( dst.m_members.root ) 1366 if ( dst.m_members.root )
1322 { 1367 {
1323 detail::rtree::visitors::destroy<value_type, options_type, translator_type, box_type, allocators_type> 1368 detail::rtree::visitors::destroy<value_type, options_type, translator_type, box_type, allocators_type>
1324 del_v(dst.m_members.root, dst.m_members.allocators()); 1369 del_v(dst.m_members.root, dst.m_members.allocators());
1325 detail::rtree::apply_visitor(del_v, *dst.m_members.root); 1370 detail::rtree::apply_visitor(del_v, *dst.m_members.root);
1327 } 1372 }
1328 1373
1329 dst.m_members.root = copy_v.result; 1374 dst.m_members.root = copy_v.result;
1330 dst.m_members.values_count = src.m_members.values_count; 1375 dst.m_members.values_count = src.m_members.values_count;
1331 dst.m_members.leafs_level = src.m_members.leafs_level; 1376 dst.m_members.leafs_level = src.m_members.leafs_level;
1377 }
1378
1379 /*!
1380 \brief Insert a value corresponding to convertible object into the index.
1381
1382 \param val_conv The object convertible to value.
1383
1384 \par Exception-safety
1385 basic
1386 */
1387 template <typename ValueConvertible>
1388 inline void insert_dispatch(ValueConvertible const& val_conv,
1389 boost::mpl::bool_<true> const& /*is_convertible*/)
1390 {
1391 if ( !m_members.root )
1392 this->raw_create();
1393
1394 this->raw_insert(val_conv);
1395 }
1396
1397 /*!
1398 \brief Insert a range of values into the index.
1399
1400 \param rng The range of values.
1401
1402 \par Exception-safety
1403 basic
1404 */
1405 template <typename Range>
1406 inline void insert_dispatch(Range const& rng,
1407 boost::mpl::bool_<false> const& /*is_convertible*/)
1408 {
1409 BOOST_MPL_ASSERT_MSG((detail::is_range<Range>::value),
1410 PASSED_OBJECT_IS_NOT_CONVERTIBLE_TO_VALUE_NOR_A_RANGE,
1411 (Range));
1412
1413 if ( !m_members.root )
1414 this->raw_create();
1415
1416 typedef typename boost::range_const_iterator<Range>::type It;
1417 for ( It it = boost::const_begin(rng); it != boost::const_end(rng) ; ++it )
1418 this->raw_insert(*it);
1419 }
1420
1421 /*!
1422 \brief Remove a value corresponding to convertible object from the index.
1423
1424 \param val_conv The object convertible to value.
1425
1426 \par Exception-safety
1427 basic
1428 */
1429 template <typename ValueConvertible>
1430 inline size_type remove_dispatch(ValueConvertible const& val_conv,
1431 boost::mpl::bool_<true> const& /*is_convertible*/)
1432 {
1433 return this->raw_remove(val_conv);
1434 }
1435
1436 /*!
1437 \brief Remove a range of values from the index.
1438
1439 \param rng The range of values which will be removed from the container.
1440
1441 \par Exception-safety
1442 basic
1443 */
1444 template <typename Range>
1445 inline size_type remove_dispatch(Range const& rng,
1446 boost::mpl::bool_<false> const& /*is_convertible*/)
1447 {
1448 BOOST_MPL_ASSERT_MSG((detail::is_range<Range>::value),
1449 PASSED_OBJECT_IS_NOT_CONVERTIBLE_TO_VALUE_NOR_A_RANGE,
1450 (Range));
1451
1452 size_type result = 0;
1453 typedef typename boost::range_const_iterator<Range>::type It;
1454 for ( It it = boost::const_begin(rng); it != boost::const_end(rng) ; ++it )
1455 result += this->raw_remove(*it);
1456 return result;
1332 } 1457 }
1333 1458
1334 /*! 1459 /*!
1335 \brief Return values meeting predicates. 1460 \brief Return values meeting predicates.
1336 1461
1370 > distance_v(m_members.parameters(), m_members.translator(), predicates, out_it); 1495 > distance_v(m_members.parameters(), m_members.translator(), predicates, out_it);
1371 1496
1372 detail::rtree::apply_visitor(distance_v, *m_members.root); 1497 detail::rtree::apply_visitor(distance_v, *m_members.root);
1373 1498
1374 return distance_v.finish(); 1499 return distance_v.finish();
1500 }
1501
1502 /*!
1503 \brief Count elements corresponding to value or indexable.
1504
1505 \par Exception-safety
1506 strong
1507 */
1508 template <typename ValueOrIndexable>
1509 size_type raw_count(ValueOrIndexable const& vori) const
1510 {
1511 if ( !m_members.root )
1512 return 0;
1513
1514 detail::rtree::visitors::count
1515 <
1516 ValueOrIndexable,
1517 value_type,
1518 options_type,
1519 translator_type,
1520 box_type,
1521 allocators_type
1522 > count_v(vori, m_members.translator());
1523
1524 detail::rtree::apply_visitor(count_v, *m_members.root);
1525
1526 return count_v.found_count;
1375 } 1527 }
1376 1528
1377 struct members_holder 1529 struct members_holder
1378 : public translator_type 1530 : public translator_type
1379 , public Parameters 1531 , public Parameters
1437 1589
1438 \param tree The spatial index. 1590 \param tree The spatial index.
1439 \param v The value which will be stored in the index. 1591 \param v The value which will be stored in the index.
1440 */ 1592 */
1441 template <typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator> 1593 template <typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator>
1442 inline void insert(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree, Value const& v) 1594 inline void insert(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree,
1595 Value const& v)
1443 { 1596 {
1444 tree.insert(v); 1597 tree.insert(v);
1445 } 1598 }
1446 1599
1447 /*! 1600 /*!
1453 1606
1454 \param tree The spatial index. 1607 \param tree The spatial index.
1455 \param first The beginning of the range of values. 1608 \param first The beginning of the range of values.
1456 \param last The end of the range of values. 1609 \param last The end of the range of values.
1457 */ 1610 */
1458 template<typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator, typename Iterator> 1611 template<typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator,
1459 inline void insert(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree, Iterator first, Iterator last) 1612 typename Iterator>
1613 inline void insert(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree,
1614 Iterator first, Iterator last)
1460 { 1615 {
1461 tree.insert(first, last); 1616 tree.insert(first, last);
1462 } 1617 }
1463 1618
1464 /*! 1619 /*!
1465 \brief Insert a range of values to the index. 1620 \brief Insert a value created using convertible object or a range of values to the index.
1466 1621
1467 It calls <tt>rtree::insert(Range const&)</tt>. 1622 It calls <tt>rtree::insert(ConvertibleOrRange const&)</tt>.
1468 1623
1469 \ingroup rtree_functions 1624 \ingroup rtree_functions
1470 1625
1471 \param tree The spatial index. 1626 \param tree The spatial index.
1472 \param rng The range of values. 1627 \param conv_or_rng The object of type convertible to value_type or a range of values.
1473 */ 1628 */
1474 template<typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator, typename Range> 1629 template<typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator,
1475 inline void insert(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree, Range const& rng) 1630 typename ConvertibleOrRange>
1631 inline void insert(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree,
1632 ConvertibleOrRange const& conv_or_rng)
1476 { 1633 {
1477 tree.insert(rng); 1634 tree.insert(conv_or_rng);
1478 } 1635 }
1479 1636
1480 /*! 1637 /*!
1481 \brief Remove a value from the container. 1638 \brief Remove a value from the container.
1482 1639
1492 1649
1493 \return 1 if value was removed, 0 otherwise. 1650 \return 1 if value was removed, 0 otherwise.
1494 */ 1651 */
1495 template <typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator> 1652 template <typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator>
1496 inline typename rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type 1653 inline typename rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type
1497 remove(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree, Value const& v) 1654 remove(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree,
1655 Value const& v)
1498 { 1656 {
1499 return tree.remove(v); 1657 return tree.remove(v);
1500 } 1658 }
1501 1659
1502 /*! 1660 /*!
1515 \param first The beginning of the range of values. 1673 \param first The beginning of the range of values.
1516 \param last The end of the range of values. 1674 \param last The end of the range of values.
1517 1675
1518 \return The number of removed values. 1676 \return The number of removed values.
1519 */ 1677 */
1520 template<typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator, typename Iterator> 1678 template<typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator,
1679 typename Iterator>
1521 inline typename rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type 1680 inline typename rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type
1522 remove(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree, Iterator first, Iterator last) 1681 remove(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree,
1682 Iterator first, Iterator last)
1523 { 1683 {
1524 return tree.remove(first, last); 1684 return tree.remove(first, last);
1525 } 1685 }
1526 1686
1527 /*! 1687 /*!
1528 \brief Remove a range of values from the container. 1688 \brief Remove a value corresponding to an object convertible to it or a range of values from the container.
1529 1689
1530 Remove a range of values from the container. In contrast to the \c std::set or <tt>std::map erase()</tt> method 1690 Remove a value corresponding to an object convertible to it or a range of values from the container.
1691 In contrast to the \c std::set or <tt>std::map erase()</tt> method
1531 it removes values equal to these passed as a range. Furthermore this method removes only 1692 it removes values equal to these passed as a range. Furthermore this method removes only
1532 one value for each one passed in the range, not all equal values. 1693 one value for each one passed in the range, not all equal values.
1533 1694
1534 It calls <tt>rtree::remove(Range const&)</tt>. 1695 It calls <tt>rtree::remove(ConvertibleOrRange const&)</tt>.
1535 1696
1536 \ingroup rtree_functions 1697 \ingroup rtree_functions
1537 1698
1538 \param tree The spatial index. 1699 \param tree The spatial index.
1539 \param rng The range of values. 1700 \param conv_or_rng The object of type convertible to value_type or the range of values.
1540 1701
1541 \return The number of removed values. 1702 \return The number of removed values.
1542 */ 1703 */
1543 template<typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator, typename Range> 1704 template<typename Value, typename Parameters, typename IndexableGetter, typename EqualTo, typename Allocator,
1705 typename ConvertibleOrRange>
1544 inline typename rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type 1706 inline typename rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator>::size_type
1545 remove(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree, Range const& rng) 1707 remove(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> & tree,
1708 ConvertibleOrRange const& conv_or_rng)
1546 { 1709 {
1547 return tree.remove(rng); 1710 return tree.remove(conv_or_rng);
1548 } 1711 }
1549 1712
1550 /*! 1713 /*!
1551 \brief Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box. 1714 \brief Finds values meeting passed predicates e.g. nearest to some Point and/or intersecting some Box.
1552 1715
1779 return l.swap(r); 1942 return l.swap(r);
1780 } 1943 }
1781 1944
1782 }}} // namespace boost::geometry::index 1945 }}} // namespace boost::geometry::index
1783 1946
1947 // TODO: don't include the implementation at the end of the file
1948 #include <boost/geometry/algorithms/detail/comparable_distance/implementation.hpp>
1949
1784 #include <boost/geometry/index/detail/config_end.hpp> 1950 #include <boost/geometry/index/detail/config_end.hpp>
1785 1951
1786 #endif // BOOST_GEOMETRY_INDEX_RTREE_HPP 1952 #endif // BOOST_GEOMETRY_INDEX_RTREE_HPP