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 | |
| 174 | #pragma GCC system_header |
| 175 | |
| 176 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 177 | |
| 178 | template <class _Tp, class _Container> class queue; |
| 179 | |
| 180 | template <class _Tp, class _Container> |
| 181 | bool |
| 182 | operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); |
| 183 | |
| 184 | template <class _Tp, class _Container> |
| 185 | bool |
| 186 | operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); |
| 187 | |
| 188 | template <class _Tp, class _Container = deque<_Tp> > |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 189 | class _LIBCPP_VISIBLE queue |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 190 | { |
| 191 | public: |
| 192 | typedef _Container container_type; |
| 193 | typedef typename container_type::value_type value_type; |
| 194 | typedef typename container_type::reference reference; |
| 195 | typedef typename container_type::const_reference const_reference; |
| 196 | typedef typename container_type::size_type size_type; |
| 197 | |
| 198 | protected: |
| 199 | container_type c; |
| 200 | |
| 201 | public: |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 202 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 203 | queue() |
| 204 | _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) |
| 205 | : c() {} |
| 206 | |
| 207 | _LIBCPP_INLINE_VISIBILITY |
| 208 | queue(const queue& __q) : c(__q.c) {} |
| 209 | |
| 210 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 211 | _LIBCPP_INLINE_VISIBILITY |
| 212 | queue(queue&& __q) |
| 213 | _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) |
| 214 | : c(_STD::move(__q.c)) {} |
| 215 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 216 | |
| 217 | _LIBCPP_INLINE_VISIBILITY |
| 218 | queue& operator=(const queue& __q) {c = __q.c; return *this;} |
| 219 | |
| 220 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 221 | _LIBCPP_INLINE_VISIBILITY |
| 222 | queue& operator=(queue&& __q) |
| 223 | _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) |
| 224 | {c = _STD::move(__q.c); return *this;} |
| 225 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 226 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 227 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 228 | explicit queue(const container_type& __c) : c(__c) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 229 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 230 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 231 | explicit queue(container_type&& __c) : c(_STD::move(__c)) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 232 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 233 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 234 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 235 | explicit queue(const _Alloc& __a, |
| 236 | typename enable_if<uses_allocator<container_type, |
| 237 | _Alloc>::value>::type* = 0) |
| 238 | : c(__a) {} |
| 239 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 240 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 241 | queue(const queue& __q, const _Alloc& __a, |
| 242 | typename enable_if<uses_allocator<container_type, |
| 243 | _Alloc>::value>::type* = 0) |
| 244 | : c(__q.c, __a) {} |
| 245 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 246 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 247 | queue(const container_type& __c, const _Alloc& __a, |
| 248 | typename enable_if<uses_allocator<container_type, |
| 249 | _Alloc>::value>::type* = 0) |
| 250 | : c(__c, __a) {} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 251 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 252 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 253 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 254 | queue(container_type&& __c, const _Alloc& __a, |
| 255 | typename enable_if<uses_allocator<container_type, |
| 256 | _Alloc>::value>::type* = 0) |
| 257 | : c(_STD::move(__c), __a) {} |
| 258 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 259 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 260 | queue(queue&& __q, const _Alloc& __a, |
| 261 | typename enable_if<uses_allocator<container_type, |
| 262 | _Alloc>::value>::type* = 0) |
| 263 | : c(_STD::move(__q.c), __a) {} |
| 264 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 265 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 266 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 267 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 268 | bool empty() const {return c.empty();} |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 269 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 270 | size_type size() const {return c.size();} |
| 271 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 272 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 273 | reference front() {return c.front();} |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 274 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 275 | const_reference front() const {return c.front();} |
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 back() {return c.back();} |
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 back() const {return c.back();} |
| 280 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 281 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 282 | void push(const value_type& __v) {c.push_back(__v);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 283 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 284 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 285 | void push(value_type&& __v) {c.push_back(_STD::move(__v));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 286 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 287 | template <class... _Args> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 288 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 289 | void emplace(_Args&&... __args) |
| 290 | {c.emplace_back(_STD::forward<_Args>(__args)...);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 291 | #endif // _LIBCPP_HAS_NO_VARIADICS |
| 292 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 293 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 294 | void pop() {c.pop_front();} |
| 295 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 296 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 297 | void swap(queue& __q) |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 298 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 299 | { |
| 300 | using _STD::swap; |
| 301 | swap(c, __q.c); |
| 302 | } |
| 303 | |
| 304 | template <class _T1, class _C1> |
| 305 | friend |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 306 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 307 | bool |
| 308 | operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 309 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 310 | template <class _T1, class _C1> |
| 311 | friend |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 312 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 313 | bool |
| 314 | operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); |
| 315 | }; |
| 316 | |
| 317 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 318 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 319 | bool |
| 320 | operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 321 | { |
| 322 | return __x.c == __y.c; |
| 323 | } |
| 324 | |
| 325 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 326 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 327 | bool |
| 328 | operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 329 | { |
| 330 | return __x.c < __y.c; |
| 331 | } |
| 332 | |
| 333 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 334 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 335 | bool |
| 336 | operator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 337 | { |
| 338 | return !(__x == __y); |
| 339 | } |
| 340 | |
| 341 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 342 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 343 | bool |
| 344 | operator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 345 | { |
| 346 | return __y < __x; |
| 347 | } |
| 348 | |
| 349 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 350 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 351 | bool |
| 352 | operator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 353 | { |
| 354 | return !(__x < __y); |
| 355 | } |
| 356 | |
| 357 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 358 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 359 | bool |
| 360 | operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 361 | { |
| 362 | return !(__y < __x); |
| 363 | } |
| 364 | |
| 365 | template <class _Tp, class _Container> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 366 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 367 | void |
| 368 | swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 369 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 370 | { |
| 371 | __x.swap(__y); |
| 372 | } |
| 373 | |
| 374 | template <class _Tp, class _Container, class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 375 | struct _LIBCPP_VISIBLE uses_allocator<queue<_Tp, _Container>, _Alloc> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 376 | : public uses_allocator<_Container, _Alloc> |
| 377 | { |
| 378 | }; |
| 379 | |
| 380 | template <class _Tp, class _Container = vector<_Tp>, |
| 381 | class _Compare = less<typename _Container::value_type> > |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 382 | class _LIBCPP_VISIBLE priority_queue |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 383 | { |
| 384 | public: |
| 385 | typedef _Container container_type; |
| 386 | typedef _Compare value_compare; |
| 387 | typedef typename container_type::value_type value_type; |
| 388 | typedef typename container_type::reference reference; |
| 389 | typedef typename container_type::const_reference const_reference; |
| 390 | typedef typename container_type::size_type size_type; |
| 391 | |
| 392 | protected: |
| 393 | container_type c; |
| 394 | value_compare comp; |
| 395 | |
| 396 | public: |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 397 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 398 | priority_queue() |
| 399 | _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && |
| 400 | is_nothrow_default_constructible<value_compare>::value) |
| 401 | : c(), comp() {} |
| 402 | |
| 403 | _LIBCPP_INLINE_VISIBILITY |
| 404 | priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} |
| 405 | |
| 406 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 407 | _LIBCPP_INLINE_VISIBILITY |
| 408 | priority_queue(priority_queue&& __q) |
| 409 | _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && |
| 410 | is_nothrow_move_constructible<value_compare>::value) |
| 411 | : c(_STD::move(__q.c)), comp(_STD::move(__q.comp)) {} |
| 412 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 413 | |
| 414 | _LIBCPP_INLINE_VISIBILITY |
| 415 | priority_queue& operator=(const priority_queue& __q) |
| 416 | {c = __q.c; comp = __q.comp; return *this;} |
| 417 | |
| 418 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 419 | _LIBCPP_INLINE_VISIBILITY |
| 420 | priority_queue& operator=(priority_queue&& __q) |
| 421 | _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && |
| 422 | is_nothrow_move_assignable<value_compare>::value) |
| 423 | {c = _STD::move(__q.c); comp = _STD::move(__q.comp); return *this;} |
| 424 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 425 | |
| 426 | _LIBCPP_INLINE_VISIBILITY |
| 427 | explicit priority_queue(const value_compare& __comp) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 428 | : c(), comp(__comp) {} |
| 429 | priority_queue(const value_compare& __comp, const container_type& __c); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 430 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 431 | explicit priority_queue(const value_compare& __comp, container_type&& __c); |
| 432 | #endif |
| 433 | template <class _InputIter> |
| 434 | priority_queue(_InputIter __f, _InputIter __l, |
| 435 | const value_compare& __comp = value_compare()); |
| 436 | template <class _InputIter> |
| 437 | priority_queue(_InputIter __f, _InputIter __l, |
| 438 | const value_compare& __comp, const container_type& __c); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 439 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 440 | template <class _InputIter> |
| 441 | priority_queue(_InputIter __f, _InputIter __l, |
| 442 | const value_compare& __comp, container_type&& __c); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 443 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 444 | template <class _Alloc> |
| 445 | explicit priority_queue(const _Alloc& __a, |
| 446 | typename enable_if<uses_allocator<container_type, |
| 447 | _Alloc>::value>::type* = 0); |
| 448 | template <class _Alloc> |
| 449 | priority_queue(const value_compare& __comp, 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 container_type& __c, |
| 454 | const _Alloc& __a, |
| 455 | typename enable_if<uses_allocator<container_type, |
| 456 | _Alloc>::value>::type* = 0); |
| 457 | template <class _Alloc> |
| 458 | priority_queue(const priority_queue& __q, const _Alloc& __a, |
| 459 | typename enable_if<uses_allocator<container_type, |
| 460 | _Alloc>::value>::type* = 0); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 461 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 462 | template <class _Alloc> |
| 463 | priority_queue(const value_compare& __comp, container_type&& __c, |
| 464 | const _Alloc& __a, |
| 465 | typename enable_if<uses_allocator<container_type, |
| 466 | _Alloc>::value>::type* = 0); |
| 467 | template <class _Alloc> |
| 468 | priority_queue(priority_queue&& __q, const _Alloc& __a, |
| 469 | typename enable_if<uses_allocator<container_type, |
| 470 | _Alloc>::value>::type* = 0); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 471 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 472 | |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 473 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 474 | bool empty() const {return c.empty();} |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 475 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 476 | size_type size() const {return c.size();} |
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 | const_reference top() const {return c.front();} |
| 479 | |
| 480 | void push(const value_type& __v); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 481 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 482 | void push(value_type&& __v); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 483 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 484 | template <class... _Args> void emplace(_Args&&... __args); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 485 | #endif |
| 486 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 487 | void pop(); |
| 488 | |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 489 | void swap(priority_queue& __q) |
| 490 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && |
| 491 | __is_nothrow_swappable<value_compare>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 492 | }; |
| 493 | |
| 494 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 495 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 496 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, |
| 497 | const container_type& __c) |
| 498 | : c(__c), |
| 499 | comp(__comp) |
| 500 | { |
| 501 | _STD::make_heap(c.begin(), c.end(), comp); |
| 502 | } |
| 503 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 504 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 505 | |
| 506 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 507 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 508 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 509 | container_type&& __c) |
| 510 | : c(_STD::move(__c)), |
| 511 | comp(__comp) |
| 512 | { |
| 513 | _STD::make_heap(c.begin(), c.end(), comp); |
| 514 | } |
| 515 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 516 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 517 | |
| 518 | template <class _Tp, class _Container, class _Compare> |
| 519 | template <class _InputIter> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 520 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 521 | priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, |
| 522 | const value_compare& __comp) |
| 523 | : c(__f, __l), |
| 524 | comp(__comp) |
| 525 | { |
| 526 | _STD::make_heap(c.begin(), c.end(), comp); |
| 527 | } |
| 528 | |
| 529 | template <class _Tp, class _Container, class _Compare> |
| 530 | template <class _InputIter> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 531 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 532 | priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, |
| 533 | const value_compare& __comp, |
| 534 | const container_type& __c) |
| 535 | : c(__c), |
| 536 | comp(__comp) |
| 537 | { |
| 538 | c.insert(c.end(), __f, __l); |
| 539 | _STD::make_heap(c.begin(), c.end(), comp); |
| 540 | } |
| 541 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 542 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 543 | |
| 544 | template <class _Tp, class _Container, class _Compare> |
| 545 | template <class _InputIter> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 546 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 547 | priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, |
| 548 | const value_compare& __comp, |
| 549 | container_type&& __c) |
| 550 | : c(_STD::move(__c)), |
| 551 | comp(__comp) |
| 552 | { |
| 553 | c.insert(c.end(), __f, __l); |
| 554 | _STD::make_heap(c.begin(), c.end(), comp); |
| 555 | } |
| 556 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 557 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 558 | |
| 559 | template <class _Tp, class _Container, class _Compare> |
| 560 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 561 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 562 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, |
| 563 | typename enable_if<uses_allocator<container_type, |
| 564 | _Alloc>::value>::type*) |
| 565 | : c(__a) |
| 566 | { |
| 567 | } |
| 568 | |
| 569 | template <class _Tp, class _Container, class _Compare> |
| 570 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 571 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 572 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 573 | const _Alloc& __a, |
| 574 | typename enable_if<uses_allocator<container_type, |
| 575 | _Alloc>::value>::type*) |
| 576 | : c(__a), |
| 577 | comp(__comp) |
| 578 | { |
| 579 | } |
| 580 | |
| 581 | template <class _Tp, class _Container, class _Compare> |
| 582 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 583 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 584 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 585 | const container_type& __c, |
| 586 | const _Alloc& __a, |
| 587 | typename enable_if<uses_allocator<container_type, |
| 588 | _Alloc>::value>::type*) |
| 589 | : c(__c, __a), |
| 590 | comp(__comp) |
| 591 | { |
| 592 | _STD::make_heap(c.begin(), c.end(), comp); |
| 593 | } |
| 594 | |
| 595 | template <class _Tp, class _Container, class _Compare> |
| 596 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 597 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 598 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, |
| 599 | const _Alloc& __a, |
| 600 | typename enable_if<uses_allocator<container_type, |
| 601 | _Alloc>::value>::type*) |
| 602 | : c(__q.c, __a), |
| 603 | comp(__q.comp) |
| 604 | { |
| 605 | _STD::make_heap(c.begin(), c.end(), comp); |
| 606 | } |
| 607 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 608 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 609 | |
| 610 | template <class _Tp, class _Container, class _Compare> |
| 611 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 612 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 613 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 614 | container_type&& __c, |
| 615 | const _Alloc& __a, |
| 616 | typename enable_if<uses_allocator<container_type, |
| 617 | _Alloc>::value>::type*) |
| 618 | : c(_STD::move(__c), __a), |
| 619 | comp(__comp) |
| 620 | { |
| 621 | _STD::make_heap(c.begin(), c.end(), comp); |
| 622 | } |
| 623 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 624 | template <class _Tp, class _Container, class _Compare> |
| 625 | template <class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 626 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 627 | priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, |
| 628 | const _Alloc& __a, |
| 629 | typename enable_if<uses_allocator<container_type, |
| 630 | _Alloc>::value>::type*) |
| 631 | : c(_STD::move(__q.c), __a), |
| 632 | comp(_STD::move(__q.comp)) |
| 633 | { |
| 634 | _STD::make_heap(c.begin(), c.end(), comp); |
| 635 | } |
| 636 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 637 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 638 | |
| 639 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 640 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 641 | void |
| 642 | priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) |
| 643 | { |
| 644 | c.push_back(__v); |
| 645 | _STD::push_heap(c.begin(), c.end(), comp); |
| 646 | } |
| 647 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 648 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 649 | |
| 650 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 651 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 652 | void |
| 653 | priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) |
| 654 | { |
| 655 | c.push_back(_STD::move(__v)); |
| 656 | _STD::push_heap(c.begin(), c.end(), comp); |
| 657 | } |
| 658 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 659 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
| 660 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 661 | template <class _Tp, class _Container, class _Compare> |
| 662 | template <class... _Args> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 663 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 664 | void |
| 665 | priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) |
| 666 | { |
| 667 | c.emplace_back(_STD::forward<_Args>(__args)...); |
| 668 | _STD::push_heap(c.begin(), c.end(), comp); |
| 669 | } |
| 670 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 671 | #endif // _LIBCPP_HAS_NO_VARIADICS |
| 672 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 673 | |
| 674 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 675 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 676 | void |
| 677 | priority_queue<_Tp, _Container, _Compare>::pop() |
| 678 | { |
| 679 | _STD::pop_heap(c.begin(), c.end(), comp); |
| 680 | c.pop_back(); |
| 681 | } |
| 682 | |
| 683 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 684 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 685 | void |
| 686 | priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 687 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && |
| 688 | __is_nothrow_swappable<value_compare>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 689 | { |
| 690 | using _STD::swap; |
| 691 | swap(c, __q.c); |
| 692 | swap(comp, __q.comp); |
| 693 | } |
| 694 | |
| 695 | template <class _Tp, class _Container, class _Compare> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 696 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 697 | void |
| 698 | swap(priority_queue<_Tp, _Container, _Compare>& __x, |
| 699 | priority_queue<_Tp, _Container, _Compare>& __y) |
Howard Hinnant | 6a09441 | 2011-06-04 21:32:33 +0000 | [diff] [blame] | 700 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 701 | { |
| 702 | __x.swap(__y); |
| 703 | } |
| 704 | |
| 705 | template <class _Tp, class _Container, class _Compare, class _Alloc> |
Howard Hinnant | b9af2ea | 2010-09-22 18:02:38 +0000 | [diff] [blame] | 706 | struct _LIBCPP_VISIBLE uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 707 | : public uses_allocator<_Container, _Alloc> |
| 708 | { |
| 709 | }; |
| 710 | |
| 711 | _LIBCPP_END_NAMESPACE_STD |
| 712 | |
| 713 | #endif // _LIBCPP_QUEUE |