3 // Copyright (C) 2010-2011 Tim Blechmann
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_HEAP_POLICIES_HPP
10 #define BOOST_HEAP_POLICIES_HPP
12 #include <boost/concept_check.hpp>
13 #include <boost/parameter/name.hpp>
14 #include <boost/parameter/template_keyword.hpp>
15 #include <boost/parameter/aux_/void.hpp>
16 #include <boost/parameter/binding.hpp>
17 #include <boost/parameter/parameters.hpp>
18 #include <boost/type_traits/conditional.hpp>
19 #include <boost/type_traits/integral_constant.hpp>
20 #include <boost/type_traits/is_void.hpp>
22 #ifdef BOOST_HAS_PRAGMA_ONCE
29 #ifndef BOOST_DOXYGEN_INVOKED
30 BOOST_PARAMETER_TEMPLATE_KEYWORD(allocator)
31 BOOST_PARAMETER_TEMPLATE_KEYWORD(compare)
33 namespace tag { struct stable; }
37 boost::parameter::template_keyword<tag::stable, boost::integral_constant<bool, T> >
40 namespace tag { struct mutable_; }
44 boost::parameter::template_keyword<tag::mutable_, boost::integral_constant<bool, T> >
48 namespace tag { struct constant_time_size; }
51 struct constant_time_size:
52 boost::parameter::template_keyword<tag::constant_time_size, boost::integral_constant<bool, T> >
55 namespace tag { struct store_parent_pointer; }
58 struct store_parent_pointer:
59 boost::parameter::template_keyword<tag::store_parent_pointer, boost::integral_constant<bool, T> >
62 namespace tag { struct arity; }
64 template <unsigned int T>
66 boost::parameter::template_keyword<tag::arity, boost::integral_constant<int, T> >
69 namespace tag { struct objects_per_page; }
71 template <unsigned int T>
72 struct objects_per_page:
73 boost::parameter::template_keyword<tag::objects_per_page, boost::integral_constant<int, T> >
76 BOOST_PARAMETER_TEMPLATE_KEYWORD(stability_counter_type)
80 template <typename bound_args, typename tag_type>
83 typedef typename boost::parameter::binding<bound_args, tag_type, void>::type type;
84 static const bool value = !boost::is_void<type>::value;
87 template <typename bound_args>
90 static const bool has_stable = has_arg<bound_args, tag::stable>::value;
92 typedef typename boost::conditional<has_stable,
93 typename has_arg<bound_args, tag::stable>::type,
97 static const bool value = stable_t::value;
100 template <typename bound_args>
101 struct extract_mutable
103 static const bool has_mutable = has_arg<bound_args, tag::mutable_>::value;
105 typedef typename boost::conditional<has_mutable,
106 typename has_arg<bound_args, tag::mutable_>::type,
110 static const bool value = mutable_t::value;
117 /** \brief Specifies the predicate for the heap order
119 template <typename T>
122 /** \brief Configure heap as mutable
124 * Certain heaps need to be configured specifically do be mutable.
130 /** \brief Specifies allocator for the internal memory management
132 template <typename T>
135 /** \brief Configure a heap as \b stable
137 * A priority queue is stable, if elements with the same priority are popped from the heap, in the same order as
143 /** \brief Specifies the type for stability counter
146 template <typename IntType>
147 struct stability_counter_type{};
149 /** \brief Configures complexity of <tt> size() </tt>
151 * Specifies, whether size() should have linear or constant complexity.
154 struct constant_time_size{};
156 /** \brief Store parent pointer in heap node.
158 * Maintaining a parent pointer adds some maintenance and size overhead, but iterating a heap is more efficient.
161 struct store_parent_pointer{};
163 /** \brief Specify arity.
165 * Specifies the arity of a D-ary heap
167 template <unsigned int T>
171 } /* namespace heap */
172 } /* namespace boost */
174 #endif /* BOOST_HEAP_POLICIES_HPP */