summaryrefslogtreecommitdiff
path: root/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp')
-rw-r--r--boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp39
1 files changed, 26 insertions, 13 deletions
diff --git a/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp b/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp
index e07926ffed..2ac6eb27c9 100644
--- a/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp
+++ b/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp
@@ -2,7 +2,7 @@
//
// R-tree R*-tree next node choosing algorithm implementation
//
-// Copyright (c) 2011-2017 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2011-2019 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
@@ -65,6 +65,20 @@ public:
}
private:
+ struct child_contents
+ {
+ content_type content_diff;
+ content_type content;
+ size_t i;
+
+ void set(size_t i_, content_type const& content_, content_type const& content_diff_)
+ {
+ i = i_;
+ content = content_;
+ content_diff = content_diff_;
+ }
+ };
+
template <typename Indexable>
static inline size_t choose_by_minimum_overlap_cost(children_type const& children,
Indexable const& indexable,
@@ -77,10 +91,8 @@ private:
size_t choosen_index = 0;
// create container of children sorted by content enlargement needed to include the new value
- typedef boost::tuple<size_t, content_type, content_type> child_contents;
-
- typename rtree::container_from_elements_type<children_type, child_contents>::type children_contents;
- children_contents.resize(children_count);
+ typename rtree::container_from_elements_type<children_type, child_contents>::type
+ children_contents(children_count);
for ( size_t i = 0 ; i < children_count ; ++i )
{
@@ -94,7 +106,7 @@ private:
content_type content = index::detail::content(box_exp);
content_type content_diff = content - index::detail::content(ch_i.first);
- children_contents[i] = boost::make_tuple(i, content_diff, content);
+ children_contents[i].set(i, content, content_diff);
if ( content_diff < min_content_diff ||
(content_diff == min_content_diff && content < min_content) )
@@ -125,10 +137,10 @@ private:
return choosen_index;
}
- static inline bool content_diff_less(boost::tuple<size_t, content_type, content_type> const& p1, boost::tuple<size_t, content_type, content_type> const& p2)
+ static inline bool content_diff_less(child_contents const& p1, child_contents const& p2)
{
- return boost::get<1>(p1) < boost::get<1>(p2) ||
- (boost::get<1>(p1) == boost::get<1>(p2) && boost::get<2>(p1) < boost::get<2>(p2));
+ return p1.content_diff < p2.content_diff
+ || (p1.content_diff == p2.content_diff && (p1.content) < (p2.content));
}
template <typename Indexable, typename ChildrenContents>
@@ -148,8 +160,12 @@ private:
content_type smallest_content = (std::numeric_limits<content_type>::max)();
// for each child node
- for (size_t i = 0 ; i < first_n_children_count ; ++i )
+ for (size_t first_i = 0 ; first_i < first_n_children_count ; ++first_i)
{
+ size_t i = children_contents[first_i].i;
+ content_type const& content = children_contents[first_i].content;
+ content_type const& content_diff = children_contents[first_i].content_diff;
+
child_type const& ch_i = children[i];
Box box_exp(ch_i.first);
@@ -173,9 +189,6 @@ private:
}
}
- content_type content = boost::get<2>(children_contents[i]);
- content_type content_diff = boost::get<1>(children_contents[i]);
-
// update result
if ( overlap_diff < smallest_overlap_diff ||
( overlap_diff == smallest_overlap_diff && ( content_diff < smallest_content_diff ||