]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/geometry/index/detail/rtree/utilities/are_counts_ok.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / boost / geometry / index / detail / rtree / utilities / are_counts_ok.hpp
index 10a1bec6ad29c2b2bed2ca64cae58956e953ff65..5c8fc9ef268d0e3a4e63e872afbd2da0fef73d99 100644 (file)
@@ -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)
@@ -17,17 +21,21 @@ namespace boost { namespace geometry { namespace index { namespace detail { name
 
 namespace visitors {
 
-template <typename Value, typename Options, typename Box, typename Allocators>
+template <typename MembersHolder>
 class are_counts_ok
-    : public rtree::visitor<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag, true>::type
+    : public MembersHolder::visitor_const
 {
-    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;
-    typedef typename Options::parameters_type parameters_type;
+    typedef typename MembersHolder::parameters_type parameters_type;
+    
+    typedef typename MembersHolder::internal_node internal_node;
+    typedef typename MembersHolder::leaf leaf;
 
 public:
-    inline are_counts_ok(parameters_type const& parameters)
-        : result(true), m_current_level(0), m_parameters(parameters)
+    inline are_counts_ok(parameters_type const& parameters, bool check_min = true)
+        : result(true)
+        , m_current_level(0)
+        , m_parameters(parameters)
+        , m_check_min(check_min)
     {}
 
     inline void operator()(internal_node const& n)
@@ -36,7 +44,7 @@ public:
         elements_type const& elements = rtree::elements(n);
 
         // root internal node shouldn't contain 0 elements
-        if ( elements.empty()
+        if ( (elements.empty() && m_check_min)
           || !check_count(elements) )
         {
             result = false;
@@ -62,7 +70,7 @@ public:
         elements_type const& elements = rtree::elements(n);
 
         // empty leaf in non-root node
-        if ( ( m_current_level > 0 && elements.empty() )
+        if ( (m_current_level > 0 && elements.empty() && m_check_min)
           || !check_count(elements) )
         {
             result = false;
@@ -78,27 +86,25 @@ private:
         // root may contain count < min but should never contain count > max
         return elements.size() <= m_parameters.get_max_elements()
             && ( elements.size() >= m_parameters.get_min_elements()
-              || m_current_level == 0 );
+              || m_current_level == 0 || !m_check_min );
     }
 
     size_t m_current_level;
     parameters_type const& m_parameters;
+    bool m_check_min;
 };
 
 } // namespace visitors
 
 template <typename Rtree> inline
-bool are_counts_ok(Rtree const& tree)
+bool are_counts_ok(Rtree const& tree, bool check_min = true)
 {
     typedef utilities::view<Rtree> RTV;
     RTV rtv(tree);
 
     visitors::are_counts_ok<
-        typename RTV::value_type,
-        typename RTV::options_type,
-        typename RTV::box_type,
-        typename RTV::allocators_type
-    > v(tree.parameters());
+        typename RTV::members_holder
+    > v(tree.parameters(), check_min);
     
     rtv.apply_visitor(v);