update boost
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
//
|
||||
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// This file was modified by Oracle on 2019.
|
||||
// Modifications copyright (c) 2019 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -41,12 +45,18 @@ inline void pick_seeds(Elements const& elements,
|
||||
typedef typename rtree::element_indexable_type<element_type, Translator>::type indexable_type;
|
||||
typedef Box box_type;
|
||||
typedef typename index::detail::default_content_result<box_type>::type content_type;
|
||||
typedef index::detail::bounded_view<indexable_type, box_type> bounded_indexable_view;
|
||||
typedef typename index::detail::strategy_type<Parameters>::type strategy_type;
|
||||
typedef index::detail::bounded_view
|
||||
<
|
||||
indexable_type, box_type, strategy_type
|
||||
> bounded_indexable_view;
|
||||
|
||||
const size_t elements_count = parameters.get_max_elements() + 1;
|
||||
BOOST_GEOMETRY_INDEX_ASSERT(elements.size() == elements_count, "wrong number of elements");
|
||||
BOOST_GEOMETRY_INDEX_ASSERT(2 <= elements_count, "unexpected number of elements");
|
||||
|
||||
strategy_type const& strategy = index::detail::get_strategy(parameters);
|
||||
|
||||
content_type greatest_free_content = 0;
|
||||
seed1 = 0;
|
||||
seed2 = 1;
|
||||
@@ -59,15 +69,15 @@ inline void pick_seeds(Elements const& elements,
|
||||
indexable_type const& ind2 = rtree::element_indexable(elements[j], tr);
|
||||
|
||||
box_type enlarged_box;
|
||||
detail::bounds(ind1, enlarged_box);
|
||||
geometry::expand(enlarged_box, ind2);
|
||||
index::detail::bounds(ind1, enlarged_box, strategy);
|
||||
index::detail::expand(enlarged_box, ind2, strategy);
|
||||
|
||||
bounded_indexable_view bounded_ind1(ind1);
|
||||
bounded_indexable_view bounded_ind2(ind2);
|
||||
bounded_indexable_view bounded_ind1(ind1, strategy);
|
||||
bounded_indexable_view bounded_ind2(ind2, strategy);
|
||||
content_type free_content = ( index::detail::content(enlarged_box)
|
||||
- index::detail::content(bounded_ind1) )
|
||||
- index::detail::content(bounded_ind2);
|
||||
|
||||
|
||||
if ( greatest_free_content < free_content )
|
||||
{
|
||||
greatest_free_content = free_content;
|
||||
@@ -82,33 +92,36 @@ inline void pick_seeds(Elements const& elements,
|
||||
|
||||
} // namespace quadratic
|
||||
|
||||
template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
|
||||
struct redistribute_elements<Value, Options, Translator, Box, Allocators, quadratic_tag>
|
||||
template <typename MembersHolder>
|
||||
struct redistribute_elements<MembersHolder, quadratic_tag>
|
||||
{
|
||||
typedef typename Options::parameters_type parameters_type;
|
||||
typedef typename MembersHolder::box_type box_type;
|
||||
typedef typename MembersHolder::parameters_type parameters_type;
|
||||
typedef typename MembersHolder::translator_type translator_type;
|
||||
typedef typename MembersHolder::allocators_type allocators_type;
|
||||
|
||||
typedef typename rtree::node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type node;
|
||||
typedef typename rtree::internal_node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
|
||||
typedef typename rtree::leaf<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
|
||||
typedef typename MembersHolder::node node;
|
||||
typedef typename MembersHolder::internal_node internal_node;
|
||||
typedef typename MembersHolder::leaf leaf;
|
||||
|
||||
typedef typename index::detail::default_content_result<Box>::type content_type;
|
||||
typedef typename index::detail::default_content_result<box_type>::type content_type;
|
||||
|
||||
template <typename Node>
|
||||
static inline void apply(Node & n,
|
||||
Node & second_node,
|
||||
Box & box1,
|
||||
Box & box2,
|
||||
box_type & box1,
|
||||
box_type & box2,
|
||||
parameters_type const& parameters,
|
||||
Translator const& translator,
|
||||
Allocators & allocators)
|
||||
translator_type const& translator,
|
||||
allocators_type & allocators)
|
||||
{
|
||||
typedef typename rtree::elements_type<Node>::type elements_type;
|
||||
typedef typename elements_type::value_type element_type;
|
||||
typedef typename rtree::element_indexable_type<element_type, Translator>::type indexable_type;
|
||||
typedef typename rtree::element_indexable_type<element_type, translator_type>::type indexable_type;
|
||||
|
||||
elements_type & elements1 = rtree::elements(n);
|
||||
elements_type & elements2 = rtree::elements(second_node);
|
||||
|
||||
|
||||
BOOST_GEOMETRY_INDEX_ASSERT(elements1.size() == parameters.get_max_elements() + 1, "unexpected elements number");
|
||||
|
||||
// copy original elements - use in-memory storage (std::allocator)
|
||||
@@ -117,11 +130,11 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, quadra
|
||||
container_type;
|
||||
container_type elements_copy(elements1.begin(), elements1.end()); // MAY THROW, STRONG (alloc, copy)
|
||||
container_type elements_backup(elements1.begin(), elements1.end()); // MAY THROW, STRONG (alloc, copy)
|
||||
|
||||
|
||||
// calculate initial seeds
|
||||
size_t seed1 = 0;
|
||||
size_t seed2 = 0;
|
||||
quadratic::pick_seeds<Box>(elements_copy, parameters, translator, seed1, seed2);
|
||||
quadratic::pick_seeds<box_type>(elements_copy, parameters, translator, seed1, seed2);
|
||||
|
||||
// prepare nodes' elements containers
|
||||
elements1.clear();
|
||||
@@ -129,13 +142,18 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, quadra
|
||||
|
||||
BOOST_TRY
|
||||
{
|
||||
typename index::detail::strategy_type<parameters_type>::type const&
|
||||
strategy = index::detail::get_strategy(parameters);
|
||||
|
||||
// add seeds
|
||||
elements1.push_back(elements_copy[seed1]); // MAY THROW, STRONG (copy)
|
||||
elements2.push_back(elements_copy[seed2]); // MAY THROW, STRONG (alloc, copy)
|
||||
|
||||
// calculate boxes
|
||||
detail::bounds(rtree::element_indexable(elements_copy[seed1], translator), box1);
|
||||
detail::bounds(rtree::element_indexable(elements_copy[seed2], translator), box2);
|
||||
detail::bounds(rtree::element_indexable(elements_copy[seed1], translator),
|
||||
box1, strategy);
|
||||
detail::bounds(rtree::element_indexable(elements_copy[seed2], translator),
|
||||
box2, strategy);
|
||||
|
||||
// remove seeds
|
||||
if (seed1 < seed2)
|
||||
@@ -185,7 +203,8 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, quadra
|
||||
content_type content_increase1 = 0;
|
||||
content_type content_increase2 = 0;
|
||||
el_it = pick_next(elements_copy.rbegin(), elements_copy.rend(),
|
||||
box1, box2, content1, content2, translator,
|
||||
box1, box2, content1, content2,
|
||||
translator, strategy,
|
||||
content_increase1, content_increase2);
|
||||
|
||||
if ( content_increase1 < content_increase2 ||
|
||||
@@ -208,13 +227,13 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, quadra
|
||||
if ( insert_into_group1 )
|
||||
{
|
||||
elements1.push_back(elem); // MAY THROW, STRONG (copy)
|
||||
geometry::expand(box1, indexable);
|
||||
index::detail::expand(box1, indexable, strategy);
|
||||
content1 = index::detail::content(box1);
|
||||
}
|
||||
else
|
||||
{
|
||||
elements2.push_back(elem); // MAY THROW, STRONG (alloc, copy)
|
||||
geometry::expand(box2, indexable);
|
||||
index::detail::expand(box2, indexable, strategy);
|
||||
content2 = index::detail::content(box2);
|
||||
}
|
||||
|
||||
@@ -233,7 +252,7 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, quadra
|
||||
elements1.clear();
|
||||
elements2.clear();
|
||||
|
||||
rtree::destroy_elements<Value, Options, Translator, Box, Allocators>::apply(elements_backup, allocators);
|
||||
rtree::destroy_elements<MembersHolder>::apply(elements_backup, allocators);
|
||||
//elements_backup.clear();
|
||||
|
||||
BOOST_RETHROW // RETHROW, BASIC
|
||||
@@ -245,29 +264,30 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, quadra
|
||||
|
||||
template <typename It>
|
||||
static inline It pick_next(It first, It last,
|
||||
Box const& box1, Box const& box2,
|
||||
box_type const& box1, box_type const& box2,
|
||||
content_type const& content1, content_type const& content2,
|
||||
Translator const& translator,
|
||||
translator_type const& translator,
|
||||
typename index::detail::strategy_type<parameters_type>::type const& strategy,
|
||||
content_type & out_content_increase1, content_type & out_content_increase2)
|
||||
{
|
||||
typedef typename boost::iterator_value<It>::type element_type;
|
||||
typedef typename rtree::element_indexable_type<element_type, Translator>::type indexable_type;
|
||||
typedef typename rtree::element_indexable_type<element_type, translator_type>::type indexable_type;
|
||||
|
||||
content_type greatest_content_incrase_diff = 0;
|
||||
It out_it = first;
|
||||
out_content_increase1 = 0;
|
||||
out_content_increase2 = 0;
|
||||
|
||||
|
||||
// find element with greatest difference between increased group's boxes areas
|
||||
for ( It el_it = first ; el_it != last ; ++el_it )
|
||||
{
|
||||
indexable_type const& indexable = rtree::element_indexable(*el_it, translator);
|
||||
|
||||
// calculate enlarged boxes and areas
|
||||
Box enlarged_box1(box1);
|
||||
Box enlarged_box2(box2);
|
||||
geometry::expand(enlarged_box1, indexable);
|
||||
geometry::expand(enlarged_box2, indexable);
|
||||
box_type enlarged_box1(box1);
|
||||
box_type enlarged_box2(box2);
|
||||
index::detail::expand(enlarged_box1, indexable, strategy);
|
||||
index::detail::expand(enlarged_box2, indexable, strategy);
|
||||
content_type enlarged_content1 = index::detail::content(enlarged_box1);
|
||||
content_type enlarged_content2 = index::detail::content(enlarged_box2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user