Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- queue ------------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_QUEUE |
| 12 | #define _LIBCPP_QUEUE |
| 13 | |
| 14 | /* |
| 15 | queue synopsis |
| 16 | |
| 17 | namespace std |
| 18 | { |
| 19 | |
| 20 | template <class T, class Container = deque<T>> |
| 21 | class queue |
| 22 | { |
| 23 | public: |
| 24 | typedef Container container_type; |
| 25 | typedef typename container_type::value_type value_type; |
| 26 | typedef typename container_type::reference reference; |
| 27 | typedef typename container_type::const_reference const_reference; |
| 28 | typedef typename container_type::size_type size_type; |
| 29 | |
| 30 | protected: |
| 31 | container_type c; |
| 32 | |
| 33 | public: |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 34 | queue() = default; |
| 35 | ~queue() = default; |
| 36 | |
| 37 | queue(const queue& q) = default; |
| 38 | queue(queue&& q) = default; |
| 39 | |
| 40 | queue& operator=(const queue& q) = default; |
| 41 | queue& operator=(queue&& q) = default; |
| 42 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 43 | explicit queue(const container_type& c); |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 44 | explicit queue(container_type&& c) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | template <class Alloc> |
| 46 | explicit queue(const Alloc& a); |
| 47 | template <class Alloc> |
| 48 | queue(const container_type& c, const Alloc& a); |
| 49 | template <class Alloc> |
| 50 | queue(container_type&& c, const Alloc& a); |
| 51 | template <class Alloc> |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 52 | queue(const queue& q, const Alloc& a); |
| 53 | template <class Alloc> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 54 | queue(queue&& q, const Alloc& a); |
| 55 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 56 | bool empty() const; |
| 57 | size_type size() const; |
| 58 | |
| 59 | reference front(); |
| 60 | const_reference front() const; |
| 61 | reference back(); |
| 62 | const_reference back() const; |
| 63 | |
| 64 | void push(const value_type& v); |
| 65 | void push(value_type&& v); |
| 66 | template <class... Args> void emplace(Args&&... args); |
| 67 | void pop(); |
| 68 | |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 69 | void swap(queue& q) noexcept(noexcept(swap(c, q.c))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | template <class T, class Container> |
| 73 | bool operator==(const queue<T, Container>& x,const queue<T, Container>& y); |
| 74 | |
| 75 | template <class T, class Container> |
| 76 | bool operator< (const queue<T, Container>& x,const queue<T, Container>& y); |
| 77 | |
| 78 | template <class T, class Container> |
| 79 | bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y); |
| 80 | |
| 81 | template <class T, class Container> |
| 82 | bool operator> (const queue<T, Container>& x,const queue<T, Container>& y); |
| 83 | |
| 84 | template <class T, class Container> |
| 85 | bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y); |
| 86 | |
| 87 | template <class T, class Container> |
| 88 | bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y); |
| 89 | |
| 90 | template <class T, class Container> |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 91 | void swap(queue<T, Container>& x, queue<T, Container>& y) |
| 92 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 93 | |
| 94 | template <class T, class Container = vector<T>, |
| 95 | class Compare = less<typename Container::value_type>> |
| 96 | class priority_queue |
| 97 | { |
| 98 | public: |
| 99 | typedef Container container_type; |
| 100 | typedef typename container_type::value_type value_type; |
| 101 | typedef typename container_type::reference reference; |
| 102 | typedef typename container_type::const_reference const_reference; |
| 103 | typedef typename container_type::size_type size_type; |
| 104 | |
| 105 | protected: |
| 106 | container_type c; |
| 107 | Compare comp; |
| 108 | |
| 109 | public: |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 110 | priority_queue() = default; |
| 111 | ~priority_queue() = default; |
| 112 | |
| 113 | priority_queue(const priority_queue& q) = default; |
| 114 | priority_queue(priority_queue&& q) = default; |
| 115 | |
| 116 | priority_queue& operator=(const priority_queue& q) = default; |
| 117 | priority_queue& operator=(priority_queue&& q) = default; |
| 118 | |
| 119 | explicit priority_queue(const Compare& comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 120 | priority_queue(const Compare& comp, const container_type& c); |
| 121 | explicit priority_queue(const Compare& comp, container_type&& c); |
| 122 | template <class InputIterator> |
| 123 | priority_queue(InputIterator first, InputIterator last, |
| 124 | const Compare& comp = Compare()); |
| 125 | template <class InputIterator> |
| 126 | priority_queue(InputIterator first, InputIterator last, |
| 127 | const Compare& comp, const container_type& c); |
| 128 | template <class InputIterator> |
| 129 | priority_queue(InputIterator first, InputIterator last, |
| 130 | const Compare& comp, container_type&& c); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 131 | template <class Alloc> |
| 132 | explicit priority_queue(const Alloc& a); |
| 133 | template <class Alloc> |
| 134 | priority_queue(const Compare& comp, const Alloc& a); |
| 135 | template <class Alloc> |
| 136 | priority_queue(const Compare& comp, const container_type& c, |
| 137 | const Alloc& a); |
| 138 | template <class Alloc> |
| 139 | priority_queue(const Compare& comp, container_type&& c, |
| 140 | const Alloc& a); |
| 141 | template <class Alloc> |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 142 | priority_queue(const priority_queue& q, const Alloc& a); |
| 143 | template <class Alloc> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 144 | priority_queue(priority_queue&& q, const Alloc& a); |
| 145 | |
| 146 | bool empty() const; |
| 147 | size_type size() const; |
| 148 | const_reference top() const; |
| 149 | |
| 150 | void push(const value_type& v); |
| 151 | void push(value_type&& v); |
| 152 | template <class... Args> void emplace(Args&&... args); |
| 153 | void pop(); |
| 154 | |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 155 | void swap(priority_queue& q) |
| 156 | noexcept(noexcept(swap(c, q.c)) && noexcept(swap(comp.q.comp))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | template <class T, class Container, class Compare> |
| 160 | void swap(priority_queue<T, Container, Compare>& x, |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 161 | priority_queue<T, Container, Compare>& y) |
| 162 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 163 | |
| 164 | } // std |
| 165 | |
| 166 | */ |
| 167 | |
| 168 | #include <__config> |
| 169 | #include <deque> |
| 170 | #include <vector> |
| 171 | #include <functional> |
| 172 | #include <algorithm> |
| 173 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 174 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 175 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 176 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 177 | |
| 178 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 179 | |
Marshall Clow | a46f5ce | 2015-02-18 17:51:56 +0000 | [diff] [blame^] | 180 | template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TYPE_VIS_ONLY queue; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 181 | |
| 182 | template <class _Tp, class _Container> |
Howard Hinnant | 33be35e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 183 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 184 | bool |
| 185 | operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); |
| 186 | |
| 187 | template <class _Tp, class _Container> |
Howard Hinnant | 33be35e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 188 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 189 | bool |
| 190 | operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); |
| 191 | |
Marshall Clow | a46f5ce | 2015-02-18 17:51:56 +0000 | [diff] [blame^] | 192 | template <class _Tp, class _Container /*= deque<_Tp>*/> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 193 | class _LIBCPP_TYPE_VIS_ONLY queue |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 194 | { |
| 195 | public: |
| 196 | typedef _Container container_type; |
| 197 | typedef typename container_type::value_type value_type; |
| 198 | typedef typename container_type::reference reference; |
| 199 | typedef typename container_type::const_reference const_reference; |
| 200 | typedef typename container_type::size_type size_type; |
| 201 | |
| 202 | protected: |
| 203 | container_type c; |
| 204 | |
| 205 | public: |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 206 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 207 | queue() |
| 208 | _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) |
| 209 | : c() {} |
| 210 | |
| 211 | _LIBCPP_INLINE_VISIBILITY |
| 212 | queue(const queue& __q) : c(__q.c) {} |
| 213 | |
| 214 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 215 | _LIBCPP_INLINE_VISIBILITY |
| 216 | queue(queue&& __q) |
| 217 | _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 218 | : c(_VSTD::move(__q.c)) {} |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 219 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 220 | |
| 221 | _LIBCPP_INLINE_VISIBILITY |
| 222 | queue& operator=(const queue& __q) {c = __q.c; return *this;} |
| 223 | |
| 224 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 225 | _LIBCPP_INLINE_VISIBILITY |
| 226 | queue& operator=(queue&& __q) |
| 227 | _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 228 | {c = _VSTD::move(__q.c); return *this;} |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 229 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 230 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 231 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 232 | explicit queue(const container_type& __c) : c(__c) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 233 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 234 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 235 | explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 236 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 237 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 238 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 239 | explicit queue(const _Alloc& __a, |
| 240 | typename enable_if<uses_allocator<container_type, |
| 241 | _Alloc>::value>::type* = 0) |
| 242 | : c(__a) {} |
| 243 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 244 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 245 | queue(const queue& __q, const _Alloc& __a, |
| 246 | typename enable_if<uses_allocator<container_type, |
| 247 | _Alloc>::value>::type* = 0) |
| 248 | : c(__q.c, __a) {} |
| 249 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 250 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 251 | queue(const container_type& __c, const _Alloc& __a, |
| 252 | typename enable_if<uses_allocator<container_type, |
| 253 | _Alloc>::value>::type* = 0) |
| 254 | : c(__c, __a) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 255 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 256 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 257 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 258 | queue(container_type&& __c, const _Alloc& __a, |
| 259 | typename enable_if<uses_allocator<container_type, |
| 260 | _Alloc>::value>::type* = 0) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 261 | : c(_VSTD::move(__c), __a) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 262 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 263 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 264 | queue(queue&& __q, const _Alloc& __a, |
| 265 | typename enable_if<uses_allocator<container_type, |
| 266 | _Alloc>::value>::type* = 0) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 267 | : c(_VSTD::move(__q.c), __a) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 268 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 269 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 270 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 271 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 272 | bool empty() const {return c.empty();} |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 273 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 274 | size_type size() const {return c.size();} |
| 275 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 276 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 277 | reference front() {return c.front();} |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 278 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 279 | const_reference front() const {return c.front();} |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 280 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 281 | reference back() {return c.back();} |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 282 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 283 | const_reference back() const {return c.back();} |
| 284 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 285 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 286 | void push(const value_type& __v) {c.push_back(__v);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 287 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 288 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 289 | void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 290 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 291 | template <class... _Args> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 292 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 293 | void emplace(_Args&&... __args) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 294 | {c.emplace_back(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 295 | #endif // _LIBCPP_HAS_NO_VARIADICS |
| 296 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 297 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 298 | void pop() {c.pop_front();} |
| 299 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 300 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 301 | void swap(queue& __q) |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 302 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 303 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 304 | using _VSTD::swap; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 305 | swap(c, __q.c); |
| 306 | } |
| 307 | |
| 308 | template <class _T1, class _C1> |
| 309 | friend |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 310 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 311 | bool |
| 312 | operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 313 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 314 | template <class _T1, class _C1> |
| 315 | friend |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 316 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 317 | bool |
| 318 | operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); |
| 319 | }; |
| 320 | |
| 321 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 322 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 323 | bool |
| 324 | operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 325 | { |
| 326 | return __x.c == __y.c; |
| 327 | } |
| 328 | |
| 329 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 330 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 331 | bool |
| 332 | operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 333 | { |
| 334 | return __x.c < __y.c; |
| 335 | } |
| 336 | |
| 337 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 338 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 339 | bool |
| 340 | operator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 341 | { |
| 342 | return !(__x == __y); |
| 343 | } |
| 344 | |
| 345 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 346 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 347 | bool |
| 348 | operator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 349 | { |
| 350 | return __y < __x; |
| 351 | } |
| 352 | |
| 353 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 354 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 355 | bool |
| 356 | operator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 357 | { |
| 358 | return !(__x < __y); |
| 359 | } |
| 360 | |
| 361 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 362 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 363 | bool |
| 364 | operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 365 | { |
| 366 | return !(__y < __x); |
| 367 | } |
| 368 | |
| 369 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 370 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 371 | void |
| 372 | swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 373 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 374 | { |
| 375 | __x.swap(__y); |
| 376 | } |
| 377 | |
| 378 | template <class _Tp, class _Container, class _Alloc> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 379 | struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<queue<_Tp, _Container>, _Alloc> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 380 | : public uses_allocator<_Container, _Alloc> |
| 381 | { |
| 382 | }; |
| 383 | |
| 384 | template <class _Tp, class _Container = vector<_Tp>, |
| 385 | class _Compare = less<typename _Container::value_type> > |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 386 | class _LIBCPP_TYPE_VIS_ONLY priority_queue |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 387 | { |
| 388 | public: |
| 389 | typedef _Container container_type; |
| 390 | typedef _Compare value_compare; |
| 391 | typedef typename container_type::value_type value_type; |
| 392 | typedef typename container_type::reference reference; |
| 393 | typedef typename container_type::const_reference const_reference; |
| 394 | typedef typename container_type::size_type size_type; |
| 395 | |
| 396 | protected: |
| 397 | container_type c; |
| 398 | value_compare comp; |
| 399 | |
| 400 | public: |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 401 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 402 | priority_queue() |
| 403 | _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && |
| 404 | is_nothrow_default_constructible<value_compare>::value) |
| 405 | : c(), comp() {} |
| 406 | |
| 407 | _LIBCPP_INLINE_VISIBILITY |
| 408 | priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} |
| 409 | |
| 410 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 411 | _LIBCPP_INLINE_VISIBILITY |
| 412 | priority_queue(priority_queue&& __q) |
| 413 | _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && |
| 414 | is_nothrow_move_constructible<value_compare>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 415 | : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {} |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 416 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 417 | |
| 418 | _LIBCPP_INLINE_VISIBILITY |
| 419 | priority_queue& operator=(const priority_queue& __q) |
| 420 | {c = __q.c; comp = __q.comp; return *this;} |
| 421 | |
| 422 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 423 | _LIBCPP_INLINE_VISIBILITY |
| 424 | priority_queue& operator=(priority_queue&& __q) |
| 425 | _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && |
| 426 | is_nothrow_move_assignable<value_compare>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 427 | {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;} |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 428 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 429 | |
| 430 | _LIBCPP_INLINE_VISIBILITY |
| 431 | explicit priority_queue(const value_compare& __comp) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 432 | : c(), comp(__comp) {} |
| 433 | priority_queue(const value_compare& __comp, const container_type& __c); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 434 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 435 | explicit priority_queue(const value_compare& __comp, container_type&& __c); |
| 436 | #endif |
| 437 | template <class _InputIter> |
| 438 | priority_queue(_InputIter __f, _InputIter __l, |
| 439 | const value_compare& __comp = value_compare()); |
| 440 | template <class _InputIter> |
| 441 | priority_queue(_InputIter __f, _InputIter __l, |
| 442 | const value_compare& __comp, const container_type& __c); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 443 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 444 | template <class _InputIter> |
| 445 | priority_queue(_InputIter __f, _InputIter __l, |
| 446 | const value_compare& __comp, container_type&& __c); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 447 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 448 | template <class _Alloc> |
| 449 | explicit priority_queue(const _Alloc& __a, |
| 450 | typename enable_if<uses_allocator<container_type, |
| 451 | _Alloc>::value>::type* = 0); |
| 452 | template <class _Alloc> |
| 453 | priority_queue(const value_compare& __comp, const _Alloc& __a, |
| 454 | typename enable_if<uses_allocator<container_type, |
| 455 | _Alloc>::value>::type* = 0); |
| 456 | template <class _Alloc> |
| 457 | priority_queue(const value_compare& __comp, const container_type& __c, |
| 458 | const _Alloc& __a, |
| 459 | typename enable_if<uses_allocator<container_type, |
| 460 | _Alloc>::value>::type* = 0); |
| 461 | template <class _Alloc> |
| 462 | priority_queue(const priority_queue& __q, const _Alloc& __a, |
| 463 | typename enable_if<uses_allocator<container_type, |
| 464 | _Alloc>::value>::type* = 0); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 465 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 466 | template <class _Alloc> |
| 467 | priority_queue(const value_compare& __comp, container_type&& __c, |
| 468 | const _Alloc& __a, |
| 469 | typename enable_if<uses_allocator<container_type, |
| 470 | _Alloc>::value>::type* = 0); |
| 471 | template <class _Alloc> |
| 472 | priority_queue(priority_queue&& __q, const _Alloc& __a, |
| 473 | typename enable_if<uses_allocator<container_type, |
| 474 | _Alloc>::value>::type* = 0); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 475 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 476 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 477 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 478 | bool empty() const {return c.empty();} |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 479 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 480 | size_type size() const {return c.size();} |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 481 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 482 | const_reference top() const {return c.front();} |
| 483 | |
| 484 | void push(const value_type& __v); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 485 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 486 | void push(value_type&& __v); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 487 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 488 | template <class... _Args> void emplace(_Args&&... __args); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 489 | #endif |
| 490 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 491 | void pop(); |
| 492 | |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 493 | void swap(priority_queue& __q) |
| 494 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && |
| 495 | __is_nothrow_swappable<value_compare>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 496 | }; |
| 497 | |
| 498 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 499 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 500 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, |
| 501 | const container_type& __c) |
| 502 | : c(__c), |
| 503 | comp(__comp) |
| 504 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 505 | _VSTD::make_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 506 | } |
| 507 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 508 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 509 | |
| 510 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 511 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 512 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 513 | container_type&& __c) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 514 | : c(_VSTD::move(__c)), |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 515 | comp(__comp) |
| 516 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 517 | _VSTD::make_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 518 | } |
| 519 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 520 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 521 | |
| 522 | template <class _Tp, class _Container, class _Compare> |
| 523 | template <class _InputIter> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 524 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 525 | priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, |
| 526 | const value_compare& __comp) |
| 527 | : c(__f, __l), |
| 528 | comp(__comp) |
| 529 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 530 | _VSTD::make_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | template <class _Tp, class _Container, class _Compare> |
| 534 | template <class _InputIter> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 535 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 536 | priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, |
| 537 | const value_compare& __comp, |
| 538 | const container_type& __c) |
| 539 | : c(__c), |
| 540 | comp(__comp) |
| 541 | { |
| 542 | c.insert(c.end(), __f, __l); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 543 | _VSTD::make_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 544 | } |
| 545 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 546 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 547 | |
| 548 | template <class _Tp, class _Container, class _Compare> |
| 549 | template <class _InputIter> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 550 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 551 | priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, |
| 552 | const value_compare& __comp, |
| 553 | container_type&& __c) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 554 | : c(_VSTD::move(__c)), |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 555 | comp(__comp) |
| 556 | { |
| 557 | c.insert(c.end(), __f, __l); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 558 | _VSTD::make_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 559 | } |
| 560 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 561 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 562 | |
| 563 | template <class _Tp, class _Container, class _Compare> |
| 564 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 565 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 566 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, |
| 567 | typename enable_if<uses_allocator<container_type, |
| 568 | _Alloc>::value>::type*) |
| 569 | : c(__a) |
| 570 | { |
| 571 | } |
| 572 | |
| 573 | template <class _Tp, class _Container, class _Compare> |
| 574 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 575 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 576 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 577 | const _Alloc& __a, |
| 578 | typename enable_if<uses_allocator<container_type, |
| 579 | _Alloc>::value>::type*) |
| 580 | : c(__a), |
| 581 | comp(__comp) |
| 582 | { |
| 583 | } |
| 584 | |
| 585 | template <class _Tp, class _Container, class _Compare> |
| 586 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 587 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 588 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 589 | const container_type& __c, |
| 590 | const _Alloc& __a, |
| 591 | typename enable_if<uses_allocator<container_type, |
| 592 | _Alloc>::value>::type*) |
| 593 | : c(__c, __a), |
| 594 | comp(__comp) |
| 595 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 596 | _VSTD::make_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | template <class _Tp, class _Container, class _Compare> |
| 600 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 601 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 602 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, |
| 603 | const _Alloc& __a, |
| 604 | typename enable_if<uses_allocator<container_type, |
| 605 | _Alloc>::value>::type*) |
| 606 | : c(__q.c, __a), |
| 607 | comp(__q.comp) |
| 608 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 609 | _VSTD::make_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 610 | } |
| 611 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 612 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 613 | |
| 614 | template <class _Tp, class _Container, class _Compare> |
| 615 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 616 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 617 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 618 | container_type&& __c, |
| 619 | const _Alloc& __a, |
| 620 | typename enable_if<uses_allocator<container_type, |
| 621 | _Alloc>::value>::type*) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 622 | : c(_VSTD::move(__c), __a), |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 623 | comp(__comp) |
| 624 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 625 | _VSTD::make_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 626 | } |
| 627 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 628 | template <class _Tp, class _Container, class _Compare> |
| 629 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 630 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 631 | priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, |
| 632 | const _Alloc& __a, |
| 633 | typename enable_if<uses_allocator<container_type, |
| 634 | _Alloc>::value>::type*) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 635 | : c(_VSTD::move(__q.c), __a), |
| 636 | comp(_VSTD::move(__q.comp)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 637 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 638 | _VSTD::make_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 639 | } |
| 640 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 641 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 642 | |
| 643 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 644 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 645 | void |
| 646 | priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) |
| 647 | { |
| 648 | c.push_back(__v); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 649 | _VSTD::push_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 650 | } |
| 651 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 652 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 653 | |
| 654 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 655 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 656 | void |
| 657 | priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) |
| 658 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 659 | c.push_back(_VSTD::move(__v)); |
| 660 | _VSTD::push_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 661 | } |
| 662 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 663 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
| 664 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 665 | template <class _Tp, class _Container, class _Compare> |
| 666 | template <class... _Args> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 667 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 668 | void |
| 669 | priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) |
| 670 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 671 | c.emplace_back(_VSTD::forward<_Args>(__args)...); |
| 672 | _VSTD::push_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 673 | } |
| 674 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 675 | #endif // _LIBCPP_HAS_NO_VARIADICS |
| 676 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 677 | |
| 678 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 679 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 680 | void |
| 681 | priority_queue<_Tp, _Container, _Compare>::pop() |
| 682 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 683 | _VSTD::pop_heap(c.begin(), c.end(), comp); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 684 | c.pop_back(); |
| 685 | } |
| 686 | |
| 687 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 688 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 689 | void |
| 690 | priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 691 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && |
| 692 | __is_nothrow_swappable<value_compare>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 693 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 694 | using _VSTD::swap; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 695 | swap(c, __q.c); |
| 696 | swap(comp, __q.comp); |
| 697 | } |
| 698 | |
| 699 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 700 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 701 | void |
| 702 | swap(priority_queue<_Tp, _Container, _Compare>& __x, |
| 703 | priority_queue<_Tp, _Container, _Compare>& __y) |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 704 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 705 | { |
| 706 | __x.swap(__y); |
| 707 | } |
| 708 | |
| 709 | template <class _Tp, class _Container, class _Compare, class _Alloc> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 710 | struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 711 | : public uses_allocator<_Container, _Alloc> |
| 712 | { |
| 713 | }; |
| 714 | |
| 715 | _LIBCPP_END_NAMESPACE_STD |
| 716 | |
| 717 | #endif // _LIBCPP_QUEUE |