9
3

insert.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. // Boost.Geometry Index
  2. //
  3. // R-tree inserting visitor implementation
  4. //
  5. // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
  6. //
  7. // This file was modified by Oracle on 2019.
  8. // Modifications copyright (c) 2019 Oracle and/or its affiliates.
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. //
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_INSERT_HPP
  15. #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_INSERT_HPP
  16. #include <boost/type_traits/is_same.hpp>
  17. #include <boost/geometry/algorithms/detail/expand_by_epsilon.hpp>
  18. #include <boost/geometry/util/condition.hpp>
  19. #include <boost/geometry/index/detail/algorithms/bounds.hpp>
  20. #include <boost/geometry/index/detail/algorithms/content.hpp>
  21. namespace boost { namespace geometry { namespace index {
  22. namespace detail { namespace rtree {
  23. // Default choose_next_node
  24. template <typename Value, typename Options, typename Box, typename Allocators, typename ChooseNextNodeTag>
  25. class choose_next_node;
  26. template <typename Value, typename Options, typename Box, typename Allocators>
  27. class choose_next_node<Value, Options, Box, Allocators, choose_by_content_diff_tag>
  28. {
  29. public:
  30. typedef typename Options::parameters_type parameters_type;
  31. typedef typename rtree::node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type node;
  32. typedef typename rtree::internal_node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
  33. typedef typename rtree::leaf<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
  34. typedef typename rtree::elements_type<internal_node>::type children_type;
  35. typedef typename index::detail::default_content_result<Box>::type content_type;
  36. template <typename Indexable>
  37. static inline size_t apply(internal_node & n,
  38. Indexable const& indexable,
  39. parameters_type const& parameters,
  40. size_t /*node_relative_level*/)
  41. {
  42. children_type & children = rtree::elements(n);
  43. BOOST_GEOMETRY_INDEX_ASSERT(!children.empty(), "can't choose the next node if children are empty");
  44. size_t children_count = children.size();
  45. // choose index with smallest content change or smallest content
  46. size_t choosen_index = 0;
  47. content_type smallest_content_diff = (std::numeric_limits<content_type>::max)();
  48. content_type smallest_content = (std::numeric_limits<content_type>::max)();
  49. // caculate areas and areas of all nodes' boxes
  50. for ( size_t i = 0 ; i < children_count ; ++i )
  51. {
  52. typedef typename children_type::value_type child_type;
  53. child_type const& ch_i = children[i];
  54. // expanded child node's box
  55. Box box_exp(ch_i.first);
  56. index::detail::expand(box_exp, indexable,
  57. index::detail::get_strategy(parameters));
  58. // areas difference
  59. content_type content = index::detail::content(box_exp);
  60. content_type content_diff = content - index::detail::content(ch_i.first);
  61. // update the result
  62. if ( content_diff < smallest_content_diff ||
  63. ( content_diff == smallest_content_diff && content < smallest_content ) )
  64. {
  65. smallest_content_diff = content_diff;
  66. smallest_content = content;
  67. choosen_index = i;
  68. }
  69. }
  70. return choosen_index;
  71. }
  72. };
  73. // ----------------------------------------------------------------------- //
  74. // Not implemented here
  75. template <typename Value, typename Options, typename Translator, typename Box, typename Allocators, typename RedistributeTag>
  76. struct redistribute_elements
  77. {
  78. BOOST_MPL_ASSERT_MSG(
  79. (false),
  80. NOT_IMPLEMENTED_FOR_THIS_REDISTRIBUTE_TAG_TYPE,
  81. (redistribute_elements));
  82. };
  83. // ----------------------------------------------------------------------- //
  84. // Split algorithm
  85. template <typename Value, typename Options, typename Translator, typename Box, typename Allocators, typename SplitTag>
  86. class split
  87. {
  88. BOOST_MPL_ASSERT_MSG(
  89. (false),
  90. NOT_IMPLEMENTED_FOR_THIS_SPLIT_TAG_TYPE,
  91. (split));
  92. };
  93. // Default split algorithm
  94. template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
  95. class split<Value, Options, Translator, Box, Allocators, split_default_tag>
  96. {
  97. protected:
  98. typedef typename Options::parameters_type parameters_type;
  99. typedef typename rtree::node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type node;
  100. typedef typename rtree::internal_node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
  101. typedef typename rtree::leaf<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
  102. typedef rtree::subtree_destroyer<Value, Options, Translator, Box, Allocators> subtree_destroyer;
  103. public:
  104. typedef index::detail::varray<
  105. typename rtree::elements_type<internal_node>::type::value_type,
  106. 1
  107. > nodes_container_type;
  108. template <typename Node>
  109. static inline void apply(nodes_container_type & additional_nodes,
  110. Node & n,
  111. Box & n_box,
  112. parameters_type const& parameters,
  113. Translator const& translator,
  114. Allocators & allocators)
  115. {
  116. // TODO - consider creating nodes always with sufficient memory allocated
  117. // create additional node, use auto destroyer for automatic destruction on exception
  118. subtree_destroyer second_node(rtree::create_node<Allocators, Node>::apply(allocators), allocators); // MAY THROW, STRONG (N: alloc)
  119. // create reference to the newly created node
  120. Node & n2 = rtree::get<Node>(*second_node);
  121. // NOTE: thread-safety
  122. // After throwing an exception by redistribute_elements the original node may be not changed or
  123. // both nodes may be empty. In both cases the tree won't be valid r-tree.
  124. // The alternative is to create 2 (or more) additional nodes here and store backup info
  125. // in the original node, then, if exception was thrown, the node would always have more than max
  126. // elements.
  127. // The alternative is to use moving semantics in the implementations of redistribute_elements,
  128. // it will be possible to throw from boost::move() in the case of e.g. static size nodes.
  129. // redistribute elements
  130. Box box2;
  131. redistribute_elements<
  132. Value,
  133. Options,
  134. Translator,
  135. Box,
  136. Allocators,
  137. typename Options::redistribute_tag
  138. >::apply(n, n2, n_box, box2, parameters, translator, allocators); // MAY THROW (V, E: alloc, copy, copy)
  139. // check numbers of elements
  140. BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n).size() &&
  141. rtree::elements(n).size() <= parameters.get_max_elements(),
  142. "unexpected number of elements");
  143. BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n2).size() &&
  144. rtree::elements(n2).size() <= parameters.get_max_elements(),
  145. "unexpected number of elements");
  146. // return the list of newly created nodes (this algorithm returns one)
  147. additional_nodes.push_back(rtree::make_ptr_pair(box2, second_node.get())); // MAY THROW, STRONG (alloc, copy)
  148. // release the ptr
  149. second_node.release();
  150. }
  151. };
  152. // ----------------------------------------------------------------------- //
  153. namespace visitors { namespace detail {
  154. template <typename InternalNode, typename InternalNodePtr, typename SizeType>
  155. struct insert_traverse_data
  156. {
  157. typedef typename rtree::elements_type<InternalNode>::type elements_type;
  158. typedef typename elements_type::value_type element_type;
  159. typedef typename elements_type::size_type elements_size_type;
  160. typedef SizeType size_type;
  161. insert_traverse_data()
  162. : parent(0), current_child_index(0), current_level(0)
  163. {}
  164. void move_to_next_level(InternalNodePtr new_parent,
  165. elements_size_type new_child_index)
  166. {
  167. parent = new_parent;
  168. current_child_index = new_child_index;
  169. ++current_level;
  170. }
  171. bool current_is_root() const
  172. {
  173. return 0 == parent;
  174. }
  175. elements_type & parent_elements() const
  176. {
  177. BOOST_GEOMETRY_INDEX_ASSERT(parent, "null pointer");
  178. return rtree::elements(*parent);
  179. }
  180. element_type & current_element() const
  181. {
  182. BOOST_GEOMETRY_INDEX_ASSERT(parent, "null pointer");
  183. return rtree::elements(*parent)[current_child_index];
  184. }
  185. InternalNodePtr parent;
  186. elements_size_type current_child_index;
  187. size_type current_level;
  188. };
  189. // Default insert visitor
  190. template <typename Element, typename Value, typename Options, typename Translator, typename Box, typename Allocators>
  191. class insert
  192. : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, false>::type
  193. {
  194. protected:
  195. typedef typename Options::parameters_type parameters_type;
  196. typedef typename rtree::node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type node;
  197. typedef typename rtree::internal_node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
  198. typedef typename rtree::leaf<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
  199. typedef rtree::subtree_destroyer<Value, Options, Translator, Box, Allocators> subtree_destroyer;
  200. typedef typename Allocators::node_pointer node_pointer;
  201. typedef typename Allocators::size_type size_type;
  202. //typedef typename Allocators::internal_node_pointer internal_node_pointer;
  203. typedef internal_node * internal_node_pointer;
  204. inline insert(node_pointer & root,
  205. size_type & leafs_level,
  206. Element const& element,
  207. parameters_type const& parameters,
  208. Translator const& translator,
  209. Allocators & allocators,
  210. size_type relative_level = 0
  211. )
  212. : m_element(element)
  213. , m_parameters(parameters)
  214. , m_translator(translator)
  215. , m_relative_level(relative_level)
  216. , m_level(leafs_level - relative_level)
  217. , m_root_node(root)
  218. , m_leafs_level(leafs_level)
  219. , m_traverse_data()
  220. , m_allocators(allocators)
  221. {
  222. BOOST_GEOMETRY_INDEX_ASSERT(m_relative_level <= leafs_level, "unexpected level value");
  223. BOOST_GEOMETRY_INDEX_ASSERT(m_level <= m_leafs_level, "unexpected level value");
  224. BOOST_GEOMETRY_INDEX_ASSERT(0 != m_root_node, "there is no root node");
  225. // TODO
  226. // assert - check if Box is correct
  227. // When a value is inserted, during the tree traversal bounds of nodes
  228. // on a path from the root to a leaf must be expanded. So prepare
  229. // a bounding object at the beginning to not do it later for each node.
  230. // NOTE: This is actually only needed because conditionally the bounding
  231. // object may be expanded below. Otherwise the indexable could be
  232. // directly used instead
  233. index::detail::bounds(rtree::element_indexable(m_element, m_translator),
  234. m_element_bounds,
  235. index::detail::get_strategy(m_parameters));
  236. #ifdef BOOST_GEOMETRY_INDEX_EXPERIMENTAL_ENLARGE_BY_EPSILON
  237. // Enlarge it in case if it's not bounding geometry type.
  238. // It's because Points and Segments are compared WRT machine epsilon
  239. // This ensures that leafs bounds correspond to the stored elements
  240. if (BOOST_GEOMETRY_CONDITION((
  241. boost::is_same<Element, Value>::value
  242. && ! index::detail::is_bounding_geometry
  243. <
  244. typename indexable_type<Translator>::type
  245. >::value )) )
  246. {
  247. geometry::detail::expand_by_epsilon(m_element_bounds);
  248. }
  249. #endif
  250. }
  251. template <typename Visitor>
  252. inline void traverse(Visitor & visitor, internal_node & n)
  253. {
  254. // choose next node
  255. size_t choosen_node_index = rtree::choose_next_node<Value, Options, Box, Allocators, typename Options::choose_next_node_tag>::
  256. apply(n, rtree::element_indexable(m_element, m_translator), m_parameters, m_leafs_level - m_traverse_data.current_level);
  257. // expand the node to contain value
  258. index::detail::expand(
  259. rtree::elements(n)[choosen_node_index].first,
  260. m_element_bounds,
  261. index::detail::get_strategy(m_parameters));
  262. // next traversing step
  263. traverse_apply_visitor(visitor, n, choosen_node_index); // MAY THROW (V, E: alloc, copy, N:alloc)
  264. }
  265. // TODO: awulkiew - change post_traverse name to handle_overflow or overflow_treatment?
  266. template <typename Node>
  267. inline void post_traverse(Node &n)
  268. {
  269. BOOST_GEOMETRY_INDEX_ASSERT(m_traverse_data.current_is_root() ||
  270. &n == &rtree::get<Node>(*m_traverse_data.current_element().second),
  271. "if node isn't the root current_child_index should be valid");
  272. // handle overflow
  273. if ( m_parameters.get_max_elements() < rtree::elements(n).size() )
  274. {
  275. // NOTE: If the exception is thrown current node may contain more than MAX elements or be empty.
  276. // Furthermore it may be empty root - internal node.
  277. split(n); // MAY THROW (V, E: alloc, copy, N:alloc)
  278. }
  279. }
  280. template <typename Visitor>
  281. inline void traverse_apply_visitor(Visitor & visitor, internal_node &n, size_t choosen_node_index)
  282. {
  283. // save previous traverse inputs and set new ones
  284. insert_traverse_data<internal_node, internal_node_pointer, size_type>
  285. backup_traverse_data = m_traverse_data;
  286. // calculate new traverse inputs
  287. m_traverse_data.move_to_next_level(&n, choosen_node_index);
  288. // next traversing step
  289. rtree::apply_visitor(visitor, *rtree::elements(n)[choosen_node_index].second); // MAY THROW (V, E: alloc, copy, N:alloc)
  290. // restore previous traverse inputs
  291. m_traverse_data = backup_traverse_data;
  292. }
  293. // TODO: consider - split result returned as OutIter is faster than reference to the container. Why?
  294. template <typename Node>
  295. inline void split(Node & n) const
  296. {
  297. typedef rtree::split<Value, Options, Translator, Box, Allocators, typename Options::split_tag> split_algo;
  298. typename split_algo::nodes_container_type additional_nodes;
  299. Box n_box;
  300. split_algo::apply(additional_nodes, n, n_box, m_parameters, m_translator, m_allocators); // MAY THROW (V, E: alloc, copy, N:alloc)
  301. BOOST_GEOMETRY_INDEX_ASSERT(additional_nodes.size() == 1, "unexpected number of additional nodes");
  302. // TODO add all additional nodes
  303. // For kmeans algorithm:
  304. // elements number may be greater than node max elements count
  305. // split and reinsert must take node with some elements count
  306. // and container of additional elements (std::pair<Box, node*>s or Values)
  307. // and translator + allocators
  308. // where node_elements_count + additional_elements > node_max_elements_count
  309. // What with elements other than std::pair<Box, node*> ?
  310. // Implement template <node_tag> struct node_element_type or something like that
  311. // for exception safety
  312. subtree_destroyer additional_node_ptr(additional_nodes[0].second, m_allocators);
  313. #ifdef BOOST_GEOMETRY_INDEX_EXPERIMENTAL_ENLARGE_BY_EPSILON
  314. // Enlarge bounds of a leaf node.
  315. // It's because Points and Segments are compared WRT machine epsilon
  316. // This ensures that leafs' bounds correspond to the stored elements.
  317. if (BOOST_GEOMETRY_CONDITION((
  318. boost::is_same<Node, leaf>::value
  319. && ! index::detail::is_bounding_geometry
  320. <
  321. typename indexable_type<Translator>::type
  322. >::value )))
  323. {
  324. geometry::detail::expand_by_epsilon(n_box);
  325. geometry::detail::expand_by_epsilon(additional_nodes[0].first);
  326. }
  327. #endif
  328. // node is not the root - just add the new node
  329. if ( !m_traverse_data.current_is_root() )
  330. {
  331. // update old node's box
  332. m_traverse_data.current_element().first = n_box;
  333. // add new node to parent's children
  334. m_traverse_data.parent_elements().push_back(additional_nodes[0]); // MAY THROW, STRONG (V, E: alloc, copy)
  335. }
  336. // node is the root - add level
  337. else
  338. {
  339. BOOST_GEOMETRY_INDEX_ASSERT(&n == &rtree::get<Node>(*m_root_node), "node should be the root");
  340. // create new root and add nodes
  341. subtree_destroyer new_root(rtree::create_node<Allocators, internal_node>::apply(m_allocators), m_allocators); // MAY THROW, STRONG (N:alloc)
  342. BOOST_TRY
  343. {
  344. rtree::elements(rtree::get<internal_node>(*new_root)).push_back(rtree::make_ptr_pair(n_box, m_root_node)); // MAY THROW, STRONG (E:alloc, copy)
  345. rtree::elements(rtree::get<internal_node>(*new_root)).push_back(additional_nodes[0]); // MAY THROW, STRONG (E:alloc, copy)
  346. }
  347. BOOST_CATCH(...)
  348. {
  349. // clear new root to not delete in the ~subtree_destroyer() potentially stored old root node
  350. rtree::elements(rtree::get<internal_node>(*new_root)).clear();
  351. BOOST_RETHROW // RETHROW
  352. }
  353. BOOST_CATCH_END
  354. m_root_node = new_root.get();
  355. ++m_leafs_level;
  356. new_root.release();
  357. }
  358. additional_node_ptr.release();
  359. }
  360. // TODO: awulkiew - implement dispatchable split::apply to enable additional nodes creation
  361. Element const& m_element;
  362. Box m_element_bounds;
  363. parameters_type const& m_parameters;
  364. Translator const& m_translator;
  365. size_type const m_relative_level;
  366. size_type const m_level;
  367. node_pointer & m_root_node;
  368. size_type & m_leafs_level;
  369. // traversing input parameters
  370. insert_traverse_data<internal_node, internal_node_pointer, size_type> m_traverse_data;
  371. Allocators & m_allocators;
  372. };
  373. } // namespace detail
  374. // Insert visitor forward declaration
  375. template <typename Element, typename Value, typename Options, typename Translator, typename Box, typename Allocators, typename InsertTag>
  376. class insert;
  377. // Default insert visitor used for nodes elements
  378. // After passing the Element to insert visitor the Element is managed by the tree
  379. // I.e. one should not delete the node passed to the insert visitor after exception is thrown
  380. // because this visitor may delete it
  381. template <typename Element, typename Value, typename Options, typename Translator, typename Box, typename Allocators>
  382. class insert<Element, Value, Options, Translator, Box, Allocators, insert_default_tag>
  383. : public detail::insert<Element, Value, Options, Translator, Box, Allocators>
  384. {
  385. public:
  386. typedef detail::insert<Element, Value, Options, Translator, Box, Allocators> base;
  387. typedef typename base::node node;
  388. typedef typename base::internal_node internal_node;
  389. typedef typename base::leaf leaf;
  390. typedef typename Options::parameters_type parameters_type;
  391. typedef typename base::node_pointer node_pointer;
  392. typedef typename base::size_type size_type;
  393. inline insert(node_pointer & root,
  394. size_type & leafs_level,
  395. Element const& element,
  396. parameters_type const& parameters,
  397. Translator const& translator,
  398. Allocators & allocators,
  399. size_type relative_level = 0
  400. )
  401. : base(root, leafs_level, element, parameters, translator, allocators, relative_level)
  402. {}
  403. inline void operator()(internal_node & n)
  404. {
  405. BOOST_GEOMETRY_INDEX_ASSERT(base::m_traverse_data.current_level < base::m_leafs_level, "unexpected level");
  406. if ( base::m_traverse_data.current_level < base::m_level )
  407. {
  408. // next traversing step
  409. base::traverse(*this, n); // MAY THROW (E: alloc, copy, N: alloc)
  410. }
  411. else
  412. {
  413. BOOST_GEOMETRY_INDEX_ASSERT(base::m_level == base::m_traverse_data.current_level, "unexpected level");
  414. BOOST_TRY
  415. {
  416. // push new child node
  417. rtree::elements(n).push_back(base::m_element); // MAY THROW, STRONG (E: alloc, copy)
  418. }
  419. BOOST_CATCH(...)
  420. {
  421. // if the insert fails above, the element won't be stored in the tree
  422. rtree::visitors::destroy<Value, Options, Translator, Box, Allocators> del_v(base::m_element.second, base::m_allocators);
  423. rtree::apply_visitor(del_v, *base::m_element.second);
  424. BOOST_RETHROW // RETHROW
  425. }
  426. BOOST_CATCH_END
  427. }
  428. base::post_traverse(n); // MAY THROW (E: alloc, copy, N: alloc)
  429. }
  430. inline void operator()(leaf &)
  431. {
  432. BOOST_GEOMETRY_INDEX_ASSERT(false, "this visitor can't be used for a leaf");
  433. }
  434. };
  435. // Default insert visitor specialized for Values elements
  436. template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
  437. class insert<Value, Value, Options, Translator, Box, Allocators, insert_default_tag>
  438. : public detail::insert<Value, Value, Options, Translator, Box, Allocators>
  439. {
  440. public:
  441. typedef detail::insert<Value, Value, Options, Translator, Box, Allocators> base;
  442. typedef typename base::node node;
  443. typedef typename base::internal_node internal_node;
  444. typedef typename base::leaf leaf;
  445. typedef typename Options::parameters_type parameters_type;
  446. typedef typename base::node_pointer node_pointer;
  447. typedef typename base::size_type size_type;
  448. inline insert(node_pointer & root,
  449. size_type & leafs_level,
  450. Value const& value,
  451. parameters_type const& parameters,
  452. Translator const& translator,
  453. Allocators & allocators,
  454. size_type relative_level = 0
  455. )
  456. : base(root, leafs_level, value, parameters, translator, allocators, relative_level)
  457. {}
  458. inline void operator()(internal_node & n)
  459. {
  460. BOOST_GEOMETRY_INDEX_ASSERT(base::m_traverse_data.current_level < base::m_leafs_level, "unexpected level");
  461. BOOST_GEOMETRY_INDEX_ASSERT(base::m_traverse_data.current_level < base::m_level, "unexpected level");
  462. // next traversing step
  463. base::traverse(*this, n); // MAY THROW (V, E: alloc, copy, N: alloc)
  464. base::post_traverse(n); // MAY THROW (E: alloc, copy, N: alloc)
  465. }
  466. inline void operator()(leaf & n)
  467. {
  468. BOOST_GEOMETRY_INDEX_ASSERT(base::m_traverse_data.current_level == base::m_leafs_level, "unexpected level");
  469. BOOST_GEOMETRY_INDEX_ASSERT(base::m_level == base::m_traverse_data.current_level ||
  470. base::m_level == (std::numeric_limits<size_t>::max)(), "unexpected level");
  471. rtree::elements(n).push_back(base::m_element); // MAY THROW, STRONG (V: alloc, copy)
  472. base::post_traverse(n); // MAY THROW (V: alloc, copy, N: alloc)
  473. }
  474. };
  475. }}} // namespace detail::rtree::visitors
  476. }}} // namespace boost::geometry::index
  477. #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_INSERT_HPP