From 1234e21c53eb5a8a1f552132a4d3bfa5cd079b7e Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 28 Feb 2014 14:00:33 +0100 Subject: [PATCH] [geometry][index] rtree packing algorithm optimized, partial_sort replaced by nth_element, thanks to Lu Wang --- .../geometry/index/detail/rtree/pack_create.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/boost/geometry/index/detail/rtree/pack_create.hpp b/include/boost/geometry/index/detail/rtree/pack_create.hpp index 44292f18c..232f4654f 100644 --- a/include/boost/geometry/index/detail/rtree/pack_create.hpp +++ b/include/boost/geometry/index/detail/rtree/pack_create.hpp @@ -2,7 +2,7 @@ // // R-tree initial packing // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 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 @@ -55,14 +55,14 @@ struct point_entries_comparer }; template -struct partial_sort_and_half_boxes +struct nth_element_and_half_boxes { template static inline void apply(EIt first, EIt median, EIt last, Box const& box, Box & left, Box & right, std::size_t dim_index) { if ( I == dim_index ) { - std::partial_sort(first, median, last, point_entries_comparer()); + std::nth_element(first, median, last, point_entries_comparer()); geometry::convert(box, left); geometry::convert(box, right); @@ -74,12 +74,12 @@ struct partial_sort_and_half_boxes geometry::set(right, median); } else - partial_sort_and_half_boxes::apply(first, median, last, box, left, right, dim_index); + nth_element_and_half_boxes::apply(first, median, last, box, left, right, dim_index); } }; template -struct partial_sort_and_half_boxes +struct nth_element_and_half_boxes { template static inline void apply(EIt , EIt , EIt , Box const& , Box & , Box & , std::size_t ) {} @@ -278,7 +278,7 @@ private: std::size_t greatest_dim_index = 0; pack_utils::biggest_edge::apply(hint_box, greatest_length, greatest_dim_index); Box left, right; - pack_utils::partial_sort_and_half_boxes<0, dimension> + pack_utils::nth_element_and_half_boxes<0, dimension> ::apply(first, median, last, hint_box, left, right, greatest_dim_index); per_level_packets(first, median, left,