|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82918 - in sandbox-branches/geometry/index: boost/geometry/index boost/geometry/index/detail/rtree/node example test/rtree/exceptions
From: adam.wulkiewicz_at_[hidden]
Date: 2013-02-15 20:21:33
Author: awulkiew
Date: 2013-02-15 20:21:32 EST (Fri, 15 Feb 2013)
New Revision: 82918
URL: http://svn.boost.org/trac/boost/changeset/82918
Log:
rtree object size decreased by deriving allocators holder from allocators
Text files modified:
sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp | 116 ++++++++++++++++++++++-----------------
sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp | 80 +++++++++++++++------------
sandbox-branches/geometry/index/boost/geometry/index/rtree.hpp | 6 +-
sandbox-branches/geometry/index/example/benchmark.cpp | 2
sandbox-branches/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp | 74 ++++++++++++++-----------
5 files changed, 154 insertions(+), 124 deletions(-)
Modified: sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp 2013-02-15 20:21:32 EST (Fri, 15 Feb 2013)
@@ -175,84 +175,96 @@
template <typename Allocator, typename Value, typename Parameters, typename Box>
class allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>
- : nonassignable
+ : public Allocator::template rebind<
+ typename internal_node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>, node_d_mem_dynamic_tag>::type
+ >::other
+ , 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
{
- 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_d_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_d_mem_dynamic_tag>::type
>::other::pointer internal_node_pointer;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
typename internal_node<Value, Parameters, Box, allocators, node_d_mem_dynamic_tag>::type
>::other internal_node_allocator_type;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
typename leaf<Value, Parameters, Box, allocators, node_d_mem_dynamic_tag>::type
>::other leaf_allocator_type;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
std::pair<Box, node_pointer>
>::other internal_node_elements_allocator_type;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
Value
>::other leaf_elements_allocator_type;
inline allocators()
- : allocator()
- , internal_node_allocator()
- , leaf_allocator()
- , internal_node_elements_allocator()
- , leaf_elements_allocator()
- {}
-
- inline explicit allocators(Allocator alloc)
- : allocator(alloc)
- , internal_node_allocator(allocator)
- , leaf_allocator(allocator)
- , internal_node_elements_allocator(allocator)
- , leaf_elements_allocator(allocator)
+ : internal_node_allocator_type()
+ , leaf_allocator_type()
+ , internal_node_elements_allocator_type()
+ , leaf_elements_allocator_type()
{}
- inline allocators(allocators const& a)
- : allocator(a.allocator)
- , internal_node_allocator(a.internal_node_allocator)
- , leaf_allocator(a.leaf_allocator)
- , internal_node_elements_allocator(a.internal_node_elements_allocator)
- , leaf_elements_allocator(a.leaf_elements_allocator)
+ 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_RV_REF(allocators) a)
- : allocator(boost::move(a.allocator))
- , internal_node_allocator(boost::move(a.internal_node_allocator))
- , leaf_allocator(boost::move(a.leaf_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)
+ : 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(allocator, a.allocator);
- 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);
- }
-
- allocator_type allocator;
- internal_node_allocator_type internal_node_allocator;
- leaf_allocator_type leaf_allocator;
- internal_node_elements_allocator_type internal_node_elements_allocator;
- leaf_elements_allocator_type leaf_elements_allocator;
+ 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; }
+ template <typename Alloc>
+ bool operator==(Alloc const& a) const { return leaf_elements_allocator() == leaf_elements_allocator_type(a); }
+
+ Allocator allocator() const { return Allocator(leaf_elements_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
@@ -316,7 +328,7 @@
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(), allocators.internal_node_elements_allocator());
}
};
@@ -332,7 +344,7 @@
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(), allocators.leaf_elements_allocator());
}
};
@@ -348,7 +360,7 @@
{
destroy_dynamic_node<
dynamic_internal_node<Value, Parameters, Box, Allocators, Tag>
- >::apply(allocators.internal_node_allocator, n);
+ >::apply(allocators.internal_node_allocator(), n);
}
};
@@ -362,7 +374,7 @@
{
destroy_dynamic_node<
dynamic_leaf<Value, Parameters, Box, Allocators, Tag>
- >::apply(allocators.leaf_allocator, n);
+ >::apply(allocators.leaf_allocator(), n);
}
};
Modified: sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp 2013-02-15 20:21:32 EST (Fri, 15 Feb 2013)
@@ -96,72 +96,80 @@
template <typename Allocator, typename Value, typename Parameters, typename Box>
class allocators<Allocator, Value, Parameters, Box, node_d_mem_static_tag>
- : detail::nonassignable
+ : public Allocator::template rebind<
+ typename internal_node<
+ Value, Parameters, Box,
+ allocators<Allocator, Value, Parameters, Box, node_d_mem_static_tag>,
+ node_d_mem_static_tag
+ >::type
+ >::other
+ , public Allocator::template rebind<
+ typename leaf<
+ Value, Parameters, Box,
+ allocators<Allocator, Value, Parameters, Box, node_d_mem_static_tag>,
+ node_d_mem_static_tag
+ >::type
+ >::other
+ , detail::nonassignable
{
- 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_d_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_d_mem_static_tag>::type
>::other::pointer internal_node_pointer;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
typename internal_node<Value, Parameters, Box, allocators, node_d_mem_static_tag>::type
>::other internal_node_allocator_type;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
typename leaf<Value, Parameters, Box, allocators, node_d_mem_static_tag>::type
>::other leaf_allocator_type;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
std::pair<Box, node_pointer>
>::other internal_node_elements_allocator_type;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
Value
>::other leaf_elements_allocator_type;
inline allocators()
- : allocator()
- , internal_node_allocator()
- , leaf_allocator()
- {}
-
- inline explicit allocators(Allocator alloc)
- : allocator(alloc)
- , internal_node_allocator(allocator)
- , leaf_allocator(allocator)
+ : internal_node_allocator_type()
+ , leaf_allocator_type()
{}
- inline allocators(allocators const& a)
- : allocator(a.allocator)
- , internal_node_allocator(a.internal_node_allocator)
- , leaf_allocator(a.leaf_allocator)
+ inline explicit allocators(Allocator const& alloc)
+ : internal_node_allocator_type(alloc)
+ , leaf_allocator_type(alloc)
{}
- inline allocators(BOOST_RV_REF(allocators) a)
- : allocator(boost::move(a.allocator))
- , internal_node_allocator(boost::move(a.internal_node_allocator))
- , leaf_allocator(boost::move(a.leaf_allocator))
+ 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()))
{}
void swap(allocators & a)
{
- boost::swap(allocator, a.allocator);
- boost::swap(internal_node_allocator, a.internal_node_allocator);
- boost::swap(leaf_allocator, a.leaf_allocator);
+ boost::swap(internal_node_allocator(), a.internal_node_allocator());
+ boost::swap(leaf_allocator(), a.leaf_allocator());
}
- allocator_type allocator;
- internal_node_allocator_type internal_node_allocator;
- leaf_allocator_type leaf_allocator;
+ bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
+ template <typename Alloc>
+ bool operator==(Alloc const& a) const { return leaf_allocator() == leaf_allocator_type(a); }
+
+ 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; }
};
// create_node
@@ -178,7 +186,7 @@
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(), allocators.internal_node_allocator());
}
};
@@ -194,7 +202,7 @@
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(), allocators.leaf_allocator());
}
};
Modified: sandbox-branches/geometry/index/boost/geometry/index/rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/index/rtree.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/index/rtree.hpp 2013-02-15 20:21:32 EST (Fri, 15 Feb 2013)
@@ -321,7 +321,7 @@
src.m_members.parameters(),
boost::move(allocator))
{
- if ( src.m_members.allocators().allocator == allocator )
+ if ( src.m_members.allocators() == allocator )
{
boost::swap(m_members.values_count, src.m_members.values_count);
boost::swap(m_members.leafs_level, src.m_members.leafs_level);
@@ -378,7 +378,7 @@
//TODO use Boost.Container allocator_traits_type::propagate_on_container_move_assignment
- if ( m_members.allocators().allocator == src.m_members.allocators().allocator )
+ if ( m_members.allocators() == src.m_members.allocators() )
{
m_members.translator() = src.m_members.translator();
m_members.parameters() = src.m_members.parameters();
@@ -782,7 +782,7 @@
*/
allocator_type get_allocator() const
{
- return m_members.allocators().allocator;
+ return m_members.allocators().allocator();
}
#if !defined(BOOST_GEOMETRY_INDEX_ENABLE_DEBUG_INTERFACE)
Modified: sandbox-branches/geometry/index/example/benchmark.cpp
==============================================================================
--- sandbox-branches/geometry/index/example/benchmark.cpp (original)
+++ sandbox-branches/geometry/index/example/benchmark.cpp 2013-02-15 20:21:32 EST (Fri, 15 Feb 2013)
@@ -55,6 +55,8 @@
//typedef bgi::rtree<B, bgi::rstar<32, 8> > RT;
//typedef bgi::rtree<B, bgi::runtime::rstar > RT;
+ std::cout << "sizeof rtree: " << sizeof(RT) << std::endl;
+
for (;;)
{
RT t;
Modified: sandbox-branches/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp (original)
+++ sandbox-branches/geometry/index/test/rtree/exceptions/test_rtree_exceptions.hpp 2013-02-15 20:21:32 EST (Fri, 15 Feb 2013)
@@ -144,63 +144,71 @@
template <typename Allocator, typename Value, typename Parameters, typename Box>
class allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>
+ : public Allocator::template rebind<
+ typename internal_node<
+ Value, Parameters, Box,
+ allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>,
+ node_throwing_d_mem_static_tag
+ >::type
+ >::other
+ , Allocator::template rebind<
+ typename leaf<
+ Value, Parameters, Box,
+ allocators<Allocator, Value, Parameters, Box, node_throwing_d_mem_static_tag>,
+ node_throwing_d_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_throwing_d_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_throwing_d_mem_static_tag>::type
>::other::pointer internal_node_pointer;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
typename internal_node<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
>::other internal_node_allocator_type;
- typedef typename allocator_type::template rebind<
+ typedef typename Allocator::template rebind<
typename leaf<Value, Parameters, Box, allocators, node_throwing_d_mem_static_tag>::type
>::other leaf_allocator_type;
inline allocators()
- : allocator()
- , internal_node_allocator()
- , leaf_allocator()
- {}
-
- inline explicit allocators(Allocator alloc)
- : allocator(alloc)
- , internal_node_allocator(allocator)
- , leaf_allocator(allocator)
+ : internal_node_allocator_type()
+ , leaf_allocator_type()
{}
- inline allocators(allocators const& a)
- : allocator(a.allocator)
- , internal_node_allocator(a.internal_node_allocator)
- , leaf_allocator(a.leaf_allocator)
+ inline explicit allocators(Allocator const& alloc)
+ : internal_node_allocator_type(alloc)
+ , leaf_allocator_type(alloc)
{}
- inline allocators(BOOST_RV_REF(allocators) a)
- : allocator(boost::move(a.allocator))
- , internal_node_allocator(boost::move(a.internal_node_allocator))
- , leaf_allocator(boost::move(a.leaf_allocator))
+ 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()))
{}
void swap(allocators & a)
{
- boost::swap(allocator, a.allocator);
- boost::swap(internal_node_allocator, a.internal_node_allocator);
- boost::swap(leaf_allocator, a.leaf_allocator);
+ boost::swap(internal_node_allocator(), a.internal_node_allocator());
+ boost::swap(leaf_allocator(), a.leaf_allocator());
}
- allocator_type allocator;
- internal_node_allocator_type internal_node_allocator;
- leaf_allocator_type leaf_allocator;
+ bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
+ template <typename Alloc>
+ bool operator==(Alloc const& a) const { return leaf_allocator() == leaf_allocator_type(a); }
+
+ 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; }
};
struct node_bad_alloc : public std::exception
@@ -243,7 +251,7 @@
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(), allocators.internal_node_allocator());
}
};
@@ -262,7 +270,7 @@
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(), allocators.leaf_allocator());
}
};
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk