mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 13:34:10 +00:00
[index] Tweaks related to is_leaf visitor/check.
Initialize the result in the ctor of the visitor. In remove() check if a node is a leaf using the level, apply the visitor only in the assert check.
This commit is contained in:
parent
f26fb3820d
commit
f07edd0b34
@ -2,7 +2,7 @@
|
||||
//
|
||||
// R-tree leaf node checking visitor implementation
|
||||
//
|
||||
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
|
||||
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -21,9 +21,13 @@ struct is_leaf : public rtree::visitor<Value, typename Options::parameters_type,
|
||||
typedef typename rtree::internal_node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
|
||||
typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
|
||||
|
||||
is_leaf()
|
||||
: result(false)
|
||||
{}
|
||||
|
||||
inline void operator()(internal_node const&)
|
||||
{
|
||||
result = false;
|
||||
// result = false;
|
||||
}
|
||||
|
||||
inline void operator()(leaf const&)
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// R-tree removing visitor implementation
|
||||
//
|
||||
// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -222,6 +222,13 @@ private:
|
||||
return elements.size() < m_parameters.get_min_elements();
|
||||
}
|
||||
|
||||
static inline bool is_leaf(node const& n)
|
||||
{
|
||||
visitors::is_leaf<Value, Options, Box, Allocators> ilv;
|
||||
rtree::apply_visitor(ilv, n);
|
||||
return ilv.result;
|
||||
}
|
||||
|
||||
void reinsert_removed_nodes_elements()
|
||||
{
|
||||
typename UnderflowNodes::reverse_iterator it = m_underflowed_nodes.rbegin();
|
||||
@ -232,9 +239,11 @@ private:
|
||||
// begin with levels closer to the root
|
||||
for ( ; it != m_underflowed_nodes.rend() ; ++it )
|
||||
{
|
||||
is_leaf<Value, Options, Box, Allocators> ilv;
|
||||
rtree::apply_visitor(ilv, *it->second);
|
||||
if ( ilv.result )
|
||||
// it->first is an index of a level of a node, not children
|
||||
// counted from the leafs level
|
||||
bool const node_is_leaf = it->first == 1;
|
||||
BOOST_GEOMETRY_INDEX_ASSERT(node_is_leaf == is_leaf(*it->second), "unexpected condition");
|
||||
if ( node_is_leaf )
|
||||
{
|
||||
reinsert_node_elements(rtree::get<leaf>(*it->second), it->first); // MAY THROW (V, E: alloc, copy, N: alloc)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user