Boost.Geometry.Index

- Main Page
- Modules
- Classes
- Files

- File List

/home/travis/build/boostorg/boost/boost/geometry/index/parameters.hpp

    00001 // Boost.Geometry Index
    00002 //
    00003 // R-tree algorithms parameters
    00004 //
    00005 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
    00006 //
    00007 // Use, modification and distribution is subject to the Boost Software License,
    00008 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    00009 // http://www.boost.org/LICENSE_1_0.txt)
    00010
    00011 #ifndef BOOST_GEOMETRY_INDEX_PARAMETERS_HPP
    00012 #define BOOST_GEOMETRY_INDEX_PARAMETERS_HPP
    00013
    00014 #include <limits>
    00015
    00016 namespace boost { namespace geometry { namespace index {
    00017
    00018 namespace detail {
    00019
    00020 template <size_t MaxElements>
    00021 struct default_min_elements_s
    00022 {
    00023     static const size_t raw_value = (MaxElements * 3) / 10;
    00024     static const size_t value = 1 <= raw_value ? raw_value : 1;
    00025 };
    00026
    00027 inline size_t default_min_elements_d()
    00028 {
    00029     return (std::numeric_limits<size_t>::max)();
    00030 }
    00031
    00032 inline size_t default_min_elements_d_calc(size_t max_elements, size_t min_elements)
    00033 {
    00034     if ( default_min_elements_d() == min_elements )
    00035     {
    00036         size_t raw_value = (max_elements * 3) / 10;
    00037         return 1 <= raw_value ? raw_value : 1;
    00038     }
    00039
    00040     return min_elements;
    00041 }
    00042
    00043 template <size_t MaxElements>
    00044 struct default_rstar_reinserted_elements_s
    00045 {
    00046     static const size_t value = (MaxElements * 3) / 10;
    00047 };
    00048
    00049 inline size_t default_rstar_reinserted_elements_d()
    00050 {
    00051     return (std::numeric_limits<size_t>::max)();
    00052 }
    00053
    00054 inline size_t default_rstar_reinserted_elements_d_calc(size_t max_elements, size_t reinserted_elements)
    00055 {
    00056     if ( default_rstar_reinserted_elements_d() == reinserted_elements )
    00057     {
    00058         return (max_elements * 3) / 10;
    00059     }
    00060
    00061     return reinserted_elements;
    00062 }
    00063
    00064 } // namespace detail
    00065
    00072 template <size_t MaxElements,
    00073           size_t MinElements = detail::default_min_elements_s<MaxElements>::value>
    00074 struct linear
    00075 {
    00076     BOOST_MPL_ASSERT_MSG((0 < MinElements && 2*MinElements <= MaxElements+1),
    00077                          INVALID_STATIC_MIN_MAX_PARAMETERS, (linear));
    00078
    00079     static const size_t max_elements = MaxElements;
    00080     static const size_t min_elements = MinElements;
    00081
    00082     static size_t get_max_elements() { return MaxElements; }
    00083     static size_t get_min_elements() { return MinElements; }
    00084 };
    00085
    00092 template <size_t MaxElements,
    00093           size_t MinElements = detail::default_min_elements_s<MaxElements>::value>
    00094 struct quadratic
    00095 {
    00096     BOOST_MPL_ASSERT_MSG((0 < MinElements && 2*MinElements <= MaxElements+1),
    00097                          INVALID_STATIC_MIN_MAX_PARAMETERS, (quadratic));
    00098
    00099     static const size_t max_elements = MaxElements;
    00100     static const size_t min_elements = MinElements;
    00101
    00102     static size_t get_max_elements() { return MaxElements; }
    00103     static size_t get_min_elements() { return MinElements; }
    00104 };
    00105
    00120 template <size_t MaxElements,
    00121           size_t MinElements = detail::default_min_elements_s<MaxElements>::value,
    00122           size_t ReinsertedElements = detail::default_rstar_reinserted_elements_s<MaxElements>::value,
    00123           size_t OverlapCostThreshold = 32>
    00124 struct rstar
    00125 {
    00126     BOOST_MPL_ASSERT_MSG((0 < MinElements && 2*MinElements <= MaxElements+1),
    00127                          INVALID_STATIC_MIN_MAX_PARAMETERS, (rstar));
    00128
    00129     static const size_t max_elements = MaxElements;
    00130     static const size_t min_elements = MinElements;
    00131     static const size_t reinserted_elements = ReinsertedElements;
    00132     static const size_t overlap_cost_threshold = OverlapCostThreshold;
    00133
    00134     static size_t get_max_elements() { return MaxElements; }
    00135     static size_t get_min_elements() { return MinElements; }
    00136     static size_t get_reinserted_elements() { return ReinsertedElements; }
    00137     static size_t get_overlap_cost_threshold() { return OverlapCostThreshold; }
    00138 };
    00139
    00140 //template <size_t MaxElements, size_t MinElements>
    00141 //struct kmeans
    00142 //{
    00143 //    static const size_t max_elements = MaxElements;
    00144 //    static const size_t min_elements = MinElements;
    00145 //};
    00146
    00150 class dynamic_linear
    00151 {
    00152 public:
    00159     dynamic_linear(size_t max_elements,
    00160                    size_t min_elements = detail::default_min_elements_d())
    00161         : m_max_elements(max_elements)
    00162         , m_min_elements(detail::default_min_elements_d_calc(max_elements, min_elements))
    00163     {
    00164         if (!(0 < m_min_elements && 2*m_min_elements <= m_max_elements+1))
    00165             detail::throw_invalid_argument("invalid min or/and max parameters of dynamic_linear");
    00166     }
    00167
    00168     size_t get_max_elements() const { return m_max_elements; }
    00169     size_t get_min_elements() const { return m_min_elements; }
    00170
    00171 private:
    00172     size_t m_max_elements;
    00173     size_t m_min_elements;
    00174 };
    00175
    00179 class dynamic_quadratic
    00180 {
    00181 public:
    00188     dynamic_quadratic(size_t max_elements,
    00189                       size_t min_elements = detail::default_min_elements_d())
    00190         : m_max_elements(max_elements)
    00191         , m_min_elements(detail::default_min_elements_d_calc(max_elements, min_elements))
    00192     {
    00193         if (!(0 < m_min_elements && 2*m_min_elements <= m_max_elements+1))
    00194             detail::throw_invalid_argument("invalid min or/and max parameters of dynamic_quadratic");
    00195     }
    00196
    00197     size_t get_max_elements() const { return m_max_elements; }
    00198     size_t get_min_elements() const { return m_min_elements; }
    00199
    00200 private:
    00201     size_t m_max_elements;
    00202     size_t m_min_elements;
    00203 };
    00204
    00208 class dynamic_rstar
    00209 {
    00210 public:
    00225     dynamic_rstar(size_t max_elements,
    00226                   size_t min_elements = detail::default_min_elements_d(),
    00227                   size_t reinserted_elements = detail::default_rstar_reinserted_elements_d(),
    00228                   size_t overlap_cost_threshold = 32)
    00229         : m_max_elements(max_elements)
    00230         , m_min_elements(detail::default_min_elements_d_calc(max_elements, min_elements))
    00231         , m_reinserted_elements(detail::default_rstar_reinserted_elements_d_calc(max_elements, reinserted_elements))
    00232         , m_overlap_cost_threshold(overlap_cost_threshold)
    00233     {
    00234         if (!(0 < m_min_elements && 2*m_min_elements <= m_max_elements+1))
    00235             detail::throw_invalid_argument("invalid min or/and max parameters of dynamic_rstar");
    00236     }
    00237
    00238     size_t get_max_elements() const { return m_max_elements; }
    00239     size_t get_min_elements() const { return m_min_elements; }
    00240     size_t get_reinserted_elements() const { return m_reinserted_elements; }
    00241     size_t get_overlap_cost_threshold() const { return m_overlap_cost_threshold; }
    00242
    00243 private:
    00244     size_t m_max_elements;
    00245     size_t m_min_elements;
    00246     size_t m_reinserted_elements;
    00247     size_t m_overlap_cost_threshold;
    00248 };
    00249
    00250 }}} // namespace boost::geometry::index
    00251
    00252 #endif // BOOST_GEOMETRY_INDEX_PARAMETERS_HPP

All Classes Functions Typedefs