dynamic_visitor added and nodes tags changed.

[SVN r80779]
This commit is contained in:
Adam Wulkiewicz
2012-09-30 12:12:34 +00:00
parent d0ce652bb7
commit 136e2fc742
9 changed files with 306 additions and 200 deletions

View File

@@ -0,0 +1,85 @@
// Boost.Geometry Index
//
// R-tree node concept
//
// Copyright (c) 2011-2012 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
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_CONCEPT_HPP
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_CONCEPT_HPP
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(node));
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct internal_node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(internal_node));
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct leaf
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(leaf));
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, bool IsVisitableConst>
struct visitor
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(visitor));
};
template <typename Allocator, typename Value, typename Parameters, typename Box, typename Tag>
struct allocators
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(allocators));
};
template <typename Allocators, typename Node>
struct create_node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_NODE_TYPE,
(create_node));
};
template <typename Allocators, typename Node>
struct destroy_node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_NODE_TYPE,
(destroy_node));
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_CONCEPT_HPP

View File

@@ -0,0 +1,70 @@
// Boost.Geometry Index
//
// R-tree nodes dynamic visitor and nodes base type
//
// Copyright (c) 2011-2012 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
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_DYNAMIC_VISITOR_HPP
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_DYNAMIC_VISITOR_HPP
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
// visitor forward declaration
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, bool IsVisitableConst>
struct dynamic_visitor;
// node
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct dynamic_node
{
virtual ~dynamic_node() {}
virtual void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, Tag, false> &) = 0;
virtual void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, Tag, true> &) const = 0;
};
// nodes variants forward declarations
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct dynamic_internal_node;
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct dynamic_leaf;
// visitor
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct dynamic_visitor<Value, Parameters, Box, Allocators, Tag, true>
{
typedef dynamic_internal_node<Value, Parameters, Box, Allocators, Tag> internal_node;
typedef dynamic_leaf<Value, Parameters, Box, Allocators, Tag> leaf;
virtual ~dynamic_visitor() {}
virtual void operator()(internal_node const&) = 0;
virtual void operator()(leaf const&) = 0;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct dynamic_visitor<Value, Parameters, Box, Allocators, Tag, false>
{
typedef dynamic_internal_node<Value, Parameters, Box, Allocators, Tag> internal_node;
typedef dynamic_leaf<Value, Parameters, Box, Allocators, Tag> leaf;
virtual ~dynamic_visitor() {}
virtual void operator()(internal_node &) = 0;
virtual void operator()(leaf &) = 0;
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_DYNAMIC_VISITOR_HPP

View File

@@ -11,11 +11,13 @@
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_NODE_HPP
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_NODE_HPP
#include <boost/geometry/extensions/index/rtree/node/node_default.hpp>
#include <boost/geometry/extensions/index/rtree/node/node_default_variant.hpp>
#include <boost/geometry/extensions/index/rtree/node/concept.hpp>
#include <boost/geometry/extensions/index/rtree/node/node_default_static.hpp>
#include <boost/geometry/extensions/index/rtree/node/node_default_static_variant.hpp>
#include <boost/geometry/extensions/index/rtree/node/node_d_mem_dynamic.hpp>
#include <boost/geometry/extensions/index/rtree/node/node_s_mem_dynamic.hpp>
#include <boost/geometry/extensions/index/rtree/node/node_d_mem_static.hpp>
#include <boost/geometry/extensions/index/rtree/node/node_s_mem_static.hpp>
#include <boost/geometry/algorithms/expand.hpp>

View File

@@ -13,128 +13,92 @@
#include <vector>
#include <boost/geometry/extensions/index/rtree/node/dynamic_visitor.hpp>
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
// visitor forward declaration
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, bool IsVisitableConst>
struct visitor_poly;
// nodes types
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct node_poly
{
virtual ~node_poly() {}
virtual void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, Tag, false> &) = 0;
virtual void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, Tag, true> &) const = 0;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct internal_node_poly : public node_poly<Value, Parameters, Box, Allocators, Tag>
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct dynamic_internal_node<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag>
: public dynamic_node<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag>
{
typedef std::vector<
std::pair<Box, node_poly<Value, Parameters, Box, Allocators, Tag> *>,
std::pair<Box, dynamic_node<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag> *>,
typename Allocators::internal_node_elements_allocator_type
> elements_type;
inline internal_node_poly(typename Allocators::internal_node_elements_allocator_type & al)
inline dynamic_internal_node(typename Allocators::internal_node_elements_allocator_type & al)
: elements(al)
{}
void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, Tag, false> & v) { v(*this); }
void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, Tag, true> & v) const { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag, false> & v) { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag, true> & v) const { v(*this); }
elements_type elements;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct leaf_poly : public node_poly<Value, Parameters, Box, Allocators, Tag>
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct dynamic_leaf<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag>
: public dynamic_node<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag>
{
typedef std::vector<
Value,
typename Allocators::leaf_elements_allocator_type
> elements_type;
inline leaf_poly(typename Allocators::leaf_elements_allocator_type & al)
inline dynamic_leaf(typename Allocators::leaf_elements_allocator_type & al)
: elements(al)
{}
void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, Tag, false> & v) { v(*this); }
void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, Tag, true> & v) const { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag, false> & v) { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag, true> & v) const { v(*this); }
elements_type elements;
};
// nodes traits
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct node
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct node<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag>
{
typedef node_poly<Value, Parameters, Box, Allocators, Tag> type;
typedef dynamic_node<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct internal_node
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag>
{
typedef internal_node_poly<Value, Parameters, Box, Allocators, Tag> type;
typedef dynamic_internal_node<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct leaf
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag>
{
typedef leaf_poly<Value, Parameters, Box, Allocators, Tag> type;
typedef dynamic_leaf<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag> type;
};
// nodes conversion
template <typename Derived, typename Parameters, typename Value, typename Box, typename Allocators, typename Tag>
inline Derived & get(node_poly<Value, Parameters, Box, Allocators, Tag> & n)
inline Derived & get(dynamic_node<Value, Parameters, Box, Allocators, Tag> & n)
{
assert(dynamic_cast<Derived*>(&n));
return static_cast<Derived&>(n);
}
template <typename Derived, typename Parameters, typename Value, typename Box, typename Allocators, typename Tag>
inline Derived * get(node_poly<Value, Parameters, Box, Allocators, Tag> * n)
inline Derived * get(dynamic_node<Value, Parameters, Box, Allocators, Tag> * n)
{
assert(dynamic_cast<Derived*>(n));
return static_cast<Derived*>(n);
}
// visitor
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct visitor_poly<Value, Parameters, Box, Allocators, Tag, true>
{
typedef typename internal_node<Value, Parameters, Box, Allocators, Tag>::type internal_node;
typedef typename leaf<Value, Parameters, Box, Allocators, Tag>::type leaf;
virtual ~visitor_poly() {}
virtual void operator()(internal_node const&) = 0;
virtual void operator()(leaf const&) = 0;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct visitor_poly<Value, Parameters, Box, Allocators, Tag, false>
{
typedef typename internal_node<Value, Parameters, Box, Allocators, Tag>::type internal_node;
typedef typename leaf<Value, Parameters, Box, Allocators, Tag>::type leaf;
virtual ~visitor_poly() {}
virtual void operator()(internal_node &) = 0;
virtual void operator()(leaf &) = 0;
};
// visitor traits
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, bool IsVisitableConst>
struct visitor
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag, IsVisitableConst>
{
typedef visitor_poly<Value, Parameters, Box, Allocators, Tag, IsVisitableConst> type;
typedef dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_dynamic_tag, IsVisitableConst> type;
};
template <typename Visitor, typename Visitable>
@@ -153,7 +117,7 @@ struct element_indexable_type
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, typename Translator>
struct element_indexable_type<
std::pair<Box, node_poly<Value, Parameters, Box, Allocators, Tag> *>,
std::pair<Box, dynamic_node<Value, Parameters, Box, Allocators, Tag> *>,
Translator
>
{
@@ -172,7 +136,7 @@ element_indexable(Value const& el, Translator const& tr)
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, typename Translator>
inline Box const&
element_indexable(
std::pair< Box, node_poly<Value, Parameters, Box, Allocators, Tag> *> const& el,
std::pair< Box, dynamic_node<Value, Parameters, Box, Allocators, Tag> *> const& el,
Translator const&)
{
return el.first;
@@ -209,29 +173,29 @@ struct container_from_elements_type
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box, typename Tag>
struct allocators_poly
template <typename Allocator, typename Value, typename Parameters, typename Box>
struct allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>
{
typedef Allocator allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::template rebind<
typename internal_node<Value, Parameters, Box, allocators_poly, Tag>::type
typename internal_node<Value, Parameters, Box, allocators, node_d_mem_dynamic_tag>::type
>::other internal_node_allocator_type;
typedef typename allocator_type::template rebind<
typename leaf<Value, Parameters, Box, allocators_poly, Tag>::type
typename leaf<Value, Parameters, Box, allocators, node_d_mem_dynamic_tag>::type
>::other leaf_allocator_type;
typedef typename allocator_type::template rebind<
std::pair<Box, node_poly<Value, Parameters, Box, allocators_poly, Tag> *>
std::pair<Box, dynamic_node<Value, Parameters, Box, allocators, node_d_mem_dynamic_tag> *>
>::other internal_node_elements_allocator_type;
typedef typename allocator_type::template rebind<
Value
>::other leaf_elements_allocator_type;
inline explicit allocators_poly(Allocator alloc)
inline explicit allocators(Allocator alloc)
: allocator(alloc)
, internal_node_allocator(allocator)
, leaf_allocator(allocator)
@@ -246,14 +210,6 @@ struct allocators_poly
leaf_elements_allocator_type leaf_elements_allocator;
};
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box, typename Tag>
struct allocators
{
typedef allocators_poly<Allocator, Value, Parameters, Box, Tag> type;
};
// create_node_impl
template <typename Node>
@@ -297,26 +253,17 @@ struct destroy_node_poly
// create_node
template <typename Allocators, typename Node>
struct create_node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_NODE_TYPE,
(create_node));
};
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct create_node<
Allocators,
internal_node_poly<Value, Parameters, Box, Allocators, Tag>
dynamic_internal_node<Value, Parameters, Box, Allocators, Tag>
>
{
static inline typename node<Value, Parameters, Box, Allocators, Tag>::type *
apply(Allocators & allocators)
{
return create_node_poly<
internal_node_poly<Value, Parameters, Box, Allocators, Tag>
dynamic_internal_node<Value, Parameters, Box, Allocators, Tag>
>::template apply<
typename node<Value, Parameters, Box, Allocators, Tag>::type
>(allocators.internal_node_allocator, allocators.internal_node_elements_allocator);
@@ -326,14 +273,14 @@ struct create_node<
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct create_node<
Allocators,
leaf_poly<Value, Parameters, Box, Allocators, Tag>
dynamic_leaf<Value, Parameters, Box, Allocators, Tag>
>
{
static inline typename node<Value, Parameters, Box, Allocators, Tag>::type *
apply(Allocators & allocators)
{
return create_node_poly<
leaf_poly<Value, Parameters, Box, Allocators, Tag>
dynamic_leaf<Value, Parameters, Box, Allocators, Tag>
>::template apply<
typename node<Value, Parameters, Box, Allocators, Tag>::type
>(allocators.leaf_allocator, allocators.leaf_elements_allocator);
@@ -342,25 +289,16 @@ struct create_node<
// destroy_node
template <typename Allocators, typename Node>
struct destroy_node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_NODE_TYPE,
(destroy_node));
};
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct destroy_node<
Allocators,
internal_node_poly<Value, Parameters, Box, Allocators, Tag>
dynamic_internal_node<Value, Parameters, Box, Allocators, Tag>
>
{
static inline void apply(Allocators & allocators, typename node<Value, Parameters, Box, Allocators, Tag>::type * n)
{
destroy_node_poly<
internal_node_poly<Value, Parameters, Box, Allocators, Tag>
dynamic_internal_node<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.internal_node_allocator, n);
}
};
@@ -368,13 +306,13 @@ struct destroy_node<
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct destroy_node<
Allocators,
leaf_poly<Value, Parameters, Box, Allocators, Tag>
dynamic_leaf<Value, Parameters, Box, Allocators, Tag>
>
{
static inline void apply(Allocators & allocators, typename node<Value, Parameters, Box, Allocators, Tag>::type * n)
{
destroy_node_poly<
leaf_poly<Value, Parameters, Box, Allocators, Tag>
dynamic_leaf<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.leaf_allocator, n);
}
};

View File

@@ -11,6 +11,7 @@
#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_NODE_DEFAULT_STATIC_HPP
#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_NODE_NODE_DEFAULT_STATIC_HPP
#include <boost/geometry/extensions/index/rtree/node/dynamic_visitor.hpp>
#include <boost/geometry/extensions/index/pushable_array.hpp>
namespace boost { namespace geometry { namespace index {
@@ -18,41 +19,67 @@ namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node_poly<Value, Parameters, Box, Allocators, node_default_static_tag>
: public node_poly<Value, Parameters, Box, Allocators, node_default_static_tag>
struct dynamic_internal_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
: public dynamic_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
{
typedef index::pushable_array<
std::pair<
Box,
node_poly<Value, Parameters, Box, Allocators, node_default_static_tag> *
dynamic_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag> *
>,
Parameters::max_elements + 1
> elements_type;
template <typename Dummy>
inline internal_node_poly(Dummy) {}
inline dynamic_internal_node(Dummy) {}
void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, node_default_static_tag, false> & v) { v(*this); }
void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, node_default_static_tag, true> & v) const { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_static_tag, false> & v) { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_static_tag, true> & v) const { v(*this); }
elements_type elements;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf_poly<Value, Parameters, Box, Allocators, node_default_static_tag>
: public node_poly<Value, Parameters, Box, Allocators, node_default_static_tag>
struct dynamic_leaf<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
: public dynamic_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
{
typedef index::pushable_array<Value, Parameters::max_elements + 1> elements_type;
template <typename Dummy>
inline leaf_poly(Dummy) {}
inline dynamic_leaf(Dummy) {}
void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, node_default_static_tag, false> & v) { v(*this); }
void apply_visitor(visitor_poly<Value, Parameters, Box, Allocators, node_default_static_tag, true> & v) const { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_static_tag, false> & v) { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_static_tag, true> & v) const { v(*this); }
elements_type elements;
};
// nodes traits
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
{
typedef dynamic_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
{
typedef dynamic_internal_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
{
typedef dynamic_leaf<Value, Parameters, Box, Allocators, node_d_mem_static_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_d_mem_static_tag, IsVisitableConst>
{
typedef dynamic_visitor<Value, Parameters, Box, Allocators, node_d_mem_static_tag, IsVisitableConst> type;
};
// elements derived type
template <typename OldValue, size_t N, typename NewValue>
struct container_from_elements_type<index::pushable_array<OldValue, N>, NewValue>
@@ -60,23 +87,23 @@ struct container_from_elements_type<index::pushable_array<OldValue, N>, NewValue
typedef index::pushable_array<NewValue, N> type;
};
// allocators_poly
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box>
struct allocators_poly<Allocator, Value, Parameters, Box, node_default_static_tag>
struct allocators<Allocator, Value, Parameters, Box, node_d_mem_static_tag>
{
typedef Allocator allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::template rebind<
typename internal_node<Value, Parameters, Box, allocators_poly, node_default_static_tag>::type
typename internal_node<Value, Parameters, Box, allocators, node_d_mem_static_tag>::type
>::other internal_node_allocator_type;
typedef typename allocator_type::template rebind<
typename leaf<Value, Parameters, Box, allocators_poly, node_default_static_tag>::type
typename leaf<Value, Parameters, Box, allocators, node_d_mem_static_tag>::type
>::other leaf_allocator_type;
inline explicit allocators_poly(Allocator alloc)
inline explicit allocators(Allocator alloc)
: allocator(alloc)
, internal_node_allocator(allocator)
, leaf_allocator(allocator)
@@ -92,16 +119,16 @@ struct allocators_poly<Allocator, Value, Parameters, Box, node_default_static_ta
template <typename Allocators, typename Value, typename Parameters, typename Box>
struct create_node<
Allocators,
internal_node_poly<Value, Parameters, Box, Allocators, node_default_static_tag>
dynamic_internal_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
>
{
static inline typename node<Value, Parameters, Box, Allocators, node_default_static_tag>::type *
static inline typename node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>::type *
apply(Allocators & allocators)
{
return create_node_poly<
internal_node_poly<Value, Parameters, Box, Allocators, node_default_static_tag>
dynamic_internal_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
>::template apply<
typename node<Value, Parameters, Box, Allocators, node_default_static_tag>::type
typename node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>::type
>(allocators.internal_node_allocator, allocators.internal_node_allocator);
}
};
@@ -109,16 +136,16 @@ struct create_node<
template <typename Allocators, typename Value, typename Parameters, typename Box>
struct create_node<
Allocators,
leaf_poly<Value, Parameters, Box, Allocators, node_default_static_tag>
dynamic_leaf<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
>
{
static inline typename node<Value, Parameters, Box, Allocators, node_default_static_tag>::type *
static inline typename node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>::type *
apply(Allocators & allocators)
{
return create_node_poly<
leaf_poly<Value, Parameters, Box, Allocators, node_default_static_tag>
dynamic_leaf<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
>::template apply<
typename node<Value, Parameters, Box, Allocators, node_default_static_tag>::type
typename node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>::type
>(allocators.leaf_allocator, allocators.leaf_allocator);
}
};

View File

@@ -56,24 +56,24 @@ struct leaf_variant
// nodes traits
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct node<Value, Parameters, Box, Allocators, node_default_variant_tag>
struct node<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>
{
typedef boost::variant<
leaf_variant<Value, Parameters, Box, Allocators, node_default_variant_tag>,
internal_node_variant<Value, Parameters, Box, Allocators, node_default_variant_tag>
leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>,
internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>
> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node<Value, Parameters, Box, Allocators, node_default_variant_tag>
struct internal_node<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>
{
typedef internal_node_variant<Value, Parameters, Box, Allocators, node_default_variant_tag> type;
typedef internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf<Value, Parameters, Box, Allocators, node_default_variant_tag>
struct leaf<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag>
{
typedef leaf_variant<Value, Parameters, Box, Allocators, node_default_variant_tag> type;
typedef leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag> type;
};
// nodes conversion
@@ -103,7 +103,7 @@ inline V * get(
// visitor traits
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_default_variant_tag, IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag, IsVisitableConst>
{
typedef static_visitor<> type;
};
@@ -163,25 +163,25 @@ element_indexable(std::pair<
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box, typename Tag>
struct allocators_variant
template <typename Allocator, typename Value, typename Parameters, typename Box>
struct allocators<Allocator, Value, Parameters, Box, node_s_mem_dynamic_tag>
{
typedef Allocator allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::template rebind<
typename node<Value, Parameters, Box, allocators_variant, node_default_variant_tag>::type
typename node<Value, Parameters, Box, allocators, node_s_mem_dynamic_tag>::type
>::other node_allocator_type;
typedef typename allocator_type::template rebind<
std::pair<Box, node_poly<Value, Parameters, Box, allocators_variant, node_default_variant_tag> *>
std::pair<Box, typename node<Value, Parameters, Box, allocators, node_s_mem_dynamic_tag>::type *>
>::other internal_node_elements_allocator_type;
typedef typename allocator_type::template rebind<
Value
>::other leaf_elements_allocator_type;
inline explicit allocators_variant(Allocator alloc)
inline explicit allocators(Allocator alloc)
: allocator(alloc)
, node_allocator(allocator)
, internal_node_elements_allocator(allocator)
@@ -194,14 +194,6 @@ struct allocators_variant
leaf_elements_allocator_type leaf_elements_allocator;
};
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box>
struct allocators<Allocator, Value, Parameters, Box, node_default_variant_tag>
{
typedef allocators_variant<Allocator, Value, Parameters, Box, node_default_variant_tag> type;
};
// create_node_variant
template <typename Node>

View File

@@ -21,12 +21,12 @@ namespace detail { namespace rtree {
// nodes default types
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
struct internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
{
typedef index::pushable_array<
std::pair<
Box,
typename node<Value, Parameters, Box, Allocators, node_default_static_variant_tag>::type *
typename node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>::type *
>,
Parameters::max_elements + 1
> elements_type;
@@ -38,7 +38,7 @@ struct internal_node_variant<Value, Parameters, Box, Allocators, node_default_st
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
struct leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
{
typedef index::pushable_array<Value, Parameters::max_elements + 1> elements_type;
@@ -51,55 +51,55 @@ struct leaf_variant<Value, Parameters, Box, Allocators, node_default_static_vari
// nodes traits
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct node<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
struct node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
{
typedef boost::variant<
leaf_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag>,
internal_node_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>,
internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
struct internal_node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
{
typedef internal_node_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag> type;
typedef internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
struct leaf<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
{
typedef leaf_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag> type;
typedef leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag> type;
};
// visitor traits
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_default_static_variant_tag, IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_s_mem_static_tag, IsVisitableConst>
{
typedef static_visitor<> type;
};
// allocators_variant
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box>
struct allocators_variant<Allocator, Value, Parameters, Box, node_default_static_variant_tag>
struct allocators<Allocator, Value, Parameters, Box, node_s_mem_static_tag>
{
typedef Allocator allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::template rebind<
typename node<Value, Parameters, Box, allocators_variant, node_default_static_variant_tag>::type
typename node<Value, Parameters, Box, allocators, node_s_mem_static_tag>::type
>::other node_allocator_type;
typedef typename allocator_type::template rebind<
std::pair<Box, node_poly<Value, Parameters, Box, allocators_variant, node_default_static_variant_tag> *>
std::pair<Box, typename node<Value, Parameters, Box, allocators, node_s_mem_static_tag>::type *>
>::other internal_node_elements_allocator_type;
typedef typename allocator_type::template rebind<
Value
>::other leaf_elements_allocator_type;
inline explicit allocators_variant(Allocator alloc)
inline explicit allocators(Allocator alloc)
: allocator(alloc)
, node_allocator(allocator)
{}
@@ -108,29 +108,21 @@ struct allocators_variant<Allocator, Value, Parameters, Box, node_default_static
node_allocator_type node_allocator;
};
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box>
struct allocators<Allocator, Value, Parameters, Box, node_default_static_variant_tag>
{
typedef allocators_variant<Allocator, Value, Parameters, Box, node_default_static_variant_tag> type;
};
// create_node
template <typename Allocators, typename Value, typename Parameters, typename Box>
struct create_node<
Allocators,
internal_node_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
>
{
static inline typename node<Value, Parameters, Box, Allocators, node_default_static_variant_tag>::type *
static inline typename node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>::type *
apply(Allocators & allocators)
{
return create_node_variant<
internal_node_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
internal_node_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
>::template apply<
typename node<Value, Parameters, Box, Allocators, node_default_static_variant_tag>::type
typename node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>::type
>(allocators.node_allocator, allocators.node_allocator);
}
};
@@ -138,16 +130,16 @@ struct create_node<
template <typename Allocators, typename Value, typename Parameters, typename Box>
struct create_node<
Allocators,
leaf_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
>
{
static inline typename node<Value, Parameters, Box, Allocators, node_default_static_variant_tag>::type *
static inline typename node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>::type *
apply(Allocators & allocators)
{
return create_node_variant<
leaf_variant<Value, Parameters, Box, Allocators, node_default_static_variant_tag>
leaf_variant<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
>::template apply<
typename node<Value, Parameters, Box, Allocators, node_default_static_variant_tag>::type
typename node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>::type
>(allocators.node_allocator, allocators.node_allocator);
}
};

View File

@@ -33,10 +33,10 @@ struct quadratic_tag {};
struct rstar_tag {};
// NodeTag
struct node_default_tag {};
struct node_default_variant_tag {};
struct node_default_static_tag {};
struct node_default_static_variant_tag {};
struct node_d_mem_dynamic_tag {};
struct node_d_mem_static_tag {};
struct node_s_mem_dynamic_tag {};
struct node_s_mem_static_tag {};
// TODO: awulkiew - implement those:
//if ( m_min_elems_per_node < 1 )
@@ -216,7 +216,7 @@ struct options_type< linear<MaxElements, MinElements> >
choose_by_content_diff_tag,
split_default_tag,
linear_tag,
node_default_static_tag
node_d_mem_static_tag
> type;
};
@@ -229,7 +229,7 @@ struct options_type< quadratic<MaxElements, MinElements> >
choose_by_content_diff_tag,
split_default_tag,
quadratic_tag,
node_default_static_tag
node_d_mem_static_tag
> type;
};
@@ -242,7 +242,7 @@ struct options_type< rstar<MaxElements, MinElements, OverlapCostThreshold, Reins
choose_by_overlap_diff_tag,
split_default_tag,
rstar_tag,
node_default_static_tag
node_d_mem_static_tag
> type;
};
@@ -255,7 +255,7 @@ struct options_type< rstar<MaxElements, MinElements, OverlapCostThreshold, Reins
// choose_by_content_diff_tag, // change it?
// split_kmeans_tag,
// int, // dummy tag - not used for now
// node_default_static_tag
// node_d_mem_static_tag
// > type;
//};
@@ -268,7 +268,7 @@ struct options_type< runtime::linear >
choose_by_content_diff_tag,
split_default_tag,
linear_tag,
node_default_tag
node_d_mem_dynamic_tag
> type;
};
@@ -281,7 +281,7 @@ struct options_type< runtime::quadratic >
choose_by_content_diff_tag,
split_default_tag,
quadratic_tag,
node_default_tag
node_d_mem_dynamic_tag
> type;
};
@@ -294,7 +294,7 @@ struct options_type< runtime::rstar >
choose_by_overlap_diff_tag,
split_default_tag,
rstar_tag,
node_default_tag
node_d_mem_dynamic_tag
> type;
};

View File

@@ -86,7 +86,7 @@ public:
typedef typename options_type::node_tag node_tag;
typedef Allocator allocator_type;
typedef typename detail::rtree::allocators<allocator_type, value_type, typename options_type::parameters_type, box_type, node_tag>::type allocators_type;
typedef detail::rtree::allocators<allocator_type, value_type, typename options_type::parameters_type, box_type, node_tag> allocators_type;
typedef typename allocators_type::size_type size_type;
typedef typename detail::rtree::node<value_type, typename options_type::parameters_type, box_type, allocators_type, node_tag>::type node;