node_elements.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // Boost.Geometry Index
  2. //
  3. // R-tree node elements access
  4. //
  5. // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
  6. //
  7. // This file was modified by Oracle on 2021.
  8. // Modifications copyright (c) 2021 Oracle and/or its affiliates.
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. //
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_ELEMENTS_HPP
  15. #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_ELEMENTS_HPP
  16. #include <boost/container/vector.hpp>
  17. #include <boost/geometry/algorithms/detail/expand_by_epsilon.hpp>
  18. #include <boost/geometry/index/detail/varray.hpp>
  19. #include <boost/geometry/index/detail/rtree/node/pairs.hpp>
  20. #include <boost/geometry/index/detail/translator.hpp>
  21. namespace boost { namespace geometry { namespace index {
  22. namespace detail { namespace rtree {
  23. // element's indexable type
  24. template <typename Element, typename Translator>
  25. struct element_indexable_type
  26. {
  27. typedef typename indexable_type<Translator>::type type;
  28. };
  29. template <typename First, typename Pointer, typename Translator>
  30. struct element_indexable_type<
  31. rtree::ptr_pair<First, Pointer>,
  32. Translator
  33. >
  34. {
  35. typedef First type;
  36. };
  37. // is leaf element
  38. template <typename Element>
  39. struct is_leaf_element
  40. {
  41. static const bool value = true;
  42. };
  43. template <typename First, typename Pointer>
  44. struct is_leaf_element< rtree::ptr_pair<First, Pointer> >
  45. {
  46. static const bool value = false;
  47. };
  48. // element's indexable getter
  49. template <typename Element, typename Translator>
  50. typename result_type<Translator>::type
  51. element_indexable(Element const& el, Translator const& tr)
  52. {
  53. return tr(el);
  54. }
  55. template <typename First, typename Pointer, typename Translator>
  56. First const&
  57. element_indexable(rtree::ptr_pair<First, Pointer> const& el, Translator const& /*tr*/)
  58. {
  59. return el.first;
  60. }
  61. // nodes elements
  62. template <typename Node>
  63. struct elements_type
  64. {
  65. typedef typename Node::elements_type type;
  66. };
  67. template <typename Node>
  68. inline typename elements_type<Node>::type &
  69. elements(Node & n)
  70. {
  71. return n.elements;
  72. }
  73. template <typename Node>
  74. inline typename elements_type<Node>::type const&
  75. elements(Node const& n)
  76. {
  77. return n.elements;
  78. }
  79. // elements derived type
  80. template <typename Elements, typename NewValue>
  81. struct container_from_elements_type
  82. {
  83. typedef boost::container::vector<NewValue> type;
  84. };
  85. template <typename OldValue, size_t N, typename NewValue>
  86. struct container_from_elements_type<detail::varray<OldValue, N>, NewValue>
  87. {
  88. typedef detail::varray<NewValue, N> type;
  89. };
  90. }} // namespace detail::rtree
  91. }}} // namespace boost::geometry::index
  92. #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_ELEMENTS_HPP