rtree: unneeded allocators removed from members.

[SVN r82924]
This commit is contained in:
Adam Wulkiewicz
2013-02-16 14:54:52 +00:00
parent cb38c7b034
commit 24626df0cf
5 changed files with 125 additions and 179 deletions

View File

@@ -23,12 +23,17 @@ 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 typename Allocators::leaf_allocator_type::template rebind<
std::pair<Box, typename Allocators::node_pointer>
>::other elements_allocator_type;
typedef boost::container::vector<
std::pair<Box, typename Allocators::node_pointer>,
typename Allocators::internal_node_elements_allocator_type
elements_allocator_type
> elements_type;
inline dynamic_internal_node(typename Allocators::internal_node_elements_allocator_type & al)
template <typename Al>
inline dynamic_internal_node(Al const& al)
: elements(al)
{}
@@ -42,12 +47,17 @@ 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 typename Allocators::leaf_allocator_type::template rebind<
Value
>::other elements_allocator_type;
typedef boost::container::vector<
Value,
typename Allocators::leaf_elements_allocator_type
elements_allocator_type
> elements_type;
inline dynamic_leaf(typename Allocators::leaf_elements_allocator_type & al)
template <typename Al>
inline dynamic_leaf(Al const& al)
: elements(al)
{}
@@ -181,18 +191,6 @@ class allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>
, public Allocator::template rebind<
typename leaf<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>, node_d_mem_dynamic_tag>::type
>::other
, public Allocator::template rebind<
std::pair<
Box,
typename Allocator::template rebind<
typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>, node_d_mem_dynamic_tag>::type
>::other::pointer
>
>::other
, public Allocator::template rebind<
Value
>::other
, nonassignable
{
public:
typedef typename Allocator::size_type size_type;
@@ -213,58 +211,37 @@ public:
typename leaf<Value, Parameters, Box, allocators, node_d_mem_dynamic_tag>::type
>::other leaf_allocator_type;
typedef typename Allocator::template rebind<
std::pair<Box, node_pointer>
>::other internal_node_elements_allocator_type;
typedef typename Allocator::template rebind<
Value
>::other leaf_elements_allocator_type;
inline allocators()
: internal_node_allocator_type()
, leaf_allocator_type()
, internal_node_elements_allocator_type()
, leaf_elements_allocator_type()
{}
inline explicit allocators(Allocator const& alloc)
: internal_node_allocator_type(alloc)
, leaf_allocator_type(alloc)
, internal_node_elements_allocator_type(alloc)
, leaf_elements_allocator_type(alloc)
{}
inline allocators(BOOST_FWD_REF(allocators) a)
: internal_node_allocator_type(boost::move(a.internal_node_allocator()))
, leaf_allocator_type(boost::move(a.leaf_allocator()))
, internal_node_elements_allocator_type(boost::move(a.internal_node_elements_allocator()))
, leaf_elements_allocator_type(boost::move(a.leaf_elements_allocator()))
{}
void swap(allocators & a)
{
boost::swap(internal_node_allocator(), a.internal_node_allocator());
boost::swap(leaf_allocator(), a.leaf_allocator());
boost::swap(internal_node_elements_allocator(), a.internal_node_elements_allocator());
boost::swap(leaf_elements_allocator(), a.leaf_elements_allocator());
}
bool operator==(allocators const& a) const { return leaf_elements_allocator() == a.leaf_elements_allocator(); }
bool operator==(leaf_elements_allocator_type const& a) const { return leaf_elements_allocator() == a; }
bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
template <typename Alloc>
bool operator==(Alloc const& a) const { return leaf_elements_allocator() == leaf_elements_allocator_type(a); }
bool operator==(Alloc const& a) const { return leaf_allocator() == leaf_allocator_type(a); }
Allocator allocator() const { return Allocator(leaf_elements_allocator()); }
Allocator allocator() const { return Allocator(leaf_allocator()); }
internal_node_allocator_type & internal_node_allocator() { return *this; }
internal_node_allocator_type const& internal_node_allocator() const { return *this; }
leaf_allocator_type & leaf_allocator() { return *this; }
leaf_allocator_type const& leaf_allocator() const { return *this; }
internal_node_elements_allocator_type & internal_node_elements_allocator() { return *this; }
internal_node_elements_allocator_type const& internal_node_elements_allocator() const { return *this; }
leaf_elements_allocator_type & leaf_elements_allocator() { return *this; }
leaf_elements_allocator_type const& leaf_elements_allocator() const { return *this; }
};
// create_node_impl
@@ -272,8 +249,8 @@ public:
template <typename BaseNodePtr, typename Node>
struct create_dynamic_node
{
template <typename AllocNode, typename AllocElems>
static inline BaseNodePtr apply(AllocNode & alloc_node, AllocElems & alloc_elems)
template <typename AllocNode>
static inline BaseNodePtr apply(AllocNode & alloc_node)
{
typedef typename AllocNode::pointer P;
@@ -286,7 +263,7 @@ struct create_dynamic_node
{
// NOTE/TODO
// Here the whole node may be copied
alloc_node.construct(p, Node(alloc_elems));
alloc_node.construct(p, Node(alloc_node));
}
catch(...)
{
@@ -328,7 +305,7 @@ struct create_node<
return create_dynamic_node<
typename Allocators::node_pointer,
dynamic_internal_node<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.internal_node_allocator(), allocators.internal_node_elements_allocator());
>::apply(allocators.internal_node_allocator());
}
};
@@ -344,7 +321,7 @@ struct create_node<
return create_dynamic_node<
typename Allocators::node_pointer,
dynamic_leaf<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.leaf_allocator(), allocators.leaf_elements_allocator());
>::apply(allocators.leaf_allocator());
}
};

View File

@@ -22,17 +22,18 @@ template <typename Value, typename Parameters, typename Box, typename Allocators
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 typename Allocators::leaf_allocator_type::template rebind<
std::pair<Box, typename Allocators::node_pointer>
>::other elements_allocator_type;
typedef detail::varray<
std::pair<
Box,
typename Allocators::node_pointer
>,
std::pair<Box, typename Allocators::node_pointer>,
Parameters::max_elements + 1,
typename Allocators::internal_node_elements_allocator_type
elements_allocator_type
> elements_type;
template <typename Dummy>
inline dynamic_internal_node(Dummy) {}
template <typename Alloc>
inline dynamic_internal_node(Alloc const&) {}
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); }
@@ -44,14 +45,18 @@ template <typename Value, typename Parameters, typename Box, typename Allocators
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 typename Allocators::leaf_allocator_type::template rebind<
Value
>::other elements_allocator_type;
typedef detail::varray<
Value,
Parameters::max_elements + 1,
typename Allocators::leaf_elements_allocator_type
elements_allocator_type
> elements_type;
template <typename Dummy>
inline dynamic_leaf(Dummy) {}
template <typename Alloc>
inline dynamic_leaf(Alloc const&) {}
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); }
@@ -110,7 +115,6 @@ class allocators<Allocator, Value, Parameters, Box, node_d_mem_static_tag>
node_d_mem_static_tag
>::type
>::other
, detail::nonassignable
{
public:
typedef typename Allocator::size_type size_type;
@@ -131,14 +135,6 @@ public:
typename leaf<Value, Parameters, Box, allocators, node_d_mem_static_tag>::type
>::other leaf_allocator_type;
typedef typename Allocator::template rebind<
std::pair<Box, node_pointer>
>::other internal_node_elements_allocator_type;
typedef typename Allocator::template rebind<
Value
>::other leaf_elements_allocator_type;
inline allocators()
: internal_node_allocator_type()
, leaf_allocator_type()
@@ -186,7 +182,7 @@ struct create_node<
return create_dynamic_node<
typename Allocators::node_pointer,
dynamic_internal_node<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
>::apply(allocators.internal_node_allocator(), allocators.internal_node_allocator());
>::apply(allocators.internal_node_allocator());
}
};
@@ -202,7 +198,7 @@ struct create_node<
return create_dynamic_node<
typename Allocators::node_pointer,
dynamic_leaf<Value, Parameters, Box, Allocators, node_d_mem_static_tag>
>::apply(allocators.leaf_allocator(), allocators.leaf_allocator());
>::apply(allocators.leaf_allocator());
}
};

View File

@@ -24,15 +24,17 @@ namespace detail { namespace rtree {
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct static_internal_node
{
typedef typename Allocators::node_allocator_type::template rebind<
std::pair<Box, typename Allocators::node_pointer>
>::other elements_allocator_type;
typedef boost::container::vector<
std::pair<
Box,
typename Allocators::node_pointer
>,
typename Allocators::internal_node_elements_allocator_type
std::pair<Box, typename Allocators::node_pointer>,
elements_allocator_type
> elements_type;
inline static_internal_node(typename Allocators::internal_node_elements_allocator_type & al)
template <typename Al>
inline static_internal_node(Al const& al)
: elements(al)
{}
@@ -42,12 +44,17 @@ struct static_internal_node
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct static_leaf
{
typedef typename Allocators::node_allocator_type::template rebind<
Value
>::other elements_allocator_type;
typedef boost::container::vector<
Value,
typename Allocators::leaf_elements_allocator_type
elements_allocator_type
> elements_type;
inline static_leaf(typename Allocators::leaf_elements_allocator_type & al)
template <typename Al>
inline static_leaf(Al const& al)
: elements(al)
{}
@@ -89,74 +96,50 @@ struct visitor<Value, Parameters, Box, Allocators, node_s_mem_dynamic_tag, IsVis
template <typename Allocator, typename Value, typename Parameters, typename Box>
class allocators<Allocator, Value, Parameters, Box, node_s_mem_dynamic_tag>
: nonassignable
: public Allocator::template rebind<
typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_s_mem_dynamic_tag>, node_s_mem_dynamic_tag>::type
>::other
{
BOOST_COPYABLE_AND_MOVABLE_ALT(allocators)
public:
typedef Allocator allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename Allocator::size_type size_type;
typedef typename allocator_type::template rebind<
typedef typename Allocator::template rebind<
typename node<Value, Parameters, Box, allocators, node_s_mem_dynamic_tag>::type
>::other::pointer node_pointer;
typedef typename allocator_type::template rebind<
typedef typename Allocator::template rebind<
typename internal_node<Value, Parameters, Box, allocators, node_s_mem_dynamic_tag>::type
>::other::pointer internal_node_pointer;
typedef typename allocator_type::template rebind<
typedef typename Allocator::template rebind<
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_pointer>
>::other internal_node_elements_allocator_type;
typedef typename allocator_type::template rebind<
Value
>::other leaf_elements_allocator_type;
inline allocators()
: allocator()
, node_allocator()
, internal_node_elements_allocator()
, leaf_elements_allocator()
: node_allocator_type()
{}
inline explicit allocators(Allocator alloc)
: allocator(alloc)
, node_allocator(allocator)
, internal_node_elements_allocator(allocator)
, leaf_elements_allocator(allocator)
inline explicit allocators(Allocator const& alloc)
: node_allocator_type(alloc)
{}
inline allocators(allocators const& a)
: allocator(a.allocator)
, node_allocator(a.node_allocator)
, internal_node_elements_allocator(a.internal_node_elements_allocator)
, leaf_elements_allocator(a.leaf_elements_allocator)
{}
inline allocators(BOOST_RV_REF(allocators) a)
: allocator(boost::move(a.allocator))
, node_allocator(boost::move(a.node_allocator))
, internal_node_elements_allocator(boost::move(a.internal_node_elements_allocator))
, leaf_elements_allocator(boost::move(a.leaf_elements_allocator))
inline allocators(BOOST_FWD_REF(allocators) a)
: node_allocator_type(boost::move(a.node_allocator()))
{}
void swap(allocators & a)
{
boost::swap(allocator, a.allocator);
boost::swap(node_allocator, a.node_allocator);
boost::swap(internal_node_elements_allocator, a.internal_node_elements_allocator);
boost::swap(leaf_elements_allocator, a.leaf_elements_allocator);
boost::swap(node_allocator(), a.node_allocator());
}
allocator_type allocator;
node_allocator_type node_allocator;
internal_node_elements_allocator_type internal_node_elements_allocator;
leaf_elements_allocator_type leaf_elements_allocator;
bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); }
template <typename Alloc>
bool operator==(Alloc const& a) const { return node_allocator() == node_allocator_type(a); }
Allocator allocator() const { return Allocator(node_allocator()); }
node_allocator_type & node_allocator() { return *this; }
node_allocator_type const& node_allocator() const { return *this; }
};
// create_node_variant
@@ -164,8 +147,8 @@ public:
template <typename VariantPtr, typename Node>
struct create_static_node
{
template <typename AllocNode, typename AllocElems>
static inline VariantPtr apply(AllocNode & alloc_node, AllocElems & alloc_elems)
template <typename AllocNode>
static inline VariantPtr apply(AllocNode & alloc_node)
{
VariantPtr p = alloc_node.allocate(1);
@@ -176,7 +159,7 @@ struct create_static_node
{
// NOTE/TODO
// Here the whole node may be copied
alloc_node.construct(p, Node(alloc_elems)); // implicit cast to Variant
alloc_node.construct(p, Node(alloc_node)); // implicit cast to Variant
}
catch(...)
{
@@ -215,7 +198,7 @@ struct create_node<
return create_static_node<
typename Allocators::node_pointer,
static_internal_node<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.node_allocator, allocators.internal_node_elements_allocator);
>::apply(allocators.node_allocator());
}
};
@@ -231,7 +214,7 @@ struct create_node<
return create_static_node<
typename Allocators::node_pointer,
static_leaf<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.node_allocator, allocators.leaf_elements_allocator);
>::apply(allocators.node_allocator());
}
};
@@ -247,7 +230,7 @@ struct destroy_node<
{
destroy_static_node<
static_internal_node<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.node_allocator, n);
>::apply(allocators.node_allocator(), n);
}
};
@@ -261,7 +244,7 @@ struct destroy_node<
{
destroy_static_node<
static_leaf<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.node_allocator, n);
>::apply(allocators.node_allocator(), n);
}
};

View File

@@ -24,17 +24,18 @@ namespace detail { namespace rtree {
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
{
typedef typename Allocators::node_allocator_type::template rebind<
std::pair<Box, typename Allocators::node_pointer>
>::other elements_allocator_type;
typedef detail::varray<
std::pair<
Box,
typename Allocators::node_pointer
>,
std::pair<Box, typename Allocators::node_pointer>,
Parameters::max_elements + 1,
typename Allocators::internal_node_elements_allocator_type
elements_allocator_type
> elements_type;
template <typename Dummy>
inline static_internal_node(Dummy) {}
template <typename Alloc>
inline static_internal_node(Alloc const&) {}
elements_type elements;
};
@@ -42,14 +43,18 @@ struct static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_stati
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct static_leaf<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
{
typedef typename Allocators::node_allocator_type::template rebind<
Value
>::other elements_allocator_type;
typedef detail::varray<
Value,
Parameters::max_elements + 1,
typename Allocators::leaf_elements_allocator_type
elements_allocator_type
> elements_type;
template <typename Dummy>
inline static_leaf(Dummy) {}
template <typename Alloc>
inline static_leaf(Alloc const&) {}
elements_type elements;
};
@@ -89,62 +94,50 @@ struct visitor<Value, Parameters, Box, Allocators, node_s_mem_static_tag, IsVisi
template <typename Allocator, typename Value, typename Parameters, typename Box>
struct allocators<Allocator, Value, Parameters, Box, node_s_mem_static_tag>
: nonassignable
: public Allocator::template rebind<
typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_s_mem_static_tag>, node_s_mem_static_tag>::type
>::other
{
BOOST_COPYABLE_AND_MOVABLE_ALT(allocators)
public:
typedef Allocator allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename Allocator::size_type size_type;
typedef typename allocator_type::template rebind<
typedef typename Allocator::template rebind<
typename node<Value, Parameters, Box, allocators, node_s_mem_static_tag>::type
>::other::pointer node_pointer;
typedef typename allocator_type::template rebind<
typedef typename Allocator::template rebind<
typename internal_node<Value, Parameters, Box, allocators, node_s_mem_static_tag>::type
>::other::pointer internal_node_pointer;
typedef typename allocator_type::template rebind<
typedef typename Allocator::template rebind<
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_pointer>
>::other internal_node_elements_allocator_type;
typedef typename allocator_type::template rebind<
Value
>::other leaf_elements_allocator_type;
inline allocators()
: allocator()
, node_allocator()
: node_allocator_type()
{}
inline explicit allocators(Allocator alloc)
: allocator(alloc)
, node_allocator(allocator)
inline explicit allocators(Allocator const& alloc)
: node_allocator_type(alloc)
{}
inline allocators(allocators const& a)
: allocator(a.allocator)
, node_allocator(a.node_allocator)
{}
inline allocators(BOOST_RV_REF(allocators) a)
: allocator(boost::move(a.allocator))
, node_allocator(boost::move(a.node_allocator))
inline allocators(BOOST_FWD_REF(allocators) a)
: node_allocator_type(boost::move(a.node_allocator()))
{}
void swap(allocators & a)
{
boost::swap(allocator, a.allocator);
boost::swap(node_allocator, a.node_allocator);
boost::swap(node_allocator(), a.node_allocator());
}
allocator_type allocator;
node_allocator_type node_allocator;
bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); }
template <typename Alloc>
bool operator==(Alloc const& a) const { return node_allocator() == node_allocator_type(a); }
Allocator allocator() const { return Allocator(node_allocator()); }
node_allocator_type & node_allocator() { return *this; }
node_allocator_type const& node_allocator() const { return *this; }
};
// create_node
@@ -161,7 +154,7 @@ struct create_node<
return create_static_node<
typename Allocators::node_pointer,
static_internal_node<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
>::template apply(allocators.node_allocator, allocators.node_allocator);
>::template apply(allocators.node_allocator());
}
};
@@ -177,7 +170,7 @@ struct create_node<
return create_static_node<
typename Allocators::node_pointer,
static_leaf<Value, Parameters, Box, Allocators, node_s_mem_static_tag>
>::template apply(allocators.node_allocator, allocators.node_allocator);
>::template apply(allocators.node_allocator());
}
};

View File

@@ -76,15 +76,12 @@ struct dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d
: public dynamic_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
{
typedef throwing_varray<
std::pair<
Box,
typename Allocators::node_pointer
>,
std::pair<Box, typename Allocators::node_pointer>,
Parameters::max_elements + 1
> elements_type;
template <typename Dummy>
inline dynamic_internal_node(Dummy) {}
inline dynamic_internal_node(Dummy const&) {}
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
@@ -99,7 +96,7 @@ struct dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_stat
typedef throwing_varray<Value, Parameters::max_elements + 1> elements_type;
template <typename Dummy>
inline dynamic_leaf(Dummy) {}
inline dynamic_leaf(Dummy const&) {}
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, false> & v) { v(*this); }
void apply_visitor(dynamic_visitor<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag, true> & v) const { v(*this); }
@@ -251,7 +248,7 @@ struct create_node<
return create_dynamic_node<
typename Allocators::node_pointer,
dynamic_internal_node<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
>::apply(allocators.internal_node_allocator(), allocators.internal_node_allocator());
>::apply(allocators.internal_node_allocator());
}
};
@@ -270,7 +267,7 @@ struct create_node<
return create_dynamic_node<
typename Allocators::node_pointer,
dynamic_leaf<Value, Parameters, Box, Allocators, node_throwing_d_mem_static_tag>
>::apply(allocators.leaf_allocator(), allocators.leaf_allocator());
>::apply(allocators.leaf_allocator());
}
};