Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/heap/policies.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // boost heap | |
2 // | |
3 // Copyright (C) 2010-2011 Tim Blechmann | |
4 // | |
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) | |
8 | |
9 #ifndef BOOST_HEAP_POLICIES_HPP | |
10 #define BOOST_HEAP_POLICIES_HPP | |
11 | |
12 #include <boost/parameter.hpp> | |
13 #include <boost/mpl/bool.hpp> | |
14 #include <boost/mpl/int.hpp> | |
15 #include <boost/mpl/void.hpp> | |
16 #include <boost/concept_check.hpp> | |
17 | |
18 | |
19 namespace boost { | |
20 namespace heap { | |
21 | |
22 #ifndef BOOST_DOXYGEN_INVOKED | |
23 BOOST_PARAMETER_TEMPLATE_KEYWORD(allocator) | |
24 BOOST_PARAMETER_TEMPLATE_KEYWORD(compare) | |
25 | |
26 namespace tag { struct stable; } | |
27 | |
28 template <bool T> | |
29 struct stable: | |
30 boost::parameter::template_keyword<tag::stable, boost::mpl::bool_<T> > | |
31 {}; | |
32 | |
33 namespace tag { struct mutable_; } | |
34 | |
35 template <bool T> | |
36 struct mutable_: | |
37 boost::parameter::template_keyword<tag::mutable_, boost::mpl::bool_<T> > | |
38 {}; | |
39 | |
40 | |
41 namespace tag { struct constant_time_size; } | |
42 | |
43 template <bool T> | |
44 struct constant_time_size: | |
45 boost::parameter::template_keyword<tag::constant_time_size, boost::mpl::bool_<T> > | |
46 {}; | |
47 | |
48 namespace tag { struct store_parent_pointer; } | |
49 | |
50 template <bool T> | |
51 struct store_parent_pointer: | |
52 boost::parameter::template_keyword<tag::store_parent_pointer, boost::mpl::bool_<T> > | |
53 {}; | |
54 | |
55 namespace tag { struct arity; } | |
56 | |
57 template <unsigned int T> | |
58 struct arity: | |
59 boost::parameter::template_keyword<tag::arity, boost::mpl::int_<T> > | |
60 {}; | |
61 | |
62 namespace tag { struct objects_per_page; } | |
63 | |
64 template <unsigned int T> | |
65 struct objects_per_page: | |
66 boost::parameter::template_keyword<tag::objects_per_page, boost::mpl::int_<T> > | |
67 {}; | |
68 | |
69 BOOST_PARAMETER_TEMPLATE_KEYWORD(stability_counter_type) | |
70 | |
71 namespace detail { | |
72 | |
73 namespace mpl = boost::mpl; | |
74 | |
75 template <typename bound_args, typename tag_type> | |
76 struct has_arg | |
77 { | |
78 typedef typename boost::parameter::binding<bound_args, tag_type, mpl::void_>::type type; | |
79 static const bool value = mpl::is_not_void_<type>::type::value; | |
80 }; | |
81 | |
82 template <typename bound_args> | |
83 struct extract_stable | |
84 { | |
85 static const bool has_stable = has_arg<bound_args, tag::stable>::value; | |
86 | |
87 typedef typename mpl::if_c<has_stable, | |
88 typename has_arg<bound_args, tag::stable>::type, | |
89 mpl::bool_<false> | |
90 >::type stable_t; | |
91 | |
92 static const bool value = stable_t::value; | |
93 }; | |
94 | |
95 template <typename bound_args> | |
96 struct extract_mutable | |
97 { | |
98 static const bool has_mutable = has_arg<bound_args, tag::mutable_>::value; | |
99 | |
100 typedef typename mpl::if_c<has_mutable, | |
101 typename has_arg<bound_args, tag::mutable_>::type, | |
102 mpl::bool_<false> | |
103 >::type mutable_t; | |
104 | |
105 static const bool value = mutable_t::value; | |
106 }; | |
107 | |
108 } | |
109 | |
110 #else | |
111 | |
112 /** \brief Specifies the predicate for the heap order | |
113 */ | |
114 template <typename T> | |
115 struct compare{}; | |
116 | |
117 /** \brief Configure heap as mutable | |
118 * | |
119 * Certain heaps need to be configured specifically do be mutable. | |
120 * | |
121 * */ | |
122 template <bool T> | |
123 struct mutable_{}; | |
124 | |
125 /** \brief Specifies allocator for the internal memory management | |
126 */ | |
127 template <typename T> | |
128 struct allocator{}; | |
129 | |
130 /** \brief Configure a heap as \b stable | |
131 * | |
132 * A priority queue is stable, if elements with the same priority are popped from the heap, in the same order as | |
133 * they are inserted. | |
134 * */ | |
135 template <bool T> | |
136 struct stable{}; | |
137 | |
138 /** \brief Specifies the type for stability counter | |
139 * | |
140 * */ | |
141 template <typename IntType> | |
142 struct stability_counter_type{}; | |
143 | |
144 /** \brief Configures complexity of <tt> size() </tt> | |
145 * | |
146 * Specifies, whether size() should have linear or constant complexity. | |
147 * */ | |
148 template <bool T> | |
149 struct constant_time_size{}; | |
150 | |
151 /** \brief Store parent pointer in heap node. | |
152 * | |
153 * Maintaining a parent pointer adds some maintenance and size overhead, but iterating a heap is more efficient. | |
154 * */ | |
155 template <bool T> | |
156 struct store_parent_pointer{}; | |
157 | |
158 /** \brief Specify arity. | |
159 * | |
160 * Specifies the arity of a D-ary heap | |
161 * */ | |
162 template <unsigned int T> | |
163 struct arity{}; | |
164 #endif | |
165 | |
166 } /* namespace heap */ | |
167 } /* namespace boost */ | |
168 | |
169 #endif /* BOOST_HEAP_POLICIES_HPP */ |