Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/unordered/detail/buckets.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 |
---|---|
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
6 | 6 |
7 #ifndef BOOST_UNORDERED_DETAIL_MANAGER_HPP_INCLUDED | 7 #ifndef BOOST_UNORDERED_DETAIL_MANAGER_HPP_INCLUDED |
8 #define BOOST_UNORDERED_DETAIL_MANAGER_HPP_INCLUDED | 8 #define BOOST_UNORDERED_DETAIL_MANAGER_HPP_INCLUDED |
9 | 9 |
10 #if defined(_MSC_VER) && (_MSC_VER >= 1020) | 10 #include <boost/config.hpp> |
11 # pragma once | 11 #if defined(BOOST_HAS_PRAGMA_ONCE) |
12 #pragma once | |
12 #endif | 13 #endif |
13 | 14 |
14 #include <boost/unordered/detail/util.hpp> | 15 #include <boost/unordered/detail/util.hpp> |
15 #include <boost/unordered/detail/allocate.hpp> | 16 #include <boost/unordered/detail/allocate.hpp> |
16 #include <boost/type_traits/aligned_storage.hpp> | 17 #include <boost/type_traits/aligned_storage.hpp> |
42 // Iterators | 43 // Iterators |
43 // | 44 // |
44 // all no throw | 45 // all no throw |
45 | 46 |
46 template <typename Node> struct iterator; | 47 template <typename Node> struct iterator; |
47 template <typename Node, typename ConstNodePointer> struct c_iterator; | 48 template <typename Node> struct c_iterator; |
48 template <typename Node, typename Policy> struct l_iterator; | 49 template <typename Node, typename Policy> struct l_iterator; |
49 template <typename Node, typename ConstNodePointer, typename Policy> | 50 template <typename Node, typename Policy> |
50 struct cl_iterator; | 51 struct cl_iterator; |
51 | 52 |
52 // Local Iterators | 53 // Local Iterators |
53 // | 54 // |
54 // all no throw | 55 // all no throw |
57 struct l_iterator | 58 struct l_iterator |
58 : public boost::iterator< | 59 : public boost::iterator< |
59 std::forward_iterator_tag, | 60 std::forward_iterator_tag, |
60 typename Node::value_type, | 61 typename Node::value_type, |
61 std::ptrdiff_t, | 62 std::ptrdiff_t, |
62 typename Node::node_pointer, | 63 typename Node::value_type*, |
63 typename Node::value_type&> | 64 typename Node::value_type&> |
64 { | 65 { |
65 #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) | 66 #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) |
66 template <typename Node2, typename ConstNodePointer, typename Policy2> | 67 template <typename Node2, typename Policy2> |
67 friend struct boost::unordered::iterator_detail::cl_iterator; | 68 friend struct boost::unordered::iterator_detail::cl_iterator; |
68 private: | 69 private: |
69 #endif | 70 #endif |
70 typedef typename Node::node_pointer node_pointer; | 71 typedef typename Node::node_pointer node_pointer; |
71 typedef boost::unordered::iterator_detail::iterator<Node> iterator; | 72 typedef boost::unordered::iterator_detail::iterator<Node> n_iterator; |
72 node_pointer ptr_; | 73 node_pointer ptr_; |
73 std::size_t bucket_; | 74 std::size_t bucket_; |
74 std::size_t bucket_count_; | 75 std::size_t bucket_count_; |
75 | 76 |
76 public: | 77 public: |
77 | 78 |
78 typedef typename Node::value_type value_type; | 79 typedef typename Node::value_type value_type; |
79 | 80 |
80 l_iterator() BOOST_NOEXCEPT : ptr_() {} | 81 l_iterator() BOOST_NOEXCEPT : ptr_() {} |
81 | 82 |
82 l_iterator(iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT | 83 l_iterator(n_iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT |
83 : ptr_(x.node_), bucket_(b), bucket_count_(c) {} | 84 : ptr_(x.node_), bucket_(b), bucket_count_(c) {} |
84 | 85 |
85 value_type& operator*() const { | 86 value_type& operator*() const { |
86 return ptr_->value(); | 87 return ptr_->value(); |
87 } | 88 } |
111 bool operator!=(l_iterator x) const BOOST_NOEXCEPT { | 112 bool operator!=(l_iterator x) const BOOST_NOEXCEPT { |
112 return ptr_ != x.ptr_; | 113 return ptr_ != x.ptr_; |
113 } | 114 } |
114 }; | 115 }; |
115 | 116 |
116 template <typename Node, typename ConstNodePointer, typename Policy> | 117 template <typename Node, typename Policy> |
117 struct cl_iterator | 118 struct cl_iterator |
118 : public boost::iterator< | 119 : public boost::iterator< |
119 std::forward_iterator_tag, | 120 std::forward_iterator_tag, |
120 typename Node::value_type, | 121 typename Node::value_type, |
121 std::ptrdiff_t, | 122 std::ptrdiff_t, |
122 ConstNodePointer, | 123 typename Node::value_type const*, |
123 typename Node::value_type const&> | 124 typename Node::value_type const&> |
124 { | 125 { |
125 friend struct boost::unordered::iterator_detail::l_iterator | 126 friend struct boost::unordered::iterator_detail::l_iterator |
126 <Node, Policy>; | 127 <Node, Policy>; |
127 private: | 128 private: |
128 | 129 |
129 typedef typename Node::node_pointer node_pointer; | 130 typedef typename Node::node_pointer node_pointer; |
130 typedef boost::unordered::iterator_detail::iterator<Node> iterator; | 131 typedef boost::unordered::iterator_detail::iterator<Node> n_iterator; |
131 node_pointer ptr_; | 132 node_pointer ptr_; |
132 std::size_t bucket_; | 133 std::size_t bucket_; |
133 std::size_t bucket_count_; | 134 std::size_t bucket_count_; |
134 | 135 |
135 public: | 136 public: |
136 | 137 |
137 typedef typename Node::value_type value_type; | 138 typedef typename Node::value_type value_type; |
138 | 139 |
139 cl_iterator() BOOST_NOEXCEPT : ptr_() {} | 140 cl_iterator() BOOST_NOEXCEPT : ptr_() {} |
140 | 141 |
141 cl_iterator(iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT : | 142 cl_iterator(n_iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT : |
142 ptr_(x.node_), bucket_(b), bucket_count_(c) {} | 143 ptr_(x.node_), bucket_(b), bucket_count_(c) {} |
143 | 144 |
144 cl_iterator(boost::unordered::iterator_detail::l_iterator< | 145 cl_iterator(boost::unordered::iterator_detail::l_iterator< |
145 Node, Policy> const& x) BOOST_NOEXCEPT : | 146 Node, Policy> const& x) BOOST_NOEXCEPT : |
146 ptr_(x.ptr_), bucket_(x.bucket_), bucket_count_(x.bucket_count_) | 147 ptr_(x.ptr_), bucket_(x.bucket_), bucket_count_(x.bucket_count_) |
185 struct iterator | 186 struct iterator |
186 : public boost::iterator< | 187 : public boost::iterator< |
187 std::forward_iterator_tag, | 188 std::forward_iterator_tag, |
188 typename Node::value_type, | 189 typename Node::value_type, |
189 std::ptrdiff_t, | 190 std::ptrdiff_t, |
190 typename Node::node_pointer, | 191 typename Node::value_type*, |
191 typename Node::value_type&> | 192 typename Node::value_type&> |
192 { | 193 { |
193 #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) | 194 #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) |
194 template <typename, typename> | 195 template <typename> |
195 friend struct boost::unordered::iterator_detail::c_iterator; | 196 friend struct boost::unordered::iterator_detail::c_iterator; |
196 template <typename, typename> | 197 template <typename, typename> |
197 friend struct boost::unordered::iterator_detail::l_iterator; | 198 friend struct boost::unordered::iterator_detail::l_iterator; |
198 template <typename, typename, typename> | 199 template <typename, typename> |
199 friend struct boost::unordered::iterator_detail::cl_iterator; | 200 friend struct boost::unordered::iterator_detail::cl_iterator; |
200 template <typename> | 201 template <typename> |
201 friend struct boost::unordered::detail::table; | 202 friend struct boost::unordered::detail::table; |
202 template <typename> | 203 template <typename> |
203 friend struct boost::unordered::detail::table_impl; | 204 friend struct boost::unordered::detail::table_impl; |
220 value_type& operator*() const { | 221 value_type& operator*() const { |
221 return node_->value(); | 222 return node_->value(); |
222 } | 223 } |
223 | 224 |
224 value_type* operator->() const { | 225 value_type* operator->() const { |
225 return &node_->value(); | 226 return node_->value_ptr(); |
226 } | 227 } |
227 | 228 |
228 iterator& operator++() { | 229 iterator& operator++() { |
229 node_ = static_cast<node_pointer>(node_->next_); | 230 node_ = static_cast<node_pointer>(node_->next_); |
230 return *this; | 231 return *this; |
243 bool operator!=(iterator const& x) const BOOST_NOEXCEPT { | 244 bool operator!=(iterator const& x) const BOOST_NOEXCEPT { |
244 return node_ != x.node_; | 245 return node_ != x.node_; |
245 } | 246 } |
246 }; | 247 }; |
247 | 248 |
248 template <typename Node, typename ConstNodePointer> | 249 template <typename Node> |
249 struct c_iterator | 250 struct c_iterator |
250 : public boost::iterator< | 251 : public boost::iterator< |
251 std::forward_iterator_tag, | 252 std::forward_iterator_tag, |
252 typename Node::value_type, | 253 typename Node::value_type, |
253 std::ptrdiff_t, | 254 std::ptrdiff_t, |
254 ConstNodePointer, | 255 typename Node::value_type const*, |
255 typename Node::value_type const&> | 256 typename Node::value_type const&> |
256 { | 257 { |
257 friend struct boost::unordered::iterator_detail::iterator<Node>; | 258 friend struct boost::unordered::iterator_detail::iterator<Node>; |
258 | 259 |
259 #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) | 260 #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) |
265 friend struct boost::unordered::detail::grouped_table_impl; | 266 friend struct boost::unordered::detail::grouped_table_impl; |
266 | 267 |
267 private: | 268 private: |
268 #endif | 269 #endif |
269 typedef typename Node::node_pointer node_pointer; | 270 typedef typename Node::node_pointer node_pointer; |
270 typedef boost::unordered::iterator_detail::iterator<Node> iterator; | 271 typedef boost::unordered::iterator_detail::iterator<Node> n_iterator; |
271 node_pointer node_; | 272 node_pointer node_; |
272 | 273 |
273 public: | 274 public: |
274 | 275 |
275 typedef typename Node::value_type value_type; | 276 typedef typename Node::value_type value_type; |
277 c_iterator() BOOST_NOEXCEPT : node_() {} | 278 c_iterator() BOOST_NOEXCEPT : node_() {} |
278 | 279 |
279 explicit c_iterator(typename Node::link_pointer x) BOOST_NOEXCEPT : | 280 explicit c_iterator(typename Node::link_pointer x) BOOST_NOEXCEPT : |
280 node_(static_cast<node_pointer>(x)) {} | 281 node_(static_cast<node_pointer>(x)) {} |
281 | 282 |
282 c_iterator(iterator const& x) BOOST_NOEXCEPT : node_(x.node_) {} | 283 c_iterator(n_iterator const& x) BOOST_NOEXCEPT : node_(x.node_) {} |
283 | 284 |
284 value_type const& operator*() const { | 285 value_type const& operator*() const { |
285 return node_->value(); | 286 return node_->value(); |
286 } | 287 } |
287 | 288 |
288 value_type const* operator->() const { | 289 value_type const* operator->() const { |
289 return &node_->value(); | 290 return node_->value_ptr(); |
290 } | 291 } |
291 | 292 |
292 c_iterator& operator++() { | 293 c_iterator& operator++() { |
293 node_ = static_cast<node_pointer>(node_->next_); | 294 node_ = static_cast<node_pointer>(node_->next_); |
294 return *this; | 295 return *this; |
399 boost::unordered::detail::func::destroy_value_impl(alloc_, | 400 boost::unordered::detail::func::destroy_value_impl(alloc_, |
400 node_->value_ptr()); | 401 node_->value_ptr()); |
401 } | 402 } |
402 | 403 |
403 if (node_constructed_) { | 404 if (node_constructed_) { |
404 node_allocator_traits::destroy(alloc_, | 405 boost::unordered::detail::func::destroy( |
405 boost::addressof(*node_)); | 406 boost::addressof(*node_)); |
406 } | 407 } |
407 | 408 |
408 node_allocator_traits::deallocate(alloc_, node_, 1); | 409 node_allocator_traits::deallocate(alloc_, node_, 1); |
409 } | 410 } |
416 node_constructed_ = false; | 417 node_constructed_ = false; |
417 value_constructed_ = false; | 418 value_constructed_ = false; |
418 | 419 |
419 node_ = node_allocator_traits::allocate(alloc_, 1); | 420 node_ = node_allocator_traits::allocate(alloc_, 1); |
420 | 421 |
421 node_allocator_traits::construct(alloc_, | 422 new ((void*) boost::addressof(*node_)) node(); |
422 boost::addressof(*node_), node()); | |
423 node_->init(node_); | 423 node_->init(node_); |
424 node_constructed_ = true; | 424 node_constructed_ = true; |
425 } | 425 } |
426 else { | 426 else { |
427 BOOST_ASSERT(node_constructed_); | 427 BOOST_ASSERT(node_constructed_); |
545 node_pointer p = nodes_; | 545 node_pointer p = nodes_; |
546 nodes_ = static_cast<node_pointer>(p->next_); | 546 nodes_ = static_cast<node_pointer>(p->next_); |
547 | 547 |
548 boost::unordered::detail::func::destroy_value_impl(this->alloc_, | 548 boost::unordered::detail::func::destroy_value_impl(this->alloc_, |
549 p->value_ptr()); | 549 p->value_ptr()); |
550 node_allocator_traits::destroy(this->alloc_, boost::addressof(*p)); | 550 boost::unordered::detail::func::destroy(boost::addressof(*p)); |
551 node_allocator_traits::deallocate(this->alloc_, p, 1); | 551 node_allocator_traits::deallocate(this->alloc_, p, 1); |
552 } | 552 } |
553 } | 553 } |
554 | 554 |
555 /////////////////////////////////////////////////////////////////// | 555 /////////////////////////////////////////////////////////////////// |
663 template <> | 663 template <> |
664 struct pick_policy_impl<64, 2> { | 664 struct pick_policy_impl<64, 2> { |
665 typedef mix64_policy<std::size_t> type; | 665 typedef mix64_policy<std::size_t> type; |
666 }; | 666 }; |
667 | 667 |
668 template <typename T> | |
668 struct pick_policy : | 669 struct pick_policy : |
669 pick_policy_impl< | 670 pick_policy_impl< |
670 std::numeric_limits<std::size_t>::digits, | 671 std::numeric_limits<std::size_t>::digits, |
671 std::numeric_limits<std::size_t>::radix> {}; | 672 std::numeric_limits<std::size_t>::radix> {}; |
673 | |
674 // While the mix policy is generally faster, the prime policy is a lot | |
675 // faster when a large number consecutive integers are used, because | |
676 // there are no collisions. Since that is probably quite common, use | |
677 // prime policy for integeral types. But not the smaller ones, as they | |
678 // don't have enough unique values for this to be an issue. | |
679 | |
680 template <> | |
681 struct pick_policy<int> { | |
682 typedef prime_policy<std::size_t> type; | |
683 }; | |
684 | |
685 template <> | |
686 struct pick_policy<unsigned int> { | |
687 typedef prime_policy<std::size_t> type; | |
688 }; | |
689 | |
690 template <> | |
691 struct pick_policy<long> { | |
692 typedef prime_policy<std::size_t> type; | |
693 }; | |
694 | |
695 template <> | |
696 struct pick_policy<unsigned long> { | |
697 typedef prime_policy<std::size_t> type; | |
698 }; | |
699 | |
700 // TODO: Maybe not if std::size_t is smaller than long long. | |
701 #if !defined(BOOST_NO_LONG_LONG) | |
702 template <> | |
703 struct pick_policy<long long> { | |
704 typedef prime_policy<std::size_t> type; | |
705 }; | |
706 | |
707 template <> | |
708 struct pick_policy<unsigned long long> { | |
709 typedef prime_policy<std::size_t> type; | |
710 }; | |
711 #endif | |
672 | 712 |
673 //////////////////////////////////////////////////////////////////////////// | 713 //////////////////////////////////////////////////////////////////////////// |
674 // Functions | 714 // Functions |
675 | 715 |
676 // Assigning and swapping the equality and hash function objects | 716 // Assigning and swapping the equality and hash function objects |