1 // Boost.Geometry Index
3 // R-tree destroying visitor implementation
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_DELETE_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_DELETE_HPP
14 namespace boost { namespace geometry { namespace index {
16 namespace detail { namespace rtree { namespace visitors {
18 template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
20 : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, false>::type
23 typedef typename rtree::node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type node;
24 typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
25 typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
27 typedef typename Allocators::node_pointer node_pointer;
29 inline destroy(node_pointer root_node, Allocators & allocators)
30 : m_current_node(root_node)
31 , m_allocators(allocators)
34 inline void operator()(internal_node & n)
36 BOOST_GEOMETRY_INDEX_ASSERT(&n == &rtree::get<internal_node>(*m_current_node), "invalid pointers");
38 node_pointer node_to_destroy = m_current_node;
40 typedef typename rtree::elements_type<internal_node>::type elements_type;
41 elements_type & elements = rtree::elements(n);
43 for (typename elements_type::iterator it = elements.begin();
44 it != elements.end(); ++it)
46 m_current_node = it->second;
47 rtree::apply_visitor(*this, *m_current_node);
51 rtree::destroy_node<Allocators, internal_node>::apply(m_allocators, node_to_destroy);
54 inline void operator()(leaf & l)
56 boost::ignore_unused(l);
57 BOOST_GEOMETRY_INDEX_ASSERT(&l == &rtree::get<leaf>(*m_current_node), "invalid pointers");
59 rtree::destroy_node<Allocators, leaf>::apply(m_allocators, m_current_node);
63 node_pointer m_current_node;
64 Allocators & m_allocators;
67 }}} // namespace detail::rtree::visitors
69 }}} // namespace boost::geometry::index
71 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_DELETE_HPP