Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/intrusive/detail/hashtable_node.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 ///////////////////////////////////////////////////////////////////////////// | 1 ///////////////////////////////////////////////////////////////////////////// |
2 // | 2 // |
3 // (C) Copyright Ion Gaztanaga 2007-2013 | 3 // (C) Copyright Ion Gaztanaga 2007-2014 |
4 // | 4 // |
5 // Distributed under the Boost Software License, Version 1.0. | 5 // Distributed under the Boost Software License, Version 1.0. |
6 // (See accompanying file LICENSE_1_0.txt or copy at | 6 // (See accompanying file LICENSE_1_0.txt or copy at |
7 // http://www.boost.org/LICENSE_1_0.txt) | 7 // http://www.boost.org/LICENSE_1_0.txt) |
8 // | 8 // |
11 ///////////////////////////////////////////////////////////////////////////// | 11 ///////////////////////////////////////////////////////////////////////////// |
12 | 12 |
13 #ifndef BOOST_INTRUSIVE_HASHTABLE_NODE_HPP | 13 #ifndef BOOST_INTRUSIVE_HASHTABLE_NODE_HPP |
14 #define BOOST_INTRUSIVE_HASHTABLE_NODE_HPP | 14 #define BOOST_INTRUSIVE_HASHTABLE_NODE_HPP |
15 | 15 |
16 #include <boost/intrusive/detail/config_begin.hpp> | 16 #ifndef BOOST_CONFIG_HPP |
17 #include <iterator> | 17 # include <boost/config.hpp> |
18 #endif | |
19 | |
20 #if defined(BOOST_HAS_PRAGMA_ONCE) | |
21 # pragma once | |
22 #endif | |
23 | |
18 #include <boost/intrusive/detail/assert.hpp> | 24 #include <boost/intrusive/detail/assert.hpp> |
19 #include <boost/intrusive/pointer_traits.hpp> | 25 #include <boost/intrusive/pointer_traits.hpp> |
20 #include <boost/intrusive/circular_list_algorithms.hpp> | |
21 #include <boost/intrusive/detail/mpl.hpp> | 26 #include <boost/intrusive/detail/mpl.hpp> |
22 #include <boost/intrusive/detail/utilities.hpp> | |
23 #include <boost/intrusive/slist.hpp> //remove-me | |
24 #include <boost/intrusive/pointer_traits.hpp> | |
25 #include <boost/intrusive/trivial_value_traits.hpp> | 27 #include <boost/intrusive/trivial_value_traits.hpp> |
28 #include <boost/intrusive/slist.hpp> //make_slist | |
26 #include <cstddef> | 29 #include <cstddef> |
27 #include <boost/type_traits/make_unsigned.hpp> | 30 #include <climits> |
28 #include <boost/pointer_cast.hpp> | |
29 #include <boost/move/core.hpp> | 31 #include <boost/move/core.hpp> |
30 | 32 |
31 | 33 |
32 namespace boost { | 34 namespace boost { |
33 namespace intrusive { | 35 namespace intrusive { |
34 namespace detail { | 36 namespace detail { |
35 | |
36 template<int Dummy = 0> | |
37 struct prime_list_holder | |
38 { | |
39 static const std::size_t prime_list[]; | |
40 static const std::size_t prime_list_size; | |
41 }; | |
42 | |
43 template<int Dummy> | |
44 const std::size_t prime_list_holder<Dummy>::prime_list[] = { | |
45 3ul, 7ul, 11ul, 17ul, 29ul, | |
46 53ul, 97ul, 193ul, 389ul, 769ul, | |
47 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, | |
48 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, | |
49 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, | |
50 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul, | |
51 1610612741ul, 3221225473ul, 4294967291ul }; | |
52 | |
53 template<int Dummy> | |
54 const std::size_t prime_list_holder<Dummy>::prime_list_size | |
55 = sizeof(prime_list)/sizeof(std::size_t); | |
56 | 37 |
57 template <class Slist> | 38 template <class Slist> |
58 struct bucket_impl : public Slist | 39 struct bucket_impl : public Slist |
59 { | 40 { |
60 typedef Slist slist_type; | 41 typedef Slist slist_type; |
161 //Reducing symbol length | 142 //Reducing symbol length |
162 struct type : make_slist | 143 struct type : make_slist |
163 < typename NodeTraits::node | 144 < typename NodeTraits::node |
164 , boost::intrusive::value_traits<trivial_traits> | 145 , boost::intrusive::value_traits<trivial_traits> |
165 , boost::intrusive::constant_time_size<false> | 146 , boost::intrusive::constant_time_size<false> |
166 , boost::intrusive::size_type<typename boost::make_unsigned | 147 , boost::intrusive::size_type<std::size_t> |
167 <typename pointer_traits<typename NodeTraits::node_ptr>::difference_type>::type > | |
168 >::type | 148 >::type |
169 {}; | 149 {}; |
170 }; | 150 }; |
171 | 151 |
172 } //namespace detail { | 152 } //namespace detail { |
173 | 153 |
174 template<class BucketValueTraits, bool IsConst> | 154 template<class BucketValueTraits, bool IsConst> |
175 class hashtable_iterator | 155 class hashtable_iterator |
176 : public std::iterator | 156 { |
157 typedef boost::intrusive::iterator | |
177 < std::forward_iterator_tag | 158 < std::forward_iterator_tag |
178 , typename BucketValueTraits::real_value_traits::value_type | 159 , typename BucketValueTraits::value_traits::value_type |
179 , typename pointer_traits<typename BucketValueTraits::real_value_traits::value_type*>::difference_type | 160 , typename pointer_traits<typename BucketValueTraits::value_traits::value_type*>::difference_type |
180 , typename detail::add_const_if_c | 161 , typename detail::add_const_if_c |
181 <typename BucketValueTraits::real_value_traits::value_type, IsConst>::type * | 162 <typename BucketValueTraits::value_traits::value_type, IsConst>::type * |
182 , typename detail::add_const_if_c | 163 , typename detail::add_const_if_c |
183 <typename BucketValueTraits::real_value_traits::value_type, IsConst>::type & | 164 <typename BucketValueTraits::value_traits::value_type, IsConst>::type & |
184 > | 165 > iterator_traits; |
185 { | 166 |
186 typedef typename BucketValueTraits::real_value_traits real_value_traits; | 167 typedef typename BucketValueTraits::value_traits value_traits; |
187 typedef typename BucketValueTraits::real_bucket_traits real_bucket_traits; | 168 typedef typename BucketValueTraits::bucket_traits bucket_traits; |
188 typedef typename real_value_traits::node_traits node_traits; | 169 typedef typename value_traits::node_traits node_traits; |
189 typedef typename detail::get_slist_impl | 170 typedef typename detail::get_slist_impl |
190 <typename detail::reduced_slist_node_traits | 171 <typename detail::reduced_slist_node_traits |
191 <typename real_value_traits::node_traits>::type | 172 <typename value_traits::node_traits>::type |
192 >::type slist_impl; | 173 >::type slist_impl; |
193 typedef typename slist_impl::iterator siterator; | 174 typedef typename slist_impl::iterator siterator; |
194 typedef typename slist_impl::const_iterator const_siterator; | 175 typedef typename slist_impl::const_iterator const_siterator; |
195 typedef detail::bucket_impl<slist_impl> bucket_type; | 176 typedef detail::bucket_impl<slist_impl> bucket_type; |
196 | 177 |
197 typedef typename pointer_traits | 178 typedef typename pointer_traits |
198 <typename real_value_traits::pointer>::template rebind_pointer | 179 <typename value_traits::pointer>::template rebind_pointer |
199 < const BucketValueTraits >::type const_bucketvaltraits_ptr; | 180 < const BucketValueTraits >::type const_bucketvaltraits_ptr; |
200 typedef typename slist_impl::size_type size_type; | 181 typedef typename slist_impl::size_type size_type; |
201 | 182 |
202 | 183 |
203 static typename node_traits::node_ptr downcast_bucket(typename bucket_type::node_ptr p) | 184 static typename node_traits::node_ptr downcast_bucket(typename bucket_type::node_ptr p) |
205 return pointer_traits<typename node_traits::node_ptr>:: | 186 return pointer_traits<typename node_traits::node_ptr>:: |
206 pointer_to(static_cast<typename node_traits::node&>(*p)); | 187 pointer_to(static_cast<typename node_traits::node&>(*p)); |
207 } | 188 } |
208 | 189 |
209 public: | 190 public: |
210 typedef typename real_value_traits::value_type value_type; | 191 typedef typename iterator_traits::difference_type difference_type; |
211 typedef typename detail::add_const_if_c<value_type, IsConst>::type *pointer; | 192 typedef typename iterator_traits::value_type value_type; |
212 typedef typename detail::add_const_if_c<value_type, IsConst>::type &reference; | 193 typedef typename iterator_traits::pointer pointer; |
194 typedef typename iterator_traits::reference reference; | |
195 typedef typename iterator_traits::iterator_category iterator_category; | |
213 | 196 |
214 hashtable_iterator () | 197 hashtable_iterator () |
198 : slist_it_() //Value initialization to achieve "null iterators" (N3644) | |
215 {} | 199 {} |
216 | 200 |
217 explicit hashtable_iterator(siterator ptr, const BucketValueTraits *cont) | 201 explicit hashtable_iterator(siterator ptr, const BucketValueTraits *cont) |
218 : slist_it_ (ptr), traitsptr_ (cont ? pointer_traits<const_bucketvaltraits_ptr>::pointer_to(*cont) : const_bucketvaltraits_ptr() ) | 202 : slist_it_ (ptr), traitsptr_ (cont ? pointer_traits<const_bucketvaltraits_ptr>::pointer_to(*cont) : const_bucketvaltraits_ptr() ) |
219 {} | 203 {} |
248 reference operator*() const | 232 reference operator*() const |
249 { return *this->operator ->(); } | 233 { return *this->operator ->(); } |
250 | 234 |
251 pointer operator->() const | 235 pointer operator->() const |
252 { | 236 { |
253 return boost::intrusive::detail::to_raw_pointer(this->priv_real_value_traits().to_value_ptr | 237 return boost::intrusive::detail::to_raw_pointer(this->priv_value_traits().to_value_ptr |
254 (downcast_bucket(slist_it_.pointed_node()))); | 238 (downcast_bucket(slist_it_.pointed_node()))); |
255 } | 239 } |
256 | 240 |
257 const const_bucketvaltraits_ptr &get_bucket_value_traits() const | 241 const const_bucketvaltraits_ptr &get_bucket_value_traits() const |
258 { return traitsptr_; } | 242 { return traitsptr_; } |
259 | 243 |
260 const real_value_traits &priv_real_value_traits() const | 244 const value_traits &priv_value_traits() const |
261 { return traitsptr_->priv_real_value_traits(); } | 245 { return traitsptr_->priv_value_traits(); } |
262 | 246 |
263 const real_bucket_traits &priv_real_bucket_traits() const | 247 const bucket_traits &priv_bucket_traits() const |
264 { return traitsptr_->priv_real_bucket_traits(); } | 248 { return traitsptr_->priv_bucket_traits(); } |
265 | 249 |
266 private: | 250 private: |
267 void increment() | 251 void increment() |
268 { | 252 { |
269 const real_bucket_traits &rbuck_traits = this->priv_real_bucket_traits(); | 253 const bucket_traits &rbuck_traits = this->priv_bucket_traits(); |
270 bucket_type* const buckets = boost::intrusive::detail::to_raw_pointer(rbuck_traits.bucket_begin()); | 254 bucket_type* const buckets = boost::intrusive::detail::to_raw_pointer(rbuck_traits.bucket_begin()); |
271 const size_type buckets_len = rbuck_traits.bucket_count(); | 255 const size_type buckets_len = rbuck_traits.bucket_count(); |
272 | 256 |
273 ++slist_it_; | 257 ++slist_it_; |
274 const typename slist_impl::node_ptr n = slist_it_.pointed_node(); | 258 const typename slist_impl::node_ptr n = slist_it_.pointed_node(); |