cleanup: run clang-format

This commit is contained in:
Tim Blechmann
2023-12-07 17:27:32 +08:00
parent e312718a99
commit 7982bdc650
35 changed files with 3889 additions and 4010 deletions
+1 -1
View File
@@ -6,8 +6,8 @@
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <iostream>
#include <iomanip>
#include <iostream>
#include "../../../boost/heap/fibonacci_heap.hpp"
+45 -46
View File
@@ -33,24 +33,21 @@
# endif
#endif
namespace boost {
namespace heap {
namespace boost { namespace heap {
namespace detail {
typedef parameter::parameters< boost::parameter::optional< tag::allocator >,
boost::parameter::optional< tag::compare >,
boost::parameter::optional< tag::stable >,
boost::parameter::optional< tag::constant_time_size >,
boost::parameter::optional<tag::stability_counter_type>
> binomial_heap_signature;
boost::parameter::optional< tag::stability_counter_type > >
binomial_heap_signature;
template < typename T, typename Parspec >
struct make_binomial_heap_base
{
static const bool constant_time_size = parameter::binding<Parspec,
tag::constant_time_size,
boost::true_type
>::type::value;
static const bool constant_time_size
= parameter::binding< Parspec, tag::constant_time_size, boost::true_type >::type::value;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::type base_type;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::allocator_argument allocator_argument;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::compare_argument compare_argument;
@@ -59,9 +56,7 @@ struct make_binomial_heap_base
typedef typename boost::allocator_rebind< allocator_argument, node_type >::type allocator_type;
struct type:
base_type,
allocator_type
struct type : base_type, allocator_type
{
type( compare_argument const& arg ) :
base_type( arg )
@@ -69,7 +64,8 @@ struct make_binomial_heap_base
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
type( type const& rhs ) :
base_type(rhs), allocator_type(rhs)
base_type( rhs ),
allocator_type( rhs )
{}
type( type&& rhs ) :
@@ -94,7 +90,7 @@ struct make_binomial_heap_base
};
};
}
} // namespace detail
/**
* \class binomial_heap
@@ -118,13 +114,10 @@ template <typename T,
class A0 = boost::parameter::void_,
class A1 = boost::parameter::void_,
class A2 = boost::parameter::void_,
class A3 = boost::parameter::void_
>
class A3 = boost::parameter::void_ >
#endif
class binomial_heap :
private detail::make_binomial_heap_base<T,
typename detail::binomial_heap_signature::bind<A0, A1, A2, A3>::type
>::type
private detail::make_binomial_heap_base< T, typename detail::binomial_heap_signature::bind< A0, A1, A2, A3 >::type >::type
{
typedef typename detail::binomial_heap_signature::bind< A0, A1, A2, A3 >::type bound_args;
typedef detail::make_binomial_heap_base< T, bound_args > base_maker;
@@ -147,8 +140,7 @@ public:
private:
#ifndef BOOST_DOXYGEN_INVOKED
struct implementation_defined:
detail::extract_allocator_types<typename base_maker::allocator_argument>
struct implementation_defined : detail::extract_allocator_types< typename base_maker::allocator_argument >
{
typedef T value_type;
typedef typename detail::extract_allocator_types< typename base_maker::allocator_argument >::size_type size_type;
@@ -165,9 +157,8 @@ private:
typedef typename base_maker::node_type node_type;
typedef boost::intrusive::list<detail::heap_node_base<false>,
boost::intrusive::constant_time_size<true>
> node_list_type;
typedef boost::intrusive::list< detail::heap_node_base< false >, boost::intrusive::constant_time_size< true > >
node_list_type;
typedef typename node_list_type::iterator node_list_iterator;
typedef typename node_list_type::const_iterator node_list_const_iterator;
@@ -177,8 +168,8 @@ private:
node_list_const_iterator,
const value_type,
value_extractor,
detail::list_iterator_converter<node_type, node_list_type>
> iterator;
detail::list_iterator_converter< node_type, node_list_type > >
iterator;
typedef iterator const_iterator;
typedef detail::tree_iterator< node_type,
@@ -188,8 +179,8 @@ private:
detail::list_iterator_converter< node_type, node_list_type >,
true,
true,
value_compare
> ordered_iterator;
value_compare >
ordered_iterator;
};
#endif
@@ -224,12 +215,14 @@ private:
public:
/// \copydoc boost::heap::priority_queue::priority_queue(value_compare const &)
explicit binomial_heap( value_compare const& cmp = value_compare() ) :
super_t(cmp), top_element(0)
super_t( cmp ),
top_element( 0 )
{}
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue const &)
binomial_heap( binomial_heap const& rhs ) :
super_t(rhs), top_element(0)
super_t( rhs ),
top_element( 0 )
{
if ( rhs.empty() )
return;
@@ -255,7 +248,8 @@ public:
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&)
binomial_heap( binomial_heap&& rhs ) :
super_t(std::move(rhs)), top_element(rhs.top_element)
super_t( std::move( rhs ) ),
top_element( rhs.top_element )
{
trees.splice( trees.begin(), rhs.trees );
rhs.top_element = NULL;
@@ -363,7 +357,8 @@ public:
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
/**
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns handle to element.
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns
* handle to element.
*
* \b Complexity: Logarithmic.
*
@@ -406,8 +401,7 @@ public:
binomial_heap children( value_comp(), element->children, sz );
if ( trees.empty() ) {
stability_counter_type stability_count = super_t::get_stability_count();
size_t size = constant_time_size ? size_holder::get_size()
: 0;
size_t size = constant_time_size ? size_holder::get_size() : 0;
swap( children );
super_t::set_stability_count( stability_count );
@@ -415,7 +409,6 @@ public:
size_holder::set_size( size );
} else
merge_and_clear_nodes( children );
}
if ( trees.empty() )
@@ -455,12 +448,12 @@ public:
node_pointer this_node = handle.node_;
if ( this_node->parent ) {
if (super_t::operator()(super_t::get_value(this_node->parent->value), super_t::get_value(this_node->value)))
if ( super_t::operator()( super_t::get_value( this_node->parent->value ),
super_t::get_value( this_node->value ) ) )
increase( handle );
else
decrease( handle );
}
else
} else
decrease( handle );
}
@@ -511,7 +504,8 @@ public:
*
* \b Complexity: Logarithmic.
*
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has
* been updated, the behavior of the data structure is undefined!
* */
void decrease( handle_type handle )
{
@@ -545,8 +539,7 @@ public:
rhs.set_size( 0 );
rhs.top_element = NULL;
super_t::set_stability_count((std::max)(super_t::get_stability_count(),
rhs.get_stability_count()));
super_t::set_stability_count( ( std::max )( super_t::get_stability_count(), rhs.get_stability_count() ) );
rhs.set_stability_count( 0 );
}
@@ -800,7 +793,9 @@ private:
void siftdown( node_pointer n )
{
while ( n->child_count() ) {
node_pointer max_child = detail::find_max_child<node_list_type, node_type, internal_compare>(n->children, super_t::get_internal_cmp());
node_pointer max_child
= detail::find_max_child< node_list_type, node_type, internal_compare >( n->children,
super_t::get_internal_cmp() );
if ( super_t::operator()( max_child->value, n->value ) )
return;
@@ -884,7 +879,9 @@ private:
void update_top_element( void )
{
top_element = detail::find_max_child<node_list_type, node_type, internal_compare>(trees, super_t::get_internal_cmp());
top_element
= detail::find_max_child< node_list_type, node_type, internal_compare >( trees,
super_t::get_internal_cmp() );
}
void sorted_by_degree( void ) const
@@ -900,7 +897,8 @@ private:
BOOST_HEAP_ASSERT( ( detail::is_heap< node_type, super_t >( n, *this ) ) );
size_type child_nodes = detail::count_nodes< node_type >( n );
BOOST_HEAP_ASSERT(child_nodes == size_type(1 << static_cast<const_node_pointer>(&*it)->child_count()));
BOOST_HEAP_ASSERT( child_nodes
== size_type( 1 << static_cast< const_node_pointer >( &*it )->child_count() ) );
}
# endif
}
@@ -911,7 +909,9 @@ private:
sorted_by_degree();
if ( !empty() ) {
node_pointer found_top = detail::find_max_child<node_list_type, node_type, internal_compare>(trees, super_t::get_internal_cmp());
node_pointer found_top
= detail::find_max_child< node_list_type, node_type, internal_compare >( trees,
super_t::get_internal_cmp() );
BOOST_HEAP_ASSERT( top_element == found_top );
}
@@ -929,8 +929,7 @@ private:
};
} /* namespace heap */
} /* namespace boost */
}} // namespace boost::heap
#undef BOOST_HEAP_ASSERT
+44 -53
View File
@@ -15,11 +15,11 @@
#include <boost/assert.hpp>
#include <boost/mem_fn.hpp>
#include <boost/heap/detail/heap_comparison.hpp>
#include <boost/heap/detail/mutable_heap.hpp>
#include <boost/heap/detail/ordered_adaptor_iterator.hpp>
#include <boost/heap/detail/stable_heap.hpp>
#include <boost/heap/detail/mutable_heap.hpp>
#include <boost/mem_fn.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
@@ -34,8 +34,7 @@
# endif
#endif
namespace boost {
namespace heap {
namespace boost { namespace heap {
namespace detail {
struct nop_index_updater
@@ -50,23 +49,21 @@ typedef parameter::parameters<boost::parameter::required<tag::arity>,
boost::parameter::optional< tag::compare >,
boost::parameter::optional< tag::stable >,
boost::parameter::optional< tag::stability_counter_type >,
boost::parameter::optional<tag::constant_time_size>
> d_ary_heap_signature;
boost::parameter::optional< tag::constant_time_size > >
d_ary_heap_signature;
/* base class for d-ary heap */
template <typename T,
class BoundArgs,
class IndexUpdater>
class d_ary_heap:
private make_heap_base<T, BoundArgs, false>::type
template < typename T, class BoundArgs, class IndexUpdater >
class d_ary_heap : private make_heap_base< T, BoundArgs, false >::type
{
typedef make_heap_base< T, BoundArgs, false > heap_base_maker;
typedef typename heap_base_maker::type super_t;
typedef typename super_t::internal_type internal_type;
typedef typename boost::allocator_rebind<typename heap_base_maker::allocator_argument, internal_type>::type internal_type_allocator;
typedef typename boost::allocator_rebind< typename heap_base_maker::allocator_argument, internal_type >::type
internal_type_allocator;
typedef std::vector< internal_type, internal_type_allocator > container_type;
typedef typename container_type::const_iterator container_iterator;
@@ -79,11 +76,11 @@ class d_ary_heap:
template < typename Heap1, typename Heap2 >
friend struct heap_merge_emulate;
struct implementation_defined:
extract_allocator_types<typename heap_base_maker::allocator_argument>
struct implementation_defined : extract_allocator_types< typename heap_base_maker::allocator_argument >
{
typedef T value_type;
typedef typename detail::extract_allocator_types<typename heap_base_maker::allocator_argument>::size_type size_type;
typedef
typename detail::extract_allocator_types< typename heap_base_maker::allocator_argument >::size_type size_type;
typedef typename heap_base_maker::compare_argument value_compare;
typedef typename heap_base_maker::allocator_argument allocator_type;
@@ -103,8 +100,7 @@ class d_ary_heap:
static std::pair< size_type, size_type > get_child_nodes( const d_ary_heap* heap, size_type index )
{
BOOST_HEAP_ASSERT( !is_leaf( heap, index ) );
return std::make_pair(d_ary_heap::first_child_index(index),
heap->last_child_index(index));
return std::make_pair( d_ary_heap::first_child_index( index ), heap->last_child_index( index ) );
}
static internal_type const& get_internal_value( const d_ary_heap* heap, size_type index )
@@ -123,13 +119,12 @@ class d_ary_heap:
d_ary_heap,
allocator_type,
typename super_t::internal_compare,
ordered_iterator_dispatcher
> ordered_iterator;
ordered_iterator_dispatcher >
ordered_iterator;
typedef detail::stable_heap_iterator< const value_type, container_iterator, super_t > iterator;
typedef iterator const_iterator;
typedef void* handle_type;
};
typedef typename implementation_defined::ordered_iterator_dispatcher ordered_iterator_dispatcher;
@@ -157,12 +152,14 @@ public:
{}
d_ary_heap( d_ary_heap const& rhs ) :
super_t(rhs), q_(rhs.q_)
super_t( rhs ),
q_( rhs.q_ )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
d_ary_heap( d_ary_heap&& rhs ) :
super_t(std::move(rhs)), q_(std::move(rhs.q_))
super_t( std::move( rhs ) ),
q_( std::move( rhs.q_ ) )
{}
d_ary_heap& operator=( d_ary_heap&& rhs )
@@ -292,8 +289,7 @@ private:
reset_index( max_child_index, index );
std::swap( q_[ max_child_index ], q_[ index ] );
index = max_child_index;
}
else
} else
return;
}
}
@@ -309,8 +305,7 @@ private:
reset_index( parent, index );
std::swap( q_[ parent ], q_[ index ] );
index = parent;
}
else
} else
return;
}
}
@@ -333,10 +328,10 @@ private:
const size_type max_elements = std::distance( first_child, end );
const container_iterator last_child = (max_elements > D) ? first_child + D
: end;
const container_iterator last_child = ( max_elements > D ) ? first_child + D : end;
const container_iterator min_element = std::max_element(first_child, last_child, static_cast<super_t const &>(*this));
const container_iterator min_element
= std::max_element( first_child, last_child, static_cast< super_t const& >( *this ) );
return min_element - q_.begin();
}
@@ -359,22 +354,22 @@ private:
return last_index;
}
template<typename U,
typename V,
typename W,
typename X>
struct rebind {
typedef d_ary_heap<U, typename d_ary_heap_signature::bind<boost::heap::stable<heap_base_maker::is_stable>,
template < typename U, typename V, typename W, typename X >
struct rebind
{
typedef d_ary_heap< U,
typename d_ary_heap_signature::bind<
boost::heap::stable< heap_base_maker::is_stable >,
boost::heap::stability_counter_type< typename heap_base_maker::stability_counter_type >,
boost::heap::arity< D >,
boost::heap::compare< V >,
boost::heap::allocator<W>
>::type,
X
> other;
boost::heap::allocator< W > >::type,
X >
other;
};
template <class U> friend class priority_queue_mutable_wrapper;
template < class U >
friend class priority_queue_mutable_wrapper;
void update( size_type index )
{
@@ -392,8 +387,7 @@ private:
void erase( size_type index )
{
while (index != 0)
{
while ( index != 0 ) {
size_type parent = parent_index( index );
reset_index( index, parent );
@@ -423,14 +417,12 @@ struct select_dary_heap
typedef typename boost::conditional< is_mutable,
priority_queue_mutable_wrapper< d_ary_heap< T, BoundArgs, nop_index_updater > >,
d_ary_heap<T, BoundArgs, nop_index_updater >
>::type type;
d_ary_heap< T, BoundArgs, nop_index_updater > >::type type;
};
} /* namespace detail */
/**
* \class d_ary_heap
* \brief d-ary heap class
@@ -459,8 +451,7 @@ template <typename T,
class A2 = boost::parameter::void_,
class A3 = boost::parameter::void_,
class A4 = boost::parameter::void_,
class A5 = boost::parameter::void_
>
class A5 = boost::parameter::void_ >
#endif
class d_ary_heap :
public detail::select_dary_heap< T, typename detail::d_ary_heap_signature::bind< A0, A1, A2, A3, A4, A5 >::type >::type
@@ -474,8 +465,7 @@ class d_ary_heap:
#ifndef BOOST_DOXYGEN_INVOKED
static const bool is_mutable = detail::extract_mutable< bound_args >::value;
#define BOOST_HEAP_TYPEDEF_FROM_SUPER_T(NAME) \
typedef typename super_t::NAME NAME;
# define BOOST_HEAP_TYPEDEF_FROM_SUPER_T( NAME ) typedef typename super_t::NAME NAME;
struct implementation_defined
{
@@ -689,7 +679,8 @@ public:
*
* \b Complexity: Logarithmic.
*
* \b Note: The new value is expected to be greater than the current one. If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
* \b Note: The new value is expected to be greater than the current one. If this is not called, after a handle has
* been updated, the behavior of the data structure is undefined!
*
* \b Requirement: data structure must be configured as mutable
* */
@@ -719,7 +710,8 @@ public:
*
* \b Complexity: Logarithmic.
*
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has
* been updated, the behavior of the data structure is undefined!
*
* \b Requirement: data structure must be configured as mutable
* */
@@ -816,8 +808,7 @@ public:
}
};
} /* namespace heap */
} /* namespace boost */
}} // namespace boost::heap
#undef BOOST_HEAP_ASSERT
+13 -31
View File
@@ -10,9 +10,9 @@
#define BOOST_HEAP_DETAIL_HEAP_COMPARISON_HPP
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/concept/assert.hpp>
#include <boost/heap/heap_concepts.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/conditional.hpp>
#ifdef BOOST_HEAP_SANITYCHECKS
@@ -21,13 +21,10 @@
# define BOOST_HEAP_ASSERT( expression )
#endif
namespace boost {
namespace heap {
namespace detail {
namespace boost { namespace heap { namespace detail {
template < typename Heap1, typename Heap2 >
bool value_equality(Heap1 const & lhs, Heap2 const & rhs,
typename Heap1::value_type lval, typename Heap2::value_type rval)
bool value_equality( Heap1 const& lhs, Heap2 const& rhs, typename Heap1::value_type lval, typename Heap2::value_type rval )
{
typename Heap1::value_compare const& cmp = lhs.value_comp();
bool ret = !( cmp( lval, rval ) ) && !( cmp( rval, lval ) );
@@ -39,8 +36,7 @@ bool value_equality(Heap1 const & lhs, Heap2 const & rhs,
}
template < typename Heap1, typename Heap2 >
bool value_compare(Heap1 const & lhs, Heap2 const & rhs,
typename Heap1::value_type lval, typename Heap2::value_type rval)
bool value_compare( Heap1 const& lhs, Heap2 const& rhs, typename Heap1::value_type lval, typename Heap2::value_type rval )
{
typename Heap1::value_compare const& cmp = lhs.value_comp();
bool ret = cmp( lval, rval );
@@ -130,17 +126,13 @@ struct heap_equivalence_iteration
};
template <typename Heap1,
typename Heap2
>
template < typename Heap1, typename Heap2 >
bool heap_equality( Heap1 const& lhs, Heap2 const& rhs )
{
const bool use_ordered_iterators = Heap1::has_ordered_iterators && Heap2::has_ordered_iterators;
typedef typename boost::conditional<use_ordered_iterators,
heap_equivalence_iteration,
heap_equivalence_copy
>::type equivalence_check;
typedef typename boost::conditional< use_ordered_iterators, heap_equivalence_iteration, heap_equivalence_copy >::type
equivalence_check;
equivalence_check eq_check;
return eq_check( lhs, rhs );
@@ -149,9 +141,7 @@ bool heap_equality(Heap1 const & lhs, Heap2 const & rhs)
struct heap_compare_iteration
{
template <typename Heap1,
typename Heap2
>
template < typename Heap1, typename Heap2 >
bool operator()( Heap1 const& lhs, Heap2 const& rhs )
{
typename Heap1::size_type left_size = lhs.size();
@@ -187,9 +177,7 @@ struct heap_compare_iteration
struct heap_compare_copy
{
template <typename Heap1,
typename Heap2
>
template < typename Heap1, typename Heap2 >
bool operator()( Heap1 const& lhs, Heap2 const& rhs )
{
typename Heap1::size_type left_size = lhs.size();
@@ -219,26 +207,20 @@ struct heap_compare_copy
}
};
template <typename Heap1,
typename Heap2
>
template < typename Heap1, typename Heap2 >
bool heap_compare( Heap1 const& lhs, Heap2 const& rhs )
{
const bool use_ordered_iterators = Heap1::has_ordered_iterators && Heap2::has_ordered_iterators;
typedef typename boost::conditional<use_ordered_iterators,
heap_compare_iteration,
heap_compare_copy
>::type compare_check;
typedef
typename boost::conditional< use_ordered_iterators, heap_compare_iteration, heap_compare_copy >::type compare_check;
compare_check check_object;
return check_object( lhs, rhs );
}
} /* namespace detail */
} /* namespace heap */
} /* namespace boost */
}}} // namespace boost::heap::detail
#undef BOOST_HEAP_ASSERT
+32 -42
View File
@@ -10,9 +10,9 @@
#define BOOST_HEAP_DETAIL_HEAP_NODE_HPP
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/core/allocator_access.hpp>
#include <boost/intrusive/list.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/conditional.hpp>
#ifdef BOOST_HEAP_SANITYCHECKS
@@ -22,19 +22,14 @@
#endif
namespace boost {
namespace heap {
namespace detail {
namespace boost { namespace heap { namespace detail {
namespace bi = boost::intrusive;
template < bool auto_unlink = false >
struct heap_node_base :
bi::list_base_hook<typename boost::conditional<auto_unlink,
bi::link_mode<bi::auto_unlink>,
bi::link_mode<bi::safe_link>
>::type
>
bi::list_base_hook<
typename boost::conditional< auto_unlink, bi::link_mode< bi::auto_unlink >, bi::link_mode< bi::safe_link > >::type >
{};
typedef bi::list< heap_node_base< false > > heap_node_list;
@@ -55,8 +50,8 @@ bool is_heap(const Node * n, typename HeapBase::value_compare const & cmp)
Node const& this_node = static_cast< Node const& >( *it );
const Node* child = static_cast< const Node* >( &this_node );
if (cmp(HeapBase::get_value(n->value), HeapBase::get_value(child->value)) ||
!is_heap<Node, HeapBase>(child, cmp))
if ( cmp( HeapBase::get_value( n->value ), HeapBase::get_value( child->value ) )
|| !is_heap< Node, HeapBase >( child, cmp ) )
return false;
}
return true;
@@ -100,9 +95,7 @@ void destroy_node(Node& node)
* Node::Node(Node const &, Alloc &, Node * parent)
*
* */
template <typename Node,
typename NodeBase,
typename Alloc>
template < typename Node, typename NodeBase, typename Alloc >
struct node_cloner
{
node_cloner( Alloc& allocator ) :
@@ -133,9 +126,7 @@ private:
* Node::clear_subtree(Alloc &) clears the subtree via allocator
*
* */
template <typename Node,
typename NodeBase,
typename Alloc>
template < typename Node, typename NodeBase, typename Alloc >
struct node_disposer
{
typedef typename boost::allocator_pointer< Alloc >::type node_pointer;
@@ -156,19 +147,15 @@ struct node_disposer
};
template <typename ValueType,
bool constant_time_child_size = true
>
struct heap_node:
heap_node_base<!constant_time_child_size>
template < typename ValueType, bool constant_time_child_size = true >
struct heap_node : heap_node_base< !constant_time_child_size >
{
typedef heap_node_base< !constant_time_child_size > node_base;
public:
typedef ValueType value_type;
typedef bi::list<node_base,
bi::constant_time_size<constant_time_child_size> > child_list;
typedef bi::list< node_base, bi::constant_time_size< constant_time_child_size > > child_list;
typedef typename child_list::iterator child_iterator;
typedef typename child_list::const_iterator const_child_iterator;
@@ -193,7 +180,6 @@ public:
}
public:
template < typename Alloc >
heap_node( heap_node const& rhs, Alloc& allocator ) :
value( rhs.value )
@@ -228,19 +214,20 @@ public:
};
template < typename value_type >
struct parent_pointing_heap_node:
heap_node<value_type>
struct parent_pointing_heap_node : heap_node< value_type >
{
typedef heap_node< value_type > super_t;
parent_pointing_heap_node( value_type const& v ) :
super_t(v), parent(NULL)
super_t( v ),
parent( NULL )
{}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
parent_pointing_heap_node( Args&&... args ) :
super_t(std::forward<Args>(args)...), parent(NULL)
super_t( std::forward< Args >( args )... ),
parent( NULL )
{}
#endif
@@ -248,13 +235,15 @@ struct parent_pointing_heap_node:
struct node_cloner
{
node_cloner( Alloc& allocator, parent_pointing_heap_node* parent ) :
allocator(allocator), parent_(parent)
allocator( allocator ),
parent_( parent )
{}
parent_pointing_heap_node* operator()( typename super_t::node_base const& node )
{
parent_pointing_heap_node* ret = allocator.allocate( 1 );
new (ret) parent_pointing_heap_node(static_cast<parent_pointing_heap_node const &>(node), allocator, parent_);
new ( ret )
parent_pointing_heap_node( static_cast< parent_pointing_heap_node const& >( node ), allocator, parent_ );
return ret;
}
@@ -264,8 +253,11 @@ struct parent_pointing_heap_node:
};
template < typename Alloc >
parent_pointing_heap_node (parent_pointing_heap_node const & rhs, Alloc & allocator, parent_pointing_heap_node * parent):
super_t(static_cast<super_t const &>(rhs)), parent(parent)
parent_pointing_heap_node( parent_pointing_heap_node const& rhs,
Alloc& allocator,
parent_pointing_heap_node* parent ) :
super_t( static_cast< super_t const& >( rhs ) ),
parent( parent )
{
super_t::children.clone_from( rhs.children, node_cloner< Alloc >( allocator, this ), nop_disposer() );
}
@@ -308,19 +300,20 @@ struct parent_pointing_heap_node:
template < typename value_type >
struct marked_heap_node:
parent_pointing_heap_node<value_type>
struct marked_heap_node : parent_pointing_heap_node< value_type >
{
typedef parent_pointing_heap_node< value_type > super_t;
marked_heap_node( value_type const& v ) :
super_t(v), mark(false)
super_t( v ),
mark( false )
{}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
marked_heap_node( Args&&... args ) :
super_t(std::forward<Args>(args)...), mark(false)
super_t( std::forward< Args >( args )... ),
mark( false )
{}
#endif
@@ -342,8 +335,7 @@ template <typename Node>
struct cmp_by_degree
{
template < typename NodeBase >
bool operator()(NodeBase const & left,
NodeBase const & right)
bool operator()( NodeBase const& left, NodeBase const& right )
{
return static_cast< const Node* >( &left )->child_count() < static_cast< const Node* >( &right )->child_count();
}
@@ -365,9 +357,7 @@ Node * find_max_child(List const & list, Cmp const & cmp)
return const_cast< Node* >( ret );
}
} /* namespace detail */
} /* namespace heap */
} /* namespace boost */
}}} // namespace boost::heap::detail
#undef BOOST_HEAP_ASSERT
#endif /* BOOST_HEAP_DETAIL_HEAP_NODE_HPP */
+2 -4
View File
@@ -11,8 +11,7 @@
#include <string> // std::size_t
namespace boost {
namespace heap {
namespace boost { namespace heap {
namespace detail {
template < typename IntType >
@@ -58,7 +57,6 @@ IntType log2(IntType value)
return fn( value );
}
} /* namespace heap */
} /* namespace boost */
}} // namespace boost::heap
#endif /* BOOST_HEAP_DETAIL_ILOG2_HPP */
+33 -33
View File
@@ -16,12 +16,10 @@
#include <list>
#include <utility>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/heap/detail/ordered_adaptor_iterator.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
namespace boost {
namespace heap {
namespace detail {
namespace boost { namespace heap { namespace detail {
/* wrapper for a mutable heap container adaptors
*
@@ -112,8 +110,7 @@ public:
};
private:
struct indirect_cmp:
public value_compare
struct indirect_cmp : public value_compare
{
indirect_cmp( value_compare const& cmp = value_compare() ) :
value_compare( cmp )
@@ -125,9 +122,9 @@ private:
}
};
typedef typename PriorityQueueType::template rebind<list_iterator,
indirect_cmp,
allocator_type, index_updater >::other q_type;
typedef
typename PriorityQueueType::template rebind< list_iterator, indirect_cmp, allocator_type, index_updater >::other
q_type;
protected:
q_type q_;
@@ -139,7 +136,8 @@ protected:
{}
priority_queue_mutable_wrapper( priority_queue_mutable_wrapper const& rhs ) :
q_(rhs.q_), objects(rhs.objects)
q_( rhs.q_ ),
objects( rhs.objects )
{
for ( typename object_list::iterator it = objects.begin(); it != objects.end(); ++it )
q_.push( it );
@@ -184,7 +182,8 @@ public:
typedef boost::iterator_adaptor< iterator_base< iterator_type >,
iterator_type,
value_type const,
boost::bidirectional_traversal_tag> super_t;
boost::bidirectional_traversal_tag >
super_t;
friend class boost::iterator_core_access;
friend class priority_queue_mutable_wrapper;
@@ -215,18 +214,11 @@ public:
typedef typename object_list::difference_type difference_type;
class ordered_iterator :
public boost::iterator_adaptor<ordered_iterator,
const_list_iterator,
value_type const,
boost::forward_traversal_tag
>,
public boost::iterator_adaptor< ordered_iterator, const_list_iterator, value_type const, boost::forward_traversal_tag >,
q_type::ordered_iterator_dispatcher
{
typedef boost::iterator_adaptor<ordered_iterator,
const_list_iterator,
value_type const,
boost::forward_traversal_tag
> adaptor_type;
typedef boost::iterator_adaptor< ordered_iterator, const_list_iterator, value_type const, boost::forward_traversal_tag >
adaptor_type;
typedef const_list_iterator iterator;
typedef typename q_type::ordered_iterator_dispatcher ordered_iterator_dispatcher;
@@ -235,15 +227,21 @@ public:
public:
ordered_iterator( void ) :
adaptor_type(0), unvisited_nodes(indirect_cmp()), q_(NULL)
adaptor_type( 0 ),
unvisited_nodes( indirect_cmp() ),
q_( NULL )
{}
ordered_iterator( const priority_queue_mutable_wrapper* q, indirect_cmp const& cmp ) :
adaptor_type(0), unvisited_nodes(cmp), q_(q)
adaptor_type( 0 ),
unvisited_nodes( cmp ),
q_( q )
{}
ordered_iterator( const_list_iterator it, const priority_queue_mutable_wrapper* q, indirect_cmp const& cmp ) :
adaptor_type(it), unvisited_nodes(cmp), q_(q)
adaptor_type( it ),
unvisited_nodes( cmp ),
q_( q )
{
if ( it != q->objects.end() )
discover_nodes( it );
@@ -285,10 +283,12 @@ public:
if ( ordered_iterator_dispatcher::is_leaf( q, current_index ) )
return;
std::pair<size_type, size_type> child_range = ordered_iterator_dispatcher::get_child_nodes(q, current_index);
std::pair< size_type, size_type > child_range
= ordered_iterator_dispatcher::get_child_nodes( q, current_index );
for ( size_type i = child_range.first; i <= child_range.second; ++i ) {
typename q_type::internal_type const & internal_value_at_index = ordered_iterator_dispatcher::get_internal_value(q, i);
typename q_type::internal_type const& internal_value_at_index
= ordered_iterator_dispatcher::get_internal_value( q, i );
typename q_type::value_type const& value_at_index = q_->q_.get_value( internal_value_at_index );
unvisited_nodes.push( value_at_index );
@@ -297,8 +297,8 @@ public:
std::priority_queue< iterator,
std::vector< iterator, typename boost::allocator_rebind< allocator_type, iterator >::type >,
indirect_cmp
> unvisited_nodes;
indirect_cmp >
unvisited_nodes;
const priority_queue_mutable_wrapper* q_;
};
@@ -417,7 +417,8 @@ public:
*
* \b Complexity: Logarithmic.
*
* \b Note: The new value is expected to be greater than the current one. If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
* \b Note: The new value is expected to be greater than the current one. If this is not called, after a handle has
* been updated, the behavior of the data structure is undefined!
* */
void increase( handle_type handle )
{
@@ -445,7 +446,8 @@ public:
*
* \b Complexity: Logarithmic.
*
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has
* been updated, the behavior of the data structure is undefined!
* */
void decrease( handle_type handle )
{
@@ -517,8 +519,6 @@ public:
};
} /* namespace detail */
} /* namespace heap */
} /* namespace boost */
}}} // namespace boost::heap::detail
#endif /* BOOST_HEAP_DETAIL_MUTABLE_HEAP_HPP */
@@ -13,13 +13,11 @@
#include <limits>
#include <boost/assert.hpp>
#include <boost/concept_check.hpp>
#include <boost/heap/detail/tree_iterator.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/concept_check.hpp>
namespace boost {
namespace heap {
namespace detail {
namespace boost { namespace heap { namespace detail {
/* ordered iterator helper classes for container adaptors
*
@@ -27,39 +25,30 @@ namespace detail {
*
* * static size_type max_index(const ContainerType * heap); // return maximum index
* * static bool is_leaf(const ContainerType * heap, size_type index); // return if index denotes a leaf
* * static std::pair<size_type, size_type> get_child_nodes(const ContainerType * heap, size_type index); // get index range of child nodes
* * static internal_type const & get_internal_value(const ContainerType * heap, size_type index); // get internal value at index
* * static std::pair<size_type, size_type> get_child_nodes(const ContainerType * heap, size_type index); // get index
* range of child nodes
* * static internal_type const & get_internal_value(const ContainerType * heap, size_type index); // get internal value
* at index
* * static value_type const & get_value(internal_type const & arg) const; // get value_type from internal_type
*
* */
template <typename ValueType,
typename InternalType,
typename ContainerType,
typename Alloc,
typename ValueCompare,
typename Dispatcher
>
template < typename ValueType, typename InternalType, typename ContainerType, typename Alloc, typename ValueCompare, typename Dispatcher >
class ordered_adaptor_iterator :
public boost::iterator_facade<ordered_adaptor_iterator<ValueType,
InternalType,
ContainerType,
Alloc,
ValueCompare,
Dispatcher>,
public boost::iterator_facade<
ordered_adaptor_iterator< ValueType, InternalType, ContainerType, Alloc, ValueCompare, Dispatcher >,
ValueType,
boost::forward_traversal_tag
>,
boost::forward_traversal_tag >,
Dispatcher
{
friend class boost::iterator_core_access;
struct compare_by_heap_value:
ValueCompare
struct compare_by_heap_value : ValueCompare
{
const ContainerType* container;
compare_by_heap_value( const ContainerType* container, ValueCompare const& cmp ) :
ValueCompare(cmp), container(container)
ValueCompare( cmp ),
container( container )
{}
bool operator()( size_t lhs, size_t rhs )
@@ -76,17 +65,20 @@ class ordered_adaptor_iterator:
public:
ordered_adaptor_iterator( void ) :
container(NULL), current_index((std::numeric_limits<size_t>::max)()),
container( NULL ),
current_index( ( std::numeric_limits< size_t >::max )() ),
unvisited_nodes( compare_by_heap_value( NULL, ValueCompare() ) )
{}
ordered_adaptor_iterator( const ContainerType* container, ValueCompare const& cmp ) :
container(container), current_index(container->size()),
container( container ),
current_index( container->size() ),
unvisited_nodes( compare_by_heap_value( container, ValueCompare() ) )
{}
ordered_adaptor_iterator( size_t initial_index, const ContainerType* container, ValueCompare const& cmp ) :
container(container), current_index(initial_index),
container( container ),
current_index( initial_index ),
unvisited_nodes( compare_by_heap_value( container, cmp ) )
{
discover_nodes( initial_index );
@@ -134,13 +126,11 @@ private:
std::priority_queue< size_t,
std::vector< size_t, typename boost::allocator_rebind< Alloc, size_t >::type >,
compare_by_heap_value
> unvisited_nodes;
compare_by_heap_value >
unvisited_nodes;
};
} /* namespace detail */
} /* namespace heap */
} /* namespace boost */
}}} // namespace boost::heap::detail
#endif /* BOOST_HEAP_DETAIL_ORDERED_ADAPTOR_ITERATOR_HPP */
+59 -61
View File
@@ -13,20 +13,18 @@
#include <stdexcept>
#include <utility>
#include <boost/cstdint.hpp>
#include <boost/throw_exception.hpp>
#include <boost/core/allocator_access.hpp>
#include <boost/cstdint.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/throw_exception.hpp>
#include <boost/heap/policies.hpp>
#include <boost/heap/heap_merge.hpp>
#include <boost/heap/policies.hpp>
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
#include <boost/type_traits/is_nothrow_move_assignable.hpp>
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
namespace boost {
namespace heap {
namespace detail {
namespace boost { namespace heap { namespace detail {
template < bool ConstantSize, class SizeType >
struct size_holder
@@ -34,19 +32,16 @@ struct size_holder
static const bool constant_time_size = ConstantSize;
typedef SizeType size_type;
size_holder(void) BOOST_NOEXCEPT:
size_(0)
size_holder( void ) BOOST_NOEXCEPT : size_( 0 )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
size_holder(size_holder && rhs) BOOST_NOEXCEPT:
size_(rhs.size_)
size_holder( size_holder&& rhs ) BOOST_NOEXCEPT : size_( rhs.size_ )
{
rhs.size_ = 0;
}
size_holder(size_holder const & rhs) BOOST_NOEXCEPT:
size_(rhs.size_)
size_holder( size_holder const& rhs ) BOOST_NOEXCEPT : size_( rhs.size_ )
{}
size_holder& operator=( size_holder&& rhs ) BOOST_NOEXCEPT
@@ -64,25 +59,39 @@ struct size_holder
#endif
SizeType get_size() const BOOST_NOEXCEPT
{ return size_; }
{
return size_;
}
void set_size( SizeType size ) BOOST_NOEXCEPT
{ size_ = size; }
{
size_ = size;
}
void decrement() BOOST_NOEXCEPT
{ --size_; }
{
--size_;
}
void increment() BOOST_NOEXCEPT
{ ++size_; }
{
++size_;
}
void add( SizeType value ) BOOST_NOEXCEPT
{ size_ += value; }
{
size_ += value;
}
void sub( SizeType value ) BOOST_NOEXCEPT
{ size_ -= value; }
{
size_ -= value;
}
void swap( size_holder& rhs ) BOOST_NOEXCEPT
{ std::swap(size_, rhs.size_); }
{
std::swap( size_, rhs.size_ );
}
SizeType size_;
};
@@ -115,7 +124,9 @@ struct size_holder<false, SizeType>
#endif
size_type get_size() const BOOST_NOEXCEPT
{ return 0; }
{
return 0;
}
void set_size( size_type ) BOOST_NOEXCEPT
{}
@@ -138,12 +149,7 @@ struct size_holder<false, SizeType>
// note: MSVC does not implement lookup correctly, we therefore have to place the Cmp object as member inside the
// struct. of course, this prevents EBO and significantly reduces the readability of this code
template <typename T,
typename Cmp,
bool constant_time_size,
typename StabilityCounterType = boost::uintmax_t,
bool stable = false
>
template < typename T, typename Cmp, bool constant_time_size, typename StabilityCounterType = boost::uintmax_t, bool stable = false >
struct heap_base :
#ifndef BOOST_MSVC
Cmp,
@@ -177,7 +183,8 @@ struct heap_base:
# endif
size_holder_type( std::move( static_cast< size_holder_type& >( rhs ) ) )
# ifdef BOOST_MSVC
, cmp_(std::move(rhs.cmp_))
,
cmp_( std::move( rhs.cmp_ ) )
# endif
{}
@@ -187,7 +194,8 @@ struct heap_base:
# endif
size_holder_type( static_cast< size_holder_type const& >( rhs ) )
# ifdef BOOST_MSVC
, cmp_(rhs.value_comp())
,
cmp_( rhs.value_comp() )
# endif
{}
@@ -255,7 +263,8 @@ struct heap_base:
return value_comp();
}
void swap(heap_base & rhs) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<Cmp>::value && boost::is_nothrow_move_assignable<Cmp>::value)
void swap( heap_base& rhs ) BOOST_NOEXCEPT_IF(
boost::is_nothrow_move_constructible< Cmp >::value&& boost::is_nothrow_move_assignable< Cmp >::value )
{
std::swap( value_comp_ref(), rhs.value_comp_ref() );
size_holder< constant_time_size, size_t >::swap( rhs );
@@ -284,11 +293,7 @@ private:
};
template <typename T,
typename Cmp,
bool constant_time_size,
typename StabilityCounterType
>
template < typename T, typename Cmp, bool constant_time_size, typename StabilityCounterType >
struct heap_base< T, Cmp, constant_time_size, StabilityCounterType, true > :
#ifndef BOOST_MSVC
Cmp,
@@ -303,12 +308,14 @@ struct heap_base<T, Cmp, constant_time_size, StabilityCounterType, true>:
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
internal_type( stability_counter_type cnt, Args&&... args ) :
first(std::forward<Args>(args)...), second(cnt)
first( std::forward< Args >( args )... ),
second( cnt )
{}
#endif
internal_type( stability_counter_type const& cnt, T const& value ) :
first(value), second(cnt)
first( value ),
second( cnt )
{}
T first;
@@ -338,7 +345,8 @@ struct heap_base<T, Cmp, constant_time_size, StabilityCounterType, true>:
# else
cmp_( std::move( rhs.cmp_ ) ),
# endif
size_holder_type(std::move(static_cast<size_holder_type&>(rhs))), counter_(rhs.counter_)
size_holder_type( std::move( static_cast< size_holder_type& >( rhs ) ) ),
counter_( rhs.counter_ )
{
rhs.counter_ = 0;
}
@@ -349,7 +357,8 @@ struct heap_base<T, Cmp, constant_time_size, StabilityCounterType, true>:
# else
cmp_( rhs.value_comp() ),
# endif
size_holder_type(static_cast<size_holder_type const &>(rhs)), counter_(rhs.counter_)
size_holder_type( static_cast< size_holder_type const& >( rhs ) ),
counter_( rhs.counter_ )
{}
heap_base& operator=( heap_base&& rhs ) BOOST_NOEXCEPT_IF( boost::is_nothrow_move_assignable< Cmp >::value )
@@ -420,8 +429,7 @@ struct heap_base<T, Cmp, constant_time_size, StabilityCounterType, true>:
#endif
}
struct internal_compare:
Cmp
struct internal_compare : Cmp
{
internal_compare( Cmp const& cmp = Cmp() ) :
Cmp( cmp )
@@ -444,7 +452,8 @@ struct heap_base<T, Cmp, constant_time_size, StabilityCounterType, true>:
return internal_compare( value_comp() );
}
void swap(heap_base & rhs) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<Cmp>::value && boost::is_nothrow_move_assignable<Cmp>::value)
void swap( heap_base& rhs ) BOOST_NOEXCEPT_IF(
boost::is_nothrow_move_constructible< Cmp >::value&& boost::is_nothrow_move_assignable< Cmp >::value )
{
#ifndef BOOST_MSVC
std::swap( static_cast< Cmp& >( *this ), static_cast< Cmp& >( rhs ) );
@@ -481,10 +490,7 @@ private:
stability_counter_type counter_;
};
template <typename node_pointer,
typename extractor,
typename reference
>
template < typename node_pointer, typename extractor, typename reference >
struct node_handle
{
explicit node_handle( node_pointer n = 0 ) :
@@ -509,10 +515,7 @@ struct node_handle
node_pointer node_;
};
template <typename value_type,
typename internal_type,
typename extractor
>
template < typename value_type, typename internal_type, typename extractor >
struct value_extractor
{
value_type const& operator()( internal_type const& data ) const
@@ -521,19 +524,15 @@ struct value_extractor
}
};
template <typename T,
typename ContainerIterator,
typename Extractor>
template < typename T, typename ContainerIterator, typename Extractor >
class stable_heap_iterator :
public boost::iterator_adaptor< stable_heap_iterator< T, ContainerIterator, Extractor >,
ContainerIterator,
T const,
boost::random_access_traversal_tag >
{
typedef boost::iterator_adaptor<stable_heap_iterator,
ContainerIterator,
T const,
boost::random_access_traversal_tag> super_t;
typedef boost::iterator_adaptor< stable_heap_iterator, ContainerIterator, T const, boost::random_access_traversal_tag >
super_t;
public:
stable_heap_iterator( void ) :
@@ -558,7 +557,8 @@ struct make_heap_base
{
typedef typename parameter::binding< Parspec, tag::compare, std::less< T > >::type compare_argument;
typedef typename parameter::binding< Parspec, tag::allocator, std::allocator< T > >::type allocator_argument;
typedef typename parameter::binding<Parspec, tag::stability_counter_type, boost::uintmax_t >::type stability_counter_type;
typedef
typename parameter::binding< Parspec, tag::stability_counter_type, boost::uintmax_t >::type stability_counter_type;
static const bool is_stable = extract_stable< Parspec >::value;
@@ -578,8 +578,6 @@ struct extract_allocator_types
};
} /* namespace detail */
} /* namespace heap */
} /* namespace boost */
}}} // namespace boost::heap::detail
#endif /* BOOST_HEAP_DETAIL_STABLE_HEAP_HPP */
+40 -71
View File
@@ -17,19 +17,21 @@
#include <boost/type_traits/conditional.hpp>
#include <queue>
namespace boost {
namespace heap {
namespace detail {
namespace boost { namespace heap { namespace detail {
template < typename type >
struct identity
{
type& operator()( type& x ) const BOOST_NOEXCEPT
{ return x; }
{
return x;
}
const type& operator()( const type& x ) const BOOST_NOEXCEPT
{ return x; }
{
return x;
}
};
template < typename Node >
@@ -53,10 +55,7 @@ struct pointer_to_reference
};
template <typename HandleType,
typename Alloc,
typename ValueCompare
>
template < typename HandleType, typename Alloc, typename ValueCompare >
struct unordered_tree_iterator_storage
{
unordered_tree_iterator_storage( ValueCompare const& cmp )
@@ -85,18 +84,10 @@ struct unordered_tree_iterator_storage
std::vector< HandleType, typename boost::allocator_rebind< Alloc, HandleType >::type > data_;
};
template <typename ValueType,
typename HandleType,
typename Alloc,
typename ValueCompare,
typename ValueExtractor
>
struct ordered_tree_iterator_storage:
ValueExtractor
template < typename ValueType, typename HandleType, typename Alloc, typename ValueCompare, typename ValueExtractor >
struct ordered_tree_iterator_storage : ValueExtractor
{
struct compare_values_by_handle:
ValueExtractor,
ValueCompare
struct compare_values_by_handle : ValueExtractor, ValueCompare
{
compare_values_by_handle( ValueCompare const& cmp ) :
ValueCompare( cmp )
@@ -136,7 +127,8 @@ struct ordered_tree_iterator_storage:
std::priority_queue< HandleType,
std::vector< HandleType, typename boost::allocator_rebind< Alloc, HandleType >::type >,
compare_values_by_handle> data_;
compare_values_by_handle >
data_;
};
@@ -154,58 +146,44 @@ template <typename Node,
typename PointerExtractor = dereferencer< Node >,
bool check_null_pointer = false,
bool ordered_iterator = false,
typename ValueCompare = std::less<ValueType>
>
typename ValueCompare = std::less< ValueType > >
class tree_iterator :
public boost::iterator_adaptor<tree_iterator<Node,
ValueType,
Alloc,
ValueExtractor,
PointerExtractor,
check_null_pointer,
ordered_iterator,
ValueCompare
>,
public boost::iterator_adaptor<
tree_iterator< Node, ValueType, Alloc, ValueExtractor, PointerExtractor, check_null_pointer, ordered_iterator, ValueCompare >,
const Node*,
ValueType,
boost::forward_traversal_tag
>,
boost::forward_traversal_tag >,
ValueExtractor,
PointerExtractor
{
typedef boost::iterator_adaptor<tree_iterator<Node,
ValueType,
Alloc,
ValueExtractor,
PointerExtractor,
check_null_pointer,
ordered_iterator,
ValueCompare
>,
typedef boost::iterator_adaptor<
tree_iterator< Node, ValueType, Alloc, ValueExtractor, PointerExtractor, check_null_pointer, ordered_iterator, ValueCompare >,
const Node*,
ValueType,
boost::forward_traversal_tag
> adaptor_type;
boost::forward_traversal_tag >
adaptor_type;
friend class boost::iterator_core_access;
typedef typename boost::conditional< ordered_iterator,
typedef typename boost::conditional<
ordered_iterator,
ordered_tree_iterator_storage< ValueType, const Node*, Alloc, ValueCompare, ValueExtractor >,
unordered_tree_iterator_storage<const Node*, Alloc, ValueCompare>
>::type
unvisited_node_container;
unordered_tree_iterator_storage< const Node*, Alloc, ValueCompare > >::type unvisited_node_container;
public:
tree_iterator( void ) :
adaptor_type(0), unvisited_nodes(ValueCompare())
adaptor_type( 0 ),
unvisited_nodes( ValueCompare() )
{}
tree_iterator( ValueCompare const& cmp ) :
adaptor_type(0), unvisited_nodes(cmp)
adaptor_type( 0 ),
unvisited_nodes( cmp )
{}
tree_iterator( const Node* it, ValueCompare const& cmp ) :
adaptor_type(it), unvisited_nodes(cmp)
adaptor_type( it ),
unvisited_nodes( cmp )
{
if ( it )
discover_nodes( it );
@@ -214,7 +192,8 @@ public:
/* fills the iterator from a list of possible top nodes */
template < typename NodePointerIterator >
tree_iterator( NodePointerIterator begin, NodePointerIterator end, const Node* top_node, ValueCompare const& cmp ) :
adaptor_type(0), unvisited_nodes(cmp)
adaptor_type( 0 ),
unvisited_nodes( cmp )
{
BOOST_STATIC_ASSERT( ordered_iterator );
if ( begin == end )
@@ -294,29 +273,21 @@ template <typename Node,
typename NodeIterator,
typename ValueType,
typename ValueExtractor = identity< typename Node::value_type >,
typename IteratorCoverter = identity<NodeIterator>
>
typename IteratorCoverter = identity< NodeIterator > >
class recursive_tree_iterator :
public boost::iterator_adaptor<recursive_tree_iterator<Node,
NodeIterator,
ValueType,
ValueExtractor,
IteratorCoverter
>,
public boost::iterator_adaptor< recursive_tree_iterator< Node, NodeIterator, ValueType, ValueExtractor, IteratorCoverter >,
NodeIterator,
ValueType const,
boost::bidirectional_traversal_tag >,
ValueExtractor, IteratorCoverter
{
typedef boost::iterator_adaptor<recursive_tree_iterator<Node,
NodeIterator,
ValueType,
ValueExtractor,
IteratorCoverter
>,
{
typedef boost::iterator_adaptor<
recursive_tree_iterator< Node, NodeIterator, ValueType, ValueExtractor, IteratorCoverter >,
NodeIterator,
ValueType const,
boost::bidirectional_traversal_tag> adaptor_type;
boost::bidirectional_traversal_tag >
adaptor_type;
friend class boost::iterator_core_access;
@@ -372,8 +343,6 @@ public:
};
} /* namespace detail */
} /* namespace heap */
} /* namespace boost */
}}} // namespace boost::heap::detail
#endif /* BOOST_HEAP_DETAIL_TREE_ITERATOR_HPP */
+34 -39
View File
@@ -35,24 +35,21 @@
# endif
#endif
namespace boost {
namespace heap {
namespace boost { namespace heap {
namespace detail {
typedef parameter::parameters< boost::parameter::optional< tag::allocator >,
boost::parameter::optional< tag::compare >,
boost::parameter::optional< tag::stable >,
boost::parameter::optional< tag::constant_time_size >,
boost::parameter::optional<tag::stability_counter_type>
> fibonacci_heap_signature;
boost::parameter::optional< tag::stability_counter_type > >
fibonacci_heap_signature;
template < typename T, typename Parspec >
struct make_fibonacci_heap_base
{
static const bool constant_time_size = parameter::binding<Parspec,
tag::constant_time_size,
boost::true_type
>::type::value;
static const bool constant_time_size
= parameter::binding< Parspec, tag::constant_time_size, boost::true_type >::type::value;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::type base_type;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::allocator_argument allocator_argument;
@@ -61,9 +58,7 @@ struct make_fibonacci_heap_base
typedef typename boost::allocator_rebind< allocator_argument, node_type >::type allocator_type;
struct type:
base_type,
allocator_type
struct type : base_type, allocator_type
{
type( compare_argument const& arg ) :
base_type( arg )
@@ -97,8 +92,7 @@ struct make_fibonacci_heap_base
};
};
}
} // namespace detail
/**
@@ -124,13 +118,11 @@ template <typename T,
class A1 = boost::parameter::void_,
class A2 = boost::parameter::void_,
class A3 = boost::parameter::void_,
class A4 = boost::parameter::void_
>
class A4 = boost::parameter::void_ >
#endif
class fibonacci_heap :
private detail::make_fibonacci_heap_base<T,
typename detail::fibonacci_heap_signature::bind<A0, A1, A2, A3, A4>::type
>::type
private detail::
make_fibonacci_heap_base< T, typename detail::fibonacci_heap_signature::bind< A0, A1, A2, A3, A4 >::type >::type
{
typedef typename detail::fibonacci_heap_signature::bind< A0, A1, A2, A3, A4 >::type bound_args;
typedef detail::make_fibonacci_heap_base< T, bound_args > base_maker;
@@ -145,8 +137,7 @@ class fibonacci_heap:
private:
#ifndef BOOST_DOXYGEN_INVOKED
struct implementation_defined:
detail::extract_allocator_types<typename base_maker::allocator_argument>
struct implementation_defined : detail::extract_allocator_types< typename base_maker::allocator_argument >
{
typedef T value_type;
typedef typename detail::extract_allocator_types< typename base_maker::allocator_argument >::size_type size_type;
@@ -172,8 +163,8 @@ private:
node_list_const_iterator,
const value_type,
value_extractor,
detail::list_iterator_converter<node, node_list_type>
> iterator;
detail::list_iterator_converter< node, node_list_type > >
iterator;
typedef iterator const_iterator;
typedef detail::tree_iterator< node,
@@ -183,8 +174,8 @@ private:
detail::list_iterator_converter< node, node_list_type >,
true,
true,
value_compare
> ordered_iterator;
value_compare >
ordered_iterator;
};
typedef typename implementation_defined::node node;
@@ -221,12 +212,14 @@ public:
/// \copydoc boost::heap::priority_queue::priority_queue(value_compare const &)
explicit fibonacci_heap( value_compare const& cmp = value_compare() ) :
super_t(cmp), top_element(0)
super_t( cmp ),
top_element( 0 )
{}
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue const &)
fibonacci_heap( fibonacci_heap const& rhs ) :
super_t(rhs), top_element(0)
super_t( rhs ),
top_element( 0 )
{
if ( rhs.empty() )
return;
@@ -238,7 +231,8 @@ public:
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&)
fibonacci_heap( fibonacci_heap&& rhs ) :
super_t(std::move(rhs)), top_element(rhs.top_element)
super_t( std::move( rhs ) ),
top_element( rhs.top_element )
{
roots.splice( roots.begin(), rhs.roots );
rhs.top_element = NULL;
@@ -361,7 +355,8 @@ public:
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
/**
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns handle to element.
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns
* handle to element.
*
* \b Complexity: Constant.
*
@@ -515,7 +510,8 @@ public:
*
* \b Complexity: Logarithmic.
*
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has
* been updated, the behavior of the data structure is undefined!
* */
void decrease( handle_type handle )
{
@@ -583,8 +579,7 @@ public:
{
size_holder::add( rhs.get_size() );
if (!top_element ||
(rhs.top_element && super_t::operator()(top_element->value, rhs.top_element->value)))
if ( !top_element || ( rhs.top_element && super_t::operator()( top_element->value, rhs.top_element->value ) ) )
top_element = rhs.top_element;
roots.splice( roots.end(), rhs.roots );
@@ -592,8 +587,7 @@ public:
rhs.top_element = NULL;
rhs.set_size( 0 );
super_t::set_stability_count((std::max)(super_t::get_stability_count(),
rhs.get_stability_count()));
super_t::set_stability_count( ( std::max )( super_t::get_stability_count(), rhs.get_stability_count() ) );
rhs.set_stability_count( 0 );
}
@@ -660,7 +654,8 @@ private:
typedef typename node::template node_cloner< allocator_type > node_cloner;
roots.clone_from( rhs.roots, node_cloner( *this, NULL ), detail::nop_disposer() );
top_element = detail::find_max_child<node_list_type, node, internal_compare>(roots, super_t::get_internal_cmp());
top_element
= detail::find_max_child< node_list_type, node, internal_compare >( roots, super_t::get_internal_cmp() );
}
void cut( node_pointer n )
@@ -721,7 +716,9 @@ private:
std::swap( n, other );
if ( other->parent )
n->children.splice(n->children.end(), other->parent->children, node_list_type::s_iterator_to(*other));
n->children.splice( n->children.end(),
other->parent->children,
node_list_type::s_iterator_to( *other ) );
else
n->children.splice( n->children.end(), roots, node_list_type::s_iterator_to( *other ) );
@@ -735,8 +732,7 @@ private:
if ( !super_t::operator()( n->value, top_element->value ) )
top_element = n;
}
while (it != roots.end());
} while ( it != roots.end() );
}
void finish_erase_or_pop( node_pointer erased_node )
@@ -759,8 +755,7 @@ private:
#endif
};
} /* namespace heap */
} /* namespace boost */
}} // namespace boost::heap
#undef BOOST_HEAP_ASSERT
+5 -9
View File
@@ -11,13 +11,11 @@
#include <boost/concept_check.hpp>
namespace boost {
namespace heap {
namespace boost { namespace heap {
template < class C >
struct PriorityQueue:
boost::ForwardContainer<C>
struct PriorityQueue : boost::ForwardContainer< C >
{
typedef typename C::iterator iterator;
typedef typename C::const_iterator const_iterator;
@@ -63,8 +61,7 @@ private:
};
template < class C >
struct MergablePriorityQueue:
PriorityQueue<C>
struct MergablePriorityQueue : PriorityQueue< C >
{
BOOST_CONCEPT_USAGE( MergablePriorityQueue )
{
@@ -75,8 +72,7 @@ struct MergablePriorityQueue:
template < class C >
struct MutablePriorityQueue:
PriorityQueue<C>
struct MutablePriorityQueue : PriorityQueue< C >
{
typedef typename C::handle_type handle_type;
@@ -105,6 +101,6 @@ struct MutablePriorityQueue:
bool equal, not_equal;
};
}}
}} // namespace boost::heap
#endif /* BOOST_HEAP_CONCEPTS_HPP */
+11 -20
View File
@@ -21,8 +21,7 @@
#endif
namespace boost {
namespace heap {
namespace boost { namespace heap {
namespace detail {
template < typename Heap1, typename Heap2 >
@@ -42,9 +41,7 @@ struct heap_merge_emulate
}
};
typedef typename boost::conditional<Heap1::has_reserve,
reserver,
dummy_reserver>::type space_reserver;
typedef typename boost::conditional< Heap1::has_reserve, reserver, dummy_reserver >::type space_reserver;
static void merge( Heap1& lhs, Heap2& rhs )
{
@@ -56,7 +53,8 @@ struct heap_merge_emulate
}
// FIXME: container adaptors could benefit from first appending all elements and then restoring the heap order
// FIXME: optimize: if we have ordered iterators and we can efficiently insert keys with a below the lowest key in the heap
// FIXME: optimize: if we have ordered iterators and we can efficiently insert keys with a below the lowest key
// in the heap
// d-ary, b and fibonacci heaps fall into this category
while ( !rhs.empty() ) {
@@ -64,11 +62,9 @@ struct heap_merge_emulate
rhs.pop();
}
lhs.set_stability_count((std::max)(lhs.get_stability_count(),
rhs.get_stability_count()));
lhs.set_stability_count( ( std::max )( lhs.get_stability_count(), rhs.get_stability_count() ) );
rhs.set_stability_count( 0 );
}
};
@@ -86,10 +82,9 @@ template <typename Heap>
struct heap_merge_same
{
static const bool is_mergable = Heap::is_mergable;
typedef typename boost::conditional<is_mergable,
heap_merge_same_mergable<Heap>,
heap_merge_emulate<Heap, Heap>
>::type heap_merger;
typedef
typename boost::conditional< is_mergable, heap_merge_same_mergable< Heap >, heap_merge_emulate< Heap, Heap > >::type
heap_merger;
static void merge( Heap& lhs, Heap& rhs )
{
@@ -105,9 +100,7 @@ struct heap_merge_same
* \b Effect: lhs contains all elements that have been part of rhs, rhs is empty.
*
* */
template <typename Heap1,
typename Heap2
>
template < typename Heap1, typename Heap2 >
void heap_merge( Heap1& lhs, Heap2& rhs )
{
BOOST_CONCEPT_ASSERT( (boost::heap::PriorityQueue< Heap1 >));
@@ -120,14 +113,12 @@ void heap_merge(Heap1 & lhs, Heap2 & rhs)
typedef typename boost::conditional< same_heaps,
detail::heap_merge_same< Heap1 >,
detail::heap_merge_emulate<Heap1, Heap2>
>::type heap_merger;
detail::heap_merge_emulate< Heap1, Heap2 > >::type heap_merger;
heap_merger::merge( lhs, rhs );
}
} /* namespace heap */
} /* namespace boost */
}} // namespace boost::heap
#endif /* BOOST_HEAP_MERGE_HPP */
+31 -37
View File
@@ -17,9 +17,9 @@
#include <boost/heap/detail/heap_comparison.hpp>
#include <boost/heap/detail/heap_node.hpp>
#include <boost/heap/policies.hpp>
#include <boost/heap/detail/stable_heap.hpp>
#include <boost/heap/detail/tree_iterator.hpp>
#include <boost/heap/policies.hpp>
#include <boost/type_traits/integral_constant.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
@@ -35,24 +35,21 @@
# endif
#endif
namespace boost {
namespace heap {
namespace boost { namespace heap {
namespace detail {
typedef parameter::parameters< boost::parameter::optional< tag::allocator >,
boost::parameter::optional< tag::compare >,
boost::parameter::optional< tag::stable >,
boost::parameter::optional< tag::constant_time_size >,
boost::parameter::optional<tag::stability_counter_type>
> pairing_heap_signature;
boost::parameter::optional< tag::stability_counter_type > >
pairing_heap_signature;
template < typename T, typename Parspec >
struct make_pairing_heap_base
{
static const bool constant_time_size = parameter::binding<Parspec,
tag::constant_time_size,
boost::true_type
>::type::value;
static const bool constant_time_size
= parameter::binding< Parspec, tag::constant_time_size, boost::true_type >::type::value;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::type base_type;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::allocator_argument allocator_argument;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::compare_argument compare_argument;
@@ -61,9 +58,7 @@ struct make_pairing_heap_base
typedef typename boost::allocator_rebind< allocator_argument, node_type >::type allocator_type;
struct type:
base_type,
allocator_type
struct type : base_type, allocator_type
{
type( compare_argument const& arg ) :
base_type( arg )
@@ -71,7 +66,8 @@ struct make_pairing_heap_base
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
type( type const& rhs ) :
base_type(rhs), allocator_type(rhs)
base_type( rhs ),
allocator_type( rhs )
{}
type( type&& rhs ) :
@@ -96,7 +92,7 @@ struct make_pairing_heap_base
};
};
}
} // namespace detail
/**
* \class pairing_heap
@@ -128,13 +124,10 @@ template <typename T,
class A1 = boost::parameter::void_,
class A2 = boost::parameter::void_,
class A3 = boost::parameter::void_,
class A4 = boost::parameter::void_
>
class A4 = boost::parameter::void_ >
#endif
class pairing_heap :
private detail::make_pairing_heap_base<T,
typename detail::pairing_heap_signature::bind<A0, A1, A2, A3, A4>::type
>::type
private detail::make_pairing_heap_base< T, typename detail::pairing_heap_signature::bind< A0, A1, A2, A3, A4 >::type >::type
{
typedef typename detail::pairing_heap_signature::bind< A0, A1, A2, A3, A4 >::type bound_args;
typedef detail::make_pairing_heap_base< T, bound_args > base_maker;
@@ -149,8 +142,7 @@ private:
friend struct heap_merge_emulate;
#ifndef BOOST_DOXYGEN_INVOKED
struct implementation_defined:
detail::extract_allocator_types<typename base_maker::allocator_argument>
struct implementation_defined : detail::extract_allocator_types< typename base_maker::allocator_argument >
{
typedef T value_type;
typedef typename detail::extract_allocator_types< typename base_maker::allocator_argument >::size_type size_type;
@@ -179,8 +171,8 @@ private:
detail::pointer_to_reference< node >,
false,
false,
value_compare
> iterator;
value_compare >
iterator;
typedef iterator const_iterator;
@@ -191,8 +183,8 @@ private:
detail::pointer_to_reference< node >,
false,
true,
value_compare
> ordered_iterator;
value_compare >
ordered_iterator;
};
typedef typename implementation_defined::node node;
@@ -202,9 +194,8 @@ private:
typedef typename implementation_defined::node_list_const_iterator node_list_const_iterator;
typedef typename implementation_defined::internal_compare internal_compare;
typedef boost::intrusive::list<detail::heap_node_base<true>,
boost::intrusive::constant_time_size<false>
> node_child_list;
typedef boost::intrusive::list< detail::heap_node_base< true >, boost::intrusive::constant_time_size< false > >
node_child_list;
#endif
public:
@@ -233,12 +224,14 @@ public:
/// \copydoc boost::heap::priority_queue::priority_queue(value_compare const &)
explicit pairing_heap( value_compare const& cmp = value_compare() ) :
super_t(cmp), root(NULL)
super_t( cmp ),
root( NULL )
{}
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue const &)
pairing_heap( pairing_heap const& rhs ) :
super_t(rhs), root(NULL)
super_t( rhs ),
root( NULL )
{
if ( rhs.empty() )
return;
@@ -250,7 +243,8 @@ public:
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&)
pairing_heap( pairing_heap&& rhs ) :
super_t(std::move(rhs)), root(rhs.root)
super_t( std::move( rhs ) ),
root( rhs.root )
{
rhs.root = NULL;
}
@@ -366,7 +360,8 @@ public:
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
/**
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns handle to element.
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns
* handle to element.
*
* \cond
* \b Complexity: \f$2^2log(log(N))\f$ (amortized).
@@ -497,7 +492,8 @@ public:
*
* \b Complexity: 2**2*log(log(N)) (amortized).
*
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has
* been updated, the behavior of the data structure is undefined!
* */
void decrease( handle_type handle )
{
@@ -586,8 +582,7 @@ public:
rhs.set_size( 0 );
rhs.root = NULL;
super_t::set_stability_count((std::max)(super_t::get_stability_count(),
rhs.get_stability_count()));
super_t::set_stability_count( ( std::max )( super_t::get_stability_count(), rhs.get_stability_count() ) );
rhs.set_stability_count( 0 );
}
@@ -708,8 +703,7 @@ private:
};
} /* namespace heap */
} /* namespace boost */
}} // namespace boost::heap
#undef BOOST_HEAP_ASSERT
#endif /* BOOST_HEAP_PAIRING_HEAP_HPP */
+47 -35
View File
@@ -10,11 +10,11 @@
#define BOOST_HEAP_POLICIES_HPP
#include <boost/concept_check.hpp>
#include <boost/parameter/name.hpp>
#include <boost/parameter/template_keyword.hpp>
#include <boost/parameter/aux_/void.hpp>
#include <boost/parameter/binding.hpp>
#include <boost/parameter/name.hpp>
#include <boost/parameter/parameters.hpp>
#include <boost/parameter/template_keyword.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/is_void.hpp>
@@ -23,54 +23,61 @@
# pragma once
#endif
namespace boost {
namespace heap {
namespace boost { namespace heap {
#ifndef BOOST_DOXYGEN_INVOKED
BOOST_PARAMETER_TEMPLATE_KEYWORD( allocator )
BOOST_PARAMETER_TEMPLATE_KEYWORD( compare )
namespace tag { struct stable; }
namespace tag {
struct stable;
} // namespace tag
template < bool T >
struct stable:
boost::parameter::template_keyword<tag::stable, boost::integral_constant<bool, T> >
struct stable : boost::parameter::template_keyword< tag::stable, boost::integral_constant< bool, T > >
{};
namespace tag { struct mutable_; }
namespace tag {
struct mutable_;
} // namespace tag
template < bool T >
struct mutable_:
boost::parameter::template_keyword<tag::mutable_, boost::integral_constant<bool, T> >
struct mutable_ : boost::parameter::template_keyword< tag::mutable_, boost::integral_constant< bool, T > >
{};
namespace tag { struct constant_time_size; }
namespace tag {
struct constant_time_size;
} // namespace tag
template < bool T >
struct constant_time_size :
boost::parameter::template_keyword< tag::constant_time_size, boost::integral_constant< bool, T > >
{};
namespace tag { struct store_parent_pointer; }
namespace tag {
struct store_parent_pointer;
} // namespace tag
template < bool T >
struct store_parent_pointer :
boost::parameter::template_keyword< tag::store_parent_pointer, boost::integral_constant< bool, T > >
{};
namespace tag { struct arity; }
namespace tag {
struct arity;
} // namespace tag
template < unsigned int T >
struct arity:
boost::parameter::template_keyword<tag::arity, boost::integral_constant<int, T> >
struct arity : boost::parameter::template_keyword< tag::arity, boost::integral_constant< int, T > >
{};
namespace tag { struct objects_per_page; }
namespace tag {
struct objects_per_page;
} // namespace tag
template < unsigned int T >
struct objects_per_page:
boost::parameter::template_keyword<tag::objects_per_page, boost::integral_constant<int, T> >
struct objects_per_page : boost::parameter::template_keyword< tag::objects_per_page, boost::integral_constant< int, T > >
{};
BOOST_PARAMETER_TEMPLATE_KEYWORD( stability_counter_type )
@@ -89,10 +96,9 @@ struct extract_stable
{
static const bool has_stable = has_arg< bound_args, tag::stable >::value;
typedef typename boost::conditional<has_stable,
typename has_arg<bound_args, tag::stable>::type,
boost::false_type
>::type stable_t;
typedef
typename boost::conditional< has_stable, typename has_arg< bound_args, tag::stable >::type, boost::false_type >::type
stable_t;
static const bool value = stable_t::value;
};
@@ -104,20 +110,20 @@ struct extract_mutable
typedef typename boost::conditional< has_mutable,
typename has_arg< bound_args, tag::mutable_ >::type,
boost::false_type
>::type mutable_t;
boost::false_type >::type mutable_t;
static const bool value = mutable_t::value;
};
}
} // namespace detail
#else
/** \brief Specifies the predicate for the heap order
*/
template < typename T >
struct compare{};
struct compare
{};
/** \brief Configure heap as mutable
*
@@ -125,12 +131,14 @@ struct compare{};
*
* */
template < bool T >
struct mutable_{};
struct mutable_
{};
/** \brief Specifies allocator for the internal memory management
*/
template < typename T >
struct allocator{};
struct allocator
{};
/** \brief Configure a heap as \b stable
*
@@ -138,37 +146,41 @@ struct allocator{};
* they are inserted.
* */
template < bool T >
struct stable{};
struct stable
{};
/** \brief Specifies the type for stability counter
*
* */
template < typename IntType >
struct stability_counter_type{};
struct stability_counter_type
{};
/** \brief Configures complexity of <tt> size() </tt>
*
* Specifies, whether size() should have linear or constant complexity.
* */
template < bool T >
struct constant_time_size{};
struct constant_time_size
{};
/** \brief Store parent pointer in heap node.
*
* Maintaining a parent pointer adds some maintenance and size overhead, but iterating a heap is more efficient.
* */
template < bool T >
struct store_parent_pointer{};
struct store_parent_pointer
{};
/** \brief Specify arity.
*
* Specifies the arity of a D-ary heap
* */
template < unsigned int T >
struct arity{};
struct arity
{};
#endif
} /* namespace heap */
} /* namespace boost */
}} // namespace boost::heap
#endif /* BOOST_HEAP_POLICIES_HPP */
+19 -17
View File
@@ -24,16 +24,15 @@
#endif
namespace boost {
namespace heap {
namespace boost { namespace heap {
namespace detail {
typedef parameter::parameters< boost::parameter::optional< tag::allocator >,
boost::parameter::optional< tag::compare >,
boost::parameter::optional< tag::stable >,
boost::parameter::optional<tag::stability_counter_type>
> priority_queue_signature;
}
boost::parameter::optional< tag::stability_counter_type > >
priority_queue_signature;
} // namespace detail
/**
* \class priority_queue
@@ -57,17 +56,18 @@ template <typename T,
class A0 = boost::parameter::void_,
class A1 = boost::parameter::void_,
class A2 = boost::parameter::void_,
class A3 = boost::parameter::void_
>
class A3 = boost::parameter::void_ >
#endif
class priority_queue :
private detail::make_heap_base< T, typename detail::priority_queue_signature::bind< A0, A1, A2, A3 >::type, false >::type
{
typedef detail::make_heap_base<T, typename detail::priority_queue_signature::bind<A0, A1, A2, A3>::type, false> heap_base_maker;
typedef detail::make_heap_base< T, typename detail::priority_queue_signature::bind< A0, A1, A2, A3 >::type, false >
heap_base_maker;
typedef typename heap_base_maker::type super_t;
typedef typename super_t::internal_type internal_type;
typedef typename boost::allocator_rebind<typename heap_base_maker::allocator_argument, internal_type>::type internal_type_allocator;
typedef typename boost::allocator_rebind< typename heap_base_maker::allocator_argument, internal_type >::type
internal_type_allocator;
typedef std::vector< internal_type, internal_type_allocator > container_type;
template < typename Heap1, typename Heap2 >
@@ -76,8 +76,7 @@ class priority_queue:
container_type q_;
#ifndef BOOST_DOXYGEN_INVOKED
struct implementation_defined:
detail::extract_allocator_types<typename heap_base_maker::allocator_argument>
struct implementation_defined : detail::extract_allocator_types< typename heap_base_maker::allocator_argument >
{
typedef typename heap_base_maker::compare_argument value_compare;
typedef detail::stable_heap_iterator< T, typename container_type::const_iterator, super_t > iterator;
@@ -125,7 +124,8 @@ public:
*
* */
priority_queue( priority_queue const& rhs ) :
super_t(rhs), q_(rhs.q_)
super_t( rhs ),
q_( rhs.q_ )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
@@ -137,7 +137,8 @@ public:
* \b Note: Only available, if BOOST_NO_CXX11_RVALUE_REFERENCES is not defined
* */
priority_queue( priority_queue&& rhs ) BOOST_NOEXCEPT_IF( boost::is_nothrow_move_constructible< super_t >::value ) :
super_t(std::move(rhs)), q_(std::move(rhs.q_))
super_t( std::move( rhs ) ),
q_( std::move( rhs.q_ ) )
{}
/**
@@ -147,7 +148,8 @@ public:
*
* \b Note: Only available, if BOOST_NO_CXX11_RVALUE_REFERENCES is not defined
* */
priority_queue & operator=(priority_queue && rhs) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_assignable<super_t>::value)
priority_queue& operator=( priority_queue&& rhs )
BOOST_NOEXCEPT_IF( boost::is_nothrow_move_assignable< super_t >::value )
{
super_t::operator=( std::move( rhs ) );
q_ = std::move( rhs.q_ );
@@ -281,7 +283,8 @@ public:
* \b Complexity: Constant.
*
* */
void swap(priority_queue & rhs) BOOST_NOEXCEPT_IF(boost::is_nothrow_move_constructible<super_t>::value && boost::is_nothrow_move_assignable<super_t>::value)
void swap( priority_queue& rhs ) BOOST_NOEXCEPT_IF(
boost::is_nothrow_move_constructible< super_t >::value&& boost::is_nothrow_move_assignable< super_t >::value )
{
super_t::swap( rhs );
q_.swap( rhs.q_ );
@@ -404,7 +407,6 @@ public:
}
};
} /* namespace heap */
} /* namespace boost */
}} // namespace boost::heap
#endif /* BOOST_HEAP_PRIORITY_QUEUE_HPP */
+38 -58
View File
@@ -13,8 +13,8 @@
#include <utility>
#include <vector>
#include <boost/assert.hpp>
#include <boost/array.hpp>
#include <boost/assert.hpp>
#include <boost/heap/detail/heap_comparison.hpp>
#include <boost/heap/detail/heap_node.hpp>
@@ -34,8 +34,7 @@
# endif
#endif
namespace boost {
namespace heap {
namespace boost { namespace heap {
namespace detail {
template < typename node_pointer, bool store_parent_pointer >
@@ -73,8 +72,7 @@ struct parent_holder<node_pointer, false>
template < typename value_type, bool store_parent_pointer >
struct skew_heap_node:
parent_holder<skew_heap_node<value_type, store_parent_pointer>*, store_parent_pointer>
struct skew_heap_node : parent_holder< skew_heap_node< value_type, store_parent_pointer >*, store_parent_pointer >
{
typedef parent_holder< skew_heap_node< value_type, store_parent_pointer >*, store_parent_pointer > super_t;
@@ -153,8 +151,8 @@ struct skew_heap_node:
if ( store_parent_pointer )
BOOST_HEAP_ASSERT( child->get_parent() == this );
if (cmp(HeapBase::get_value(value), HeapBase::get_value(child->value)) ||
!child->is_heap<HeapBase>(cmp))
if ( cmp( HeapBase::get_value( value ), HeapBase::get_value( child->value ) )
|| !child->is_heap< HeapBase >( cmp ) )
return false;
}
return true;
@@ -171,33 +169,28 @@ typedef parameter::parameters<boost::parameter::optional<tag::allocator>,
boost::parameter::optional< tag::store_parent_pointer >,
boost::parameter::optional< tag::stability_counter_type >,
boost::parameter::optional< tag::constant_time_size >,
boost::parameter::optional<tag::mutable_>
> skew_heap_signature;
boost::parameter::optional< tag::mutable_ > >
skew_heap_signature;
template < typename T, typename BoundArgs >
struct make_skew_heap_base
{
static const bool constant_time_size = parameter::binding<BoundArgs,
tag::constant_time_size,
boost::true_type
>::type::value;
static const bool constant_time_size
= parameter::binding< BoundArgs, tag::constant_time_size, boost::true_type >::type::value;
typedef typename make_heap_base< T, BoundArgs, constant_time_size >::type base_type;
typedef typename make_heap_base< T, BoundArgs, constant_time_size >::allocator_argument allocator_argument;
typedef typename make_heap_base< T, BoundArgs, constant_time_size >::compare_argument compare_argument;
static const bool is_mutable = extract_mutable< BoundArgs >::value;
static const bool store_parent_pointer = parameter::binding<BoundArgs,
tag::store_parent_pointer,
boost::false_type>::type::value || is_mutable;
static const bool store_parent_pointer
= parameter::binding< BoundArgs, tag::store_parent_pointer, boost::false_type >::type::value || is_mutable;
typedef skew_heap_node< typename base_type::internal_type, store_parent_pointer > node_type;
typedef typename boost::allocator_rebind< allocator_argument, node_type >::type allocator_type;
struct type:
base_type,
allocator_type
struct type : base_type, allocator_type
{
type( compare_argument const& arg ) :
base_type( arg )
@@ -247,8 +240,8 @@ struct make_skew_heap_base
* - \c boost::heap::stability_counter_type<>, defaults to \c stability_counter_type<boost::uintmax_t>
* - \c boost::heap::allocator<>, defaults to \c allocator<std::allocator<T> >
* - \c boost::heap::constant_time_size<>, defaults to \c constant_time_size<true>
* - \c boost::heap::store_parent_pointer<>, defaults to \c store_parent_pointer<true>. Maintaining a parent pointer adds some
* maintenance and size overhead, but iterating a heap is more efficient.
* - \c boost::heap::store_parent_pointer<>, defaults to \c store_parent_pointer<true>. Maintaining a parent pointer
* adds some maintenance and size overhead, but iterating a heap is more efficient.
* - \c boost::heap::mutable<>, defaults to \c mutable<false>.
*
*/
@@ -262,13 +255,10 @@ template <typename T,
class A3 = boost::parameter::void_,
class A4 = boost::parameter::void_,
class A5 = boost::parameter::void_,
class A6 = boost::parameter::void_
>
class A6 = boost::parameter::void_ >
#endif
class skew_heap :
private detail::make_skew_heap_base<T,
typename detail::skew_heap_signature::bind<A0, A1, A2, A3, A4, A5, A6>::type
>::type
private detail::make_skew_heap_base< T, typename detail::skew_heap_signature::bind< A0, A1, A2, A3, A4, A5, A6 >::type >::type
{
typedef typename detail::skew_heap_signature::bind< A0, A1, A2, A3, A4, A5, A6 >::type bound_args;
typedef detail::make_skew_heap_base< T, bound_args > base_maker;
@@ -282,8 +272,7 @@ class skew_heap:
template < typename Heap1, typename Heap2 >
friend struct heap_merge_emulate;
struct implementation_defined:
detail::extract_allocator_types<typename base_maker::allocator_argument>
struct implementation_defined : detail::extract_allocator_types< typename base_maker::allocator_argument >
{
typedef T value_type;
@@ -299,15 +288,13 @@ class skew_heap:
typedef boost::array< node_pointer, 2 > child_list_type;
typedef typename child_list_type::iterator child_list_iterator;
typedef typename boost::conditional<false,
typedef typename boost::conditional<
false,
detail::recursive_tree_iterator< node,
child_list_iterator,
const value_type,
value_extractor,
detail::list_iterator_converter<node,
child_list_type
>
>,
detail::list_iterator_converter< node, child_list_type > >,
detail::tree_iterator< node,
const value_type,
allocator_type,
@@ -315,21 +302,13 @@ class skew_heap:
detail::dereferencer< node >,
true,
false,
value_compare
>
>::type iterator;
value_compare > >::type iterator;
typedef iterator const_iterator;
typedef detail::tree_iterator<node,
const value_type,
allocator_type,
value_extractor,
detail::dereferencer<node>,
true,
true,
value_compare
> ordered_iterator;
typedef detail::
tree_iterator< node, const value_type, allocator_type, value_extractor, detail::dereferencer< node >, true, true, value_compare >
ordered_iterator;
typedef typename detail::extract_allocator_types< typename base_maker::allocator_argument >::reference reference;
typedef detail::node_handle< node_pointer, super_t, reference > handle_type;
@@ -363,16 +342,19 @@ public:
static const bool has_reserve = false;
static const bool is_mutable = detail::extract_mutable< bound_args >::value;
typedef typename boost::conditional<is_mutable, typename implementation_defined::handle_type, void*>::type handle_type;
typedef
typename boost::conditional< is_mutable, typename implementation_defined::handle_type, void* >::type handle_type;
/// \copydoc boost::heap::priority_queue::priority_queue(value_compare const &)
explicit skew_heap( value_compare const& cmp = value_compare() ) :
super_t(cmp), root(NULL)
super_t( cmp ),
root( NULL )
{}
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue const &)
skew_heap( skew_heap const& rhs ) :
super_t(rhs), root(0)
super_t( rhs ),
root( 0 )
{
if ( rhs.empty() )
return;
@@ -395,7 +377,8 @@ public:
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&)
skew_heap( skew_heap&& rhs ) :
super_t(std::move(rhs)), root(rhs.root)
super_t( std::move( rhs ) ),
root( rhs.root )
{
rhs.root = NULL;
}
@@ -570,8 +553,7 @@ public:
rhs.root = NULL;
sanity_check();
super_t::set_stability_count((std::max)(super_t::get_stability_count(),
rhs.get_stability_count()));
super_t::set_stability_count( ( std::max )( super_t::get_stability_count(), rhs.get_stability_count() ) );
rhs.set_stability_count( 0 );
}
@@ -683,8 +665,7 @@ public:
increase( handle );
else
decrease( handle );
}
else
} else
decrease( handle );
}
@@ -747,7 +728,8 @@ public:
*
* \b Complexity: Logarithmic (amortized).
*
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has been updated, the behavior of the data structure is undefined!
* \b Note: The new value is expected to be less than the current one. If this is not called, after a handle has
* been updated, the behavior of the data structure is undefined!
* */
void decrease( handle_type handle )
{
@@ -829,8 +811,7 @@ private:
parent->children[ 0 ] = merged_children;
else
parent->children[ 1 ] = merged_children;
}
else
} else
root = merged_children;
}
@@ -925,8 +906,7 @@ private:
#endif
};
} /* namespace heap */
} /* namespace boost */
}} // namespace boost::heap
#undef BOOST_HEAP_ASSERT
#endif /* BOOST_HEAP_SKEW_HEAP_HPP */
+13 -9
View File
@@ -12,17 +12,19 @@
#include <boost/heap/binomial_heap.hpp>
#include "common_heap_tests.hpp"
#include "stable_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "merge_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "stable_heap_tests.hpp"
template < bool stable, bool constant_time_size >
void run_binomial_heap_test( void )
{
typedef boost::heap::binomial_heap<int, boost::heap::stable<stable>,
typedef boost::heap::binomial_heap< int,
boost::heap::stable< stable >,
boost::heap::compare< std::less< int > >,
boost::heap::allocator< std::allocator< int > >,
boost::heap::constant_time_size<constant_time_size> > pri_queue;
boost::heap::constant_time_size< constant_time_size > >
pri_queue;
BOOST_CONCEPT_ASSERT( (boost::heap::MutablePriorityQueue< pri_queue >));
BOOST_CONCEPT_ASSERT( (boost::heap::MergablePriorityQueue< pri_queue >));
@@ -38,8 +40,10 @@ void run_binomial_heap_test(void)
run_ordered_iterator_tests< pri_queue >();
if ( stable ) {
typedef boost::heap::binomial_heap<q_tester, boost::heap::stable<stable>,
boost::heap::constant_time_size<constant_time_size> > stable_pri_queue;
typedef boost::heap::binomial_heap< q_tester,
boost::heap::stable< stable >,
boost::heap::constant_time_size< constant_time_size > >
stable_pri_queue;
run_stable_heap_tests< stable_pri_queue >();
}
@@ -57,9 +61,9 @@ BOOST_AUTO_TEST_CASE( binomial_heap_test )
BOOST_AUTO_TEST_CASE( binomial_heap_compare_lookup_test )
{
typedef boost::heap::binomial_heap<int,
boost::heap::compare<less_with_T>,
boost::heap::allocator<std::allocator<int> > > pri_queue;
typedef boost::heap::
binomial_heap< int, boost::heap::compare< less_with_T >, boost::heap::allocator< std::allocator< int > > >
pri_queue;
run_common_heap_tests< pri_queue >();
}
+31 -40
View File
@@ -43,10 +43,8 @@ using std::random_shuffle;
#endif
typedef boost::default_constructible_archetype<
boost::less_than_comparable_archetype<
boost::copy_constructible_archetype<
boost::assignable_archetype<
> > > > test_value_type;
boost::less_than_comparable_archetype< boost::copy_constructible_archetype< boost::assignable_archetype<> > > >
test_value_type;
typedef std::vector< int > test_data;
@@ -74,8 +72,7 @@ void check_q(pri_queue & q, data_container const & expected)
{
BOOST_REQUIRE_EQUAL( q.size(), expected.size() );
for (unsigned int i = 0; i != expected.size(); ++i)
{
for ( unsigned int i = 0; i != expected.size(); ++i ) {
BOOST_REQUIRE_EQUAL( q.size(), expected.size() - i );
BOOST_REQUIRE_EQUAL( q.top(), expected[ expected.size() - 1 - i ] );
q.pop();
@@ -106,8 +103,7 @@ void fill_emplace_q(pri_queue & q, data_container const & data)
template < typename pri_queue >
void pri_queue_test_sequential_push( void )
{
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( i );
fill_q( q, data );
@@ -118,8 +114,7 @@ void pri_queue_test_sequential_push(void)
template < typename pri_queue >
void pri_queue_test_sequential_reverse_push( void )
{
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( i );
std::reverse( data.begin(), data.end() );
@@ -133,8 +128,7 @@ template <typename pri_queue>
void pri_queue_test_emplace( void )
{
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( i );
std::reverse( data.begin(), data.end() );
@@ -149,8 +143,7 @@ void pri_queue_test_emplace(void)
template < typename pri_queue >
void pri_queue_test_random_push( void )
{
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( i );
@@ -166,8 +159,7 @@ void pri_queue_test_random_push(void)
template < typename pri_queue >
void pri_queue_test_copyconstructor( void )
{
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( i );
fill_q( q, data );
@@ -181,8 +173,7 @@ void pri_queue_test_copyconstructor(void)
template < typename pri_queue >
void pri_queue_test_assignment( void )
{
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( i );
fill_q( q, data );
@@ -229,8 +220,7 @@ void pri_queue_test_move_assignment(void)
template < typename pri_queue >
void pri_queue_test_swap( void )
{
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( i );
test_data shuffled( data );
@@ -307,8 +297,7 @@ void pri_queue_test_ordered_iterators(void)
template < typename pri_queue >
void pri_queue_test_equality( void )
{
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q, r;
test_data data = make_test_data( i );
fill_q( q, data );
@@ -322,8 +311,7 @@ void pri_queue_test_equality(void)
template < typename pri_queue >
void pri_queue_test_inequality( void )
{
for (int i = 1; i != test_size; ++i)
{
for ( int i = 1; i != test_size; ++i ) {
pri_queue q, r;
test_data data = make_test_data( i );
fill_q( q, data );
@@ -337,8 +325,7 @@ void pri_queue_test_inequality(void)
template < typename pri_queue >
void pri_queue_test_less( void )
{
for (int i = 1; i != test_size; ++i)
{
for ( int i = 1; i != test_size; ++i ) {
pri_queue q, r;
test_data data = make_test_data( i );
test_data r_data( data );
@@ -350,8 +337,7 @@ void pri_queue_test_less(void)
BOOST_REQUIRE( r < q );
}
for (int i = 1; i != test_size; ++i)
{
for ( int i = 1; i != test_size; ++i ) {
pri_queue q, r;
test_data data = make_test_data( i );
test_data r_data( data );
@@ -363,8 +349,7 @@ void pri_queue_test_less(void)
BOOST_REQUIRE( r < q );
}
for (int i = 1; i != test_size; ++i)
{
for ( int i = 1; i != test_size; ++i ) {
pri_queue q, r;
test_data data = make_test_data( i );
test_data r_data( data );
@@ -377,8 +362,7 @@ void pri_queue_test_less(void)
BOOST_REQUIRE( r < q );
}
for (int i = 1; i != test_size; ++i)
{
for ( int i = 1; i != test_size; ++i ) {
pri_queue q, r;
test_data data = make_test_data( i );
test_data r_data( data );
@@ -390,14 +374,12 @@ void pri_queue_test_less(void)
BOOST_REQUIRE( r < q );
}
}
template < typename pri_queue >
void pri_queue_test_clear( void )
{
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( i );
fill_q( q, data );
@@ -484,21 +466,30 @@ struct less_with_T
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
class thing {
class thing
{
public:
thing( int a_, int b_, int c_ ) : a(a_), b(b_), c(c_) {}
thing( int a_, int b_, int c_ ) :
a( a_ ),
b( b_ ),
c( c_ )
{}
public:
int a;
int b;
int c;
};
class cmpthings {
class cmpthings
{
public:
bool operator() ( const thing& lhs, const thing& rhs ) const {
bool operator()( const thing& lhs, const thing& rhs ) const
{
return lhs.a > rhs.a;
}
bool operator() ( const thing& lhs, const thing& rhs ) {
bool operator()( const thing& lhs, const thing& rhs )
{
return lhs.a > rhs.a;
}
};
+18 -18
View File
@@ -18,18 +18,20 @@
#include <boost/heap/d_ary_heap.hpp>
#include "common_heap_tests.hpp"
#include "stable_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "merge_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "stable_heap_tests.hpp"
template < int D, bool stable >
void run_d_ary_heap_test( void )
{
typedef boost::heap::d_ary_heap<int, boost::heap::arity<D>,
typedef boost::heap::d_ary_heap< int,
boost::heap::arity< D >,
boost::heap::stable< stable >,
boost::heap::compare< std::less< int > >,
boost::heap::allocator<std::allocator<int> > > pri_queue;
boost::heap::allocator< std::allocator< int > > >
pri_queue;
BOOST_CONCEPT_ASSERT( (boost::heap::PriorityQueue< pri_queue >));
@@ -44,16 +46,15 @@ void run_d_ary_heap_test(void)
run_ordered_iterator_tests< pri_queue >();
if ( stable ) {
typedef boost::heap::d_ary_heap<q_tester, boost::heap::arity<D>,
boost::heap::stable<stable>
> stable_pri_queue;
typedef boost::heap::d_ary_heap< q_tester, boost::heap::arity< D >, boost::heap::stable< stable > > stable_pri_queue;
run_stable_heap_tests< stable_pri_queue >();
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
cmpthings ord;
boost::heap::d_ary_heap<thing, boost::heap::arity<D>, boost::heap::compare<cmpthings>, boost::heap::stable<stable> > vpq(ord);
boost::heap::d_ary_heap< thing, boost::heap::arity< D >, boost::heap::compare< cmpthings >, boost::heap::stable< stable > >
vpq( ord );
vpq.emplace( 5, 6, 7 );
#endif
}
@@ -78,10 +79,8 @@ BOOST_AUTO_TEST_CASE( d_ary_heap_stable_test )
template < int D, bool stable >
void run_d_ary_heap_mutable_test( void )
{
typedef boost::heap::d_ary_heap<int, boost::heap::mutable_<true>,
boost::heap::arity<D>,
boost::heap::stable<stable>
> pri_queue;
typedef boost::heap::d_ary_heap< int, boost::heap::mutable_< true >, boost::heap::arity< D >, boost::heap::stable< stable > >
pri_queue;
BOOST_CONCEPT_ASSERT( (boost::heap::MutablePriorityQueue< pri_queue >));
@@ -95,10 +94,9 @@ void run_d_ary_heap_mutable_test(void)
run_ordered_iterator_tests< pri_queue >();
if ( stable ) {
typedef boost::heap::d_ary_heap<q_tester, boost::heap::mutable_<true>,
boost::heap::arity<D>,
boost::heap::stable<stable>
> stable_pri_queue;
typedef boost::heap::
d_ary_heap< q_tester, boost::heap::mutable_< true >, boost::heap::arity< D >, boost::heap::stable< stable > >
stable_pri_queue;
run_stable_heap_tests< stable_pri_queue >();
}
}
@@ -121,9 +119,11 @@ BOOST_AUTO_TEST_CASE( d_ary_heap_mutable_stable_test )
BOOST_AUTO_TEST_CASE( d_ary_heap_compare_lookup_test )
{
typedef boost::heap::d_ary_heap<int, boost::heap::arity<2>,
typedef boost::heap::d_ary_heap< int,
boost::heap::arity< 2 >,
boost::heap::compare< less_with_T >,
boost::heap::allocator<std::allocator<int> > > pri_queue;
boost::heap::allocator< std::allocator< int > > >
pri_queue;
run_common_heap_tests< pri_queue >();
}
+13 -11
View File
@@ -14,19 +14,20 @@
#include <boost/heap/fibonacci_heap.hpp>
#include "common_heap_tests.hpp"
#include "stable_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "merge_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "stable_heap_tests.hpp"
template < bool stable, bool constant_time_size >
void run_fibonacci_heap_test( void )
{
typedef boost::heap::fibonacci_heap<int, boost::heap::stable<stable>,
typedef boost::heap::fibonacci_heap< int,
boost::heap::stable< stable >,
boost::heap::compare< std::less< int > >,
boost::heap::allocator< std::allocator< int > >,
boost::heap::constant_time_size<constant_time_size>
> pri_queue;
boost::heap::constant_time_size< constant_time_size > >
pri_queue;
BOOST_CONCEPT_ASSERT( (boost::heap::MutablePriorityQueue< pri_queue >));
BOOST_CONCEPT_ASSERT( (boost::heap::MergablePriorityQueue< pri_queue >));
@@ -42,9 +43,10 @@ void run_fibonacci_heap_test(void)
run_ordered_iterator_tests< pri_queue >();
if ( stable ) {
typedef boost::heap::fibonacci_heap<q_tester, boost::heap::stable<stable>,
boost::heap::constant_time_size<constant_time_size>
> stable_pri_queue;
typedef boost::heap::fibonacci_heap< q_tester,
boost::heap::stable< stable >,
boost::heap::constant_time_size< constant_time_size > >
stable_pri_queue;
run_stable_heap_tests< stable_pri_queue >();
}
}
@@ -62,9 +64,9 @@ BOOST_AUTO_TEST_CASE( fibonacci_heap_test )
BOOST_AUTO_TEST_CASE( fibonacci_heap_compare_lookup_test )
{
typedef boost::heap::fibonacci_heap<int,
boost::heap::compare<less_with_T>,
boost::heap::allocator<std::allocator<int> > > pri_queue;
typedef boost::heap::
fibonacci_heap< int, boost::heap::compare< less_with_T >, boost::heap::allocator< std::allocator< int > > >
pri_queue;
run_common_heap_tests< pri_queue >();
}
+1 -5
View File
@@ -62,14 +62,10 @@ struct pri_queue_test_heap_merge
};
template < typename pri_queue >
void run_merge_tests( void )
{
boost::conditional<pri_queue::is_mergable,
pri_queue_test_merge<pri_queue>,
dummy_run
>::type::run();
boost::conditional< pri_queue::is_mergable, pri_queue_test_merge< pri_queue >, dummy_run >::type::run();
pri_queue_test_heap_merge< pri_queue, pri_queue >::run();
}
+16 -6
View File
@@ -9,10 +9,10 @@
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/heap/binomial_heap.hpp>
#include <boost/heap/d_ary_heap.hpp>
#include <boost/heap/fibonacci_heap.hpp>
#include <boost/heap/pairing_heap.hpp>
#include <boost/heap/binomial_heap.hpp>
#include <boost/heap/skew_heap.hpp>
using namespace boost::heap;
@@ -44,7 +44,9 @@ struct fibonacci_heap_data
handle_type handle;
int i;
fibonacci_heap_data(int i):i(i) {}
fibonacci_heap_data( int i ) :
i( i )
{}
bool operator<( fibonacci_heap_data const& rhs ) const
{
@@ -64,7 +66,9 @@ struct d_heap_data
handle_type handle;
int i;
d_heap_data(int i):i(i) {}
d_heap_data( int i ) :
i( i )
{}
bool operator<( d_heap_data const& rhs ) const
{
@@ -85,7 +89,9 @@ struct pairing_heap_data
handle_type handle;
int i;
pairing_heap_data(int i):i(i) {}
pairing_heap_data( int i ) :
i( i )
{}
bool operator<( pairing_heap_data const& rhs ) const
{
@@ -107,7 +113,9 @@ struct binomial_heap_data
handle_type handle;
int i;
binomial_heap_data(int i):i(i) {}
binomial_heap_data( int i ) :
i( i )
{}
bool operator<( binomial_heap_data const& rhs ) const
{
@@ -128,7 +136,9 @@ struct skew_heap_data
handle_type handle;
int i;
skew_heap_data(int i):i(i) {}
skew_heap_data( int i ) :
i( i )
{}
bool operator<( skew_heap_data const& rhs ) const
{
+3 -7
View File
@@ -25,7 +25,6 @@
HANDLES.push_back( Q.push( DATA[ k ] ) );
template < typename pri_queue >
void pri_queue_test_update_decrease( void )
{
@@ -226,14 +225,12 @@ void pri_queue_test_erase(void)
boost::mt19937 rng;
#endif
for (int i = 0; i != test_size; ++i)
{
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( test_size );
PUSH_WITH_HANDLES( handles, q, data );
for (int j = 0; j != i; ++j)
{
for ( int j = 0; j != i; ++j ) {
#ifdef USE_BOOST_RANDOM
boost::uniform_int<> range( 0, data.size() - 1 );
boost::variate_generator< boost::mt19937&, boost::uniform_int<> > gen( rng, range );
@@ -302,8 +299,7 @@ void run_mutable_heap_test_handle_from_iterator(void)
que.push( 1 );
que.push( 4 );
que.update(pri_queue::s_handle_from_iterator(que.begin()),
6);
que.update( pri_queue::s_handle_from_iterator( que.begin() ), 6 );
}
+13 -10
View File
@@ -14,17 +14,19 @@
#include <boost/heap/pairing_heap.hpp>
#include "common_heap_tests.hpp"
#include "stable_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "merge_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "stable_heap_tests.hpp"
template < bool stable, bool constant_time_size >
void run_pairing_heap_test( void )
{
typedef boost::heap::pairing_heap<int, boost::heap::stable<stable>,
typedef boost::heap::pairing_heap< int,
boost::heap::stable< stable >,
boost::heap::compare< std::less< int > >,
boost::heap::allocator< std::allocator< int > >,
boost::heap::constant_time_size<constant_time_size> > pri_queue;
boost::heap::constant_time_size< constant_time_size > >
pri_queue;
BOOST_CONCEPT_ASSERT( (boost::heap::MutablePriorityQueue< pri_queue >));
BOOST_CONCEPT_ASSERT( (boost::heap::MergablePriorityQueue< pri_queue >));
@@ -41,9 +43,10 @@ void run_pairing_heap_test(void)
run_ordered_iterator_tests< pri_queue >();
if ( stable ) {
typedef boost::heap::pairing_heap<q_tester, boost::heap::stable<stable>,
boost::heap::constant_time_size<constant_time_size>
> stable_pri_queue;
typedef boost::heap::pairing_heap< q_tester,
boost::heap::stable< stable >,
boost::heap::constant_time_size< constant_time_size > >
stable_pri_queue;
run_stable_heap_tests< stable_pri_queue >();
}
}
@@ -60,9 +63,9 @@ BOOST_AUTO_TEST_CASE( pairing_heap_test )
BOOST_AUTO_TEST_CASE( pairing_heap_compare_lookup_test )
{
typedef boost::heap::pairing_heap<int,
boost::heap::compare<less_with_T>,
boost::heap::allocator<std::allocator<int> > > pri_queue;
typedef boost::heap::
pairing_heap< int, boost::heap::compare< less_with_T >, boost::heap::allocator< std::allocator< int > > >
pri_queue;
run_common_heap_tests< pri_queue >();
}
+1 -1
View File
@@ -12,8 +12,8 @@
#include <boost/heap/priority_queue.hpp>
#include "common_heap_tests.hpp"
#include "stable_heap_tests.hpp"
#include "merge_heap_tests.hpp"
#include "stable_heap_tests.hpp"
template < bool stable >
void run_common_priority_queue_tests( void )
+2 -1
View File
@@ -9,7 +9,8 @@
* \author Andrey Semashev
* \date 28.10.2018
*
* \brief This file contains a test boilerplate for checking that every public header is self-contained and does not have any missing #includes.
* \brief This file contains a test boilerplate for checking that every public header is self-contained and does not
* have any missing #includes.
*/
#define BOOST_HEAP_TEST_INCLUDE_HEADER() <boost/heap/BOOST_HEAP_TEST_HEADER>
+22 -17
View File
@@ -14,19 +14,20 @@
#include <boost/heap/skew_heap.hpp>
#include "common_heap_tests.hpp"
#include "stable_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "merge_heap_tests.hpp"
#include "mutable_heap_tests.hpp"
#include "stable_heap_tests.hpp"
template < bool stable, bool constant_time_size, bool store_parent_pointer >
void run_skew_heap_test( void )
{
typedef boost::heap::skew_heap<int, boost::heap::stable<stable>,
typedef boost::heap::skew_heap< int,
boost::heap::stable< stable >,
boost::heap::compare< std::less< int > >,
boost::heap::allocator< std::allocator< int > >,
boost::heap::constant_time_size< constant_time_size >,
boost::heap::store_parent_pointer<store_parent_pointer>
> pri_queue;
boost::heap::store_parent_pointer< store_parent_pointer > >
pri_queue;
BOOST_CONCEPT_ASSERT( (boost::heap::PriorityQueue< pri_queue >));
BOOST_CONCEPT_ASSERT( (boost::heap::MergablePriorityQueue< pri_queue >));
@@ -41,10 +42,11 @@ void run_skew_heap_test(void)
pri_queue_test_ordered_iterators< pri_queue >();
if ( stable ) {
typedef boost::heap::skew_heap<q_tester, boost::heap::stable<stable>,
typedef boost::heap::skew_heap< q_tester,
boost::heap::stable< stable >,
boost::heap::constant_time_size< constant_time_size >,
boost::heap::store_parent_pointer<store_parent_pointer>
> stable_pri_queue;
boost::heap::store_parent_pointer< store_parent_pointer > >
stable_pri_queue;
run_stable_heap_tests< stable_pri_queue >();
}
}
@@ -52,11 +54,13 @@ void run_skew_heap_test(void)
template < bool stable, bool constant_time_size >
void run_skew_heap_mutable_test( void )
{
typedef boost::heap::skew_heap<int, boost::heap::stable<stable>, boost::heap::mutable_<true>,
typedef boost::heap::skew_heap< int,
boost::heap::stable< stable >,
boost::heap::mutable_< true >,
boost::heap::compare< std::less< int > >,
boost::heap::allocator< std::allocator< int > >,
boost::heap::constant_time_size<constant_time_size>
> pri_queue;
boost::heap::constant_time_size< constant_time_size > >
pri_queue;
BOOST_CONCEPT_ASSERT( (boost::heap::MutablePriorityQueue< pri_queue >));
BOOST_CONCEPT_ASSERT( (boost::heap::MergablePriorityQueue< pri_queue >));
@@ -73,9 +77,11 @@ void run_skew_heap_mutable_test(void)
run_ordered_iterator_tests< pri_queue >();
if ( stable ) {
typedef boost::heap::skew_heap<q_tester, boost::heap::stable<stable>, boost::heap::mutable_<true>,
boost::heap::constant_time_size<constant_time_size>
> stable_pri_queue;
typedef boost::heap::skew_heap< q_tester,
boost::heap::stable< stable >,
boost::heap::mutable_< true >,
boost::heap::constant_time_size< constant_time_size > >
stable_pri_queue;
run_stable_heap_tests< stable_pri_queue >();
}
}
@@ -106,9 +112,8 @@ BOOST_AUTO_TEST_CASE( skew_heap_mutable_test )
BOOST_AUTO_TEST_CASE( skew_heap_compare_lookup_test )
{
typedef boost::heap::skew_heap<int,
boost::heap::compare<less_with_T>,
boost::heap::allocator<std::allocator<int> > > pri_queue;
typedef boost::heap::skew_heap< int, boost::heap::compare< less_with_T >, boost::heap::allocator< std::allocator< int > > >
pri_queue;
run_common_heap_tests< pri_queue >();
}
+4 -4
View File
@@ -6,13 +6,14 @@
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/foreach.hpp>
#include "common_heap_tests.hpp"
#include <boost/foreach.hpp>
struct q_tester
{
q_tester( int i = 0, int j = 0 ) :
value(i), id(j)
value( i ),
id( j )
{}
bool operator<( q_tester const& rhs ) const
@@ -42,8 +43,7 @@ std::ostream& operator<< (std::ostream& out, q_tester const & t)
typedef std::vector< q_tester > stable_test_data;
stable_test_data make_stable_test_data(int size, int same_count = 3,
int offset = 0, int strive = 1)
stable_test_data make_stable_test_data( int size, int same_count = 3, int offset = 0, int strive = 1 )
{
stable_test_data ret;
+9 -9
View File
@@ -9,8 +9,8 @@
#include <algorithm>
#include <vector>
#include <boost/foreach.hpp>
#include "high_resolution_timer.hpp"
#include <boost/foreach.hpp>
#include <boost/heap/heap_merge.hpp>
@@ -56,7 +56,8 @@ test_data const & get_data(int index)
struct make_##SUFFIX \
{ \
template < typename heap > \
struct rebind { \
struct rebind \
{ \
typedef run_##SUFFIX< heap > type; \
}; \
};
@@ -75,9 +76,7 @@ void fill_heap(pri_queue & q, int index, int size, int offset = 0)
}
}
template <typename pri_queue,
typename handle_container
>
template < typename pri_queue, typename handle_container >
void fill_heap_with_handles( pri_queue& q, handle_container& handles, int index, int size, int offset = 0 )
{
test_data const& data = get_data( index );
@@ -151,7 +150,8 @@ template <typename pri_queue>
struct run_sequential_increase
{
run_sequential_increase( int size ) :
size(size), handles(size)
size( size ),
handles( size )
{}
void prepare( int index )
@@ -178,7 +178,8 @@ template <typename pri_queue>
struct run_sequential_decrease
{
run_sequential_decrease( int size ) :
size(size), handles(size)
size( size ),
handles( size )
{}
void prepare( int index )
@@ -264,8 +265,7 @@ inline double run_benchmark(benchmark & b)
boost::high_resolution_timer timer;
std::vector< double > results;
for (int i = 0; i != num_benchmarks; ++i)
{
for ( int i = 0; i != num_benchmarks; ++i ) {
b.prepare( i );
timer.restart();
b( i );
+7 -9
View File
@@ -16,8 +16,8 @@
# include "time.h"
#include <stdexcept>
# include <limits>
# include <stdexcept>
namespace boost {
@@ -51,8 +51,7 @@ public:
double ret_sec = double( now.tv_sec - start_time.tv_sec );
double ret_nsec = double( now.tv_nsec - start_time.tv_nsec );
while (ret_nsec < 0)
{
while ( ret_nsec < 0 ) {
ret_sec -= 1.0;
ret_nsec += 1e9;
}
@@ -132,8 +131,8 @@ private:
# elif defined( BOOST_WINDOWS )
#include <stdexcept>
# include <limits>
# include <stdexcept>
# include <windows.h>
namespace boost {
@@ -176,8 +175,8 @@ public:
double elapsed_max() const // return estimated maximum value for elapsed()
{
return (double((std::numeric_limits<LONGLONG>::max)())
- double(start_time.QuadPart)) / double(frequency.QuadPart);
return ( double( ( std::numeric_limits< LONGLONG >::max )() ) - double( start_time.QuadPart ) )
/ double( frequency.QuadPart );
}
double elapsed_min() const // return minimum value for elapsed()
@@ -195,14 +194,13 @@ private:
# else
// For other platforms, simply fall back to boost::timer
#include <boost/timer.hpp>
# include <boost/throw_exception.hpp>
# include <boost/timer.hpp>
namespace boost {
typedef boost::timer high_resolution_timer;
}
} // namespace boost
# endif
#endif // !defined(BOOST_HIGH_RESOLUTION_TIMER_HPP)
+48 -62
View File
@@ -6,14 +6,14 @@
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <iostream>
#include <iomanip>
#include <iostream>
#include "../../../boost/heap/d_ary_heap.hpp"
#include "../../../boost/heap/pairing_heap.hpp"
#include "../../../boost/heap/fibonacci_heap.hpp"
#include "../../../boost/heap/binomial_heap.hpp"
#include "../../../boost/heap/d_ary_heap.hpp"
#include "../../../boost/heap/fibonacci_heap.hpp"
#include "../../../boost/heap/pairing_heap.hpp"
#include "../../../boost/heap/skew_heap.hpp"
#include "heap_benchmarks.hpp"
@@ -37,99 +37,91 @@ void run_benchmarks_immutable(void)
cout << size << "\t";
{
typedef typename benchmark_selector::
template rebind<boost::heap::d_ary_heap<long, boost::heap::arity<2> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::d_ary_heap< long, boost::heap::arity< 2 > > >::type benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::d_ary_heap<long, boost::heap::arity<2>, boost::heap::mutable_<true> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::d_ary_heap< long, boost::heap::arity< 2 >, boost::heap::mutable_< true > > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::d_ary_heap<long, boost::heap::arity<4> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::d_ary_heap< long, boost::heap::arity< 4 > > >::type benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::d_ary_heap<long, boost::heap::arity<4>, boost::heap::mutable_<true> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::d_ary_heap< long, boost::heap::arity< 4 >, boost::heap::mutable_< true > > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::d_ary_heap<long, boost::heap::arity<8> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::d_ary_heap< long, boost::heap::arity< 8 > > >::type benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::d_ary_heap<long, boost::heap::arity<8>, boost::heap::mutable_<true> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::d_ary_heap< long, boost::heap::arity< 8 >, boost::heap::mutable_< true > > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::binomial_heap<long> >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind< boost::heap::binomial_heap< long > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::fibonacci_heap<long> >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind< boost::heap::fibonacci_heap< long > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::pairing_heap<long> >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind< boost::heap::pairing_heap< long > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::skew_heap<long> >
::type benchmark_functor;
typedef
typename benchmark_selector::template rebind< boost::heap::skew_heap< long > >::type benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::skew_heap<long> >
::type benchmark_functor;
typedef
typename benchmark_selector::template rebind< boost::heap::skew_heap< long > >::type benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
@@ -142,10 +134,8 @@ void run_benchmarks_immutable(void)
template < typename benchmark_selector >
void run_benchmarks_mutable( void )
{
for (int i = 4; i != max_data; ++i)
{
for (int j = 0; j != 8; ++j)
{
for ( int i = 4; i != max_data; ++i ) {
for ( int j = 0; j != 8; ++j ) {
int size = 1 << i;
if ( j % 4 == 1 )
size += 1 << ( i - 3 );
@@ -158,63 +148,59 @@ void run_benchmarks_mutable(void)
cout << size << "\t";
{
typedef typename benchmark_selector::
template rebind<boost::heap::d_ary_heap<long, boost::heap::arity<2>, boost::heap::mutable_<true> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::d_ary_heap< long, boost::heap::arity< 2 >, boost::heap::mutable_< true > > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::d_ary_heap<long, boost::heap::arity<4>, boost::heap::mutable_<true> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::d_ary_heap< long, boost::heap::arity< 4 >, boost::heap::mutable_< true > > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::d_ary_heap<long, boost::heap::arity<8>, boost::heap::mutable_<true> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::d_ary_heap< long, boost::heap::arity< 8 >, boost::heap::mutable_< true > > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::binomial_heap<long> >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind< boost::heap::binomial_heap< long > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::fibonacci_heap<long> >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind< boost::heap::fibonacci_heap< long > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::pairing_heap<long> >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind< boost::heap::pairing_heap< long > >::type
benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';
}
{
typedef typename benchmark_selector::
template rebind<boost::heap::skew_heap<long, boost::heap::mutable_<true> > >
::type benchmark_functor;
typedef typename benchmark_selector::template rebind<
boost::heap::skew_heap< long, boost::heap::mutable_< true > > >::type benchmark_functor;
benchmark_functor benchmark( size );
double result = run_benchmark( benchmark );
cout << result << '\t';