59 #define _STL_QUEUE_H 1
64 namespace std _GLIBCXX_VISIBILITY(default)
66 _GLIBCXX_BEGIN_NAMESPACE_VERSION
91 template<
typename _Tp,
typename _Sequence = deque<_Tp> >
95 typedef typename _Sequence::value_type _Sequence_value_type;
96 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
97 __glibcxx_class_requires(_Sequence, _FrontInsertionSequenceConcept)
98 __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
99 __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
101 template<
typename _Tp1,
typename _Seq1>
105 template<
typename _Tp1,
typename _Seq1>
110 typedef typename _Sequence::value_type value_type;
111 typedef typename _Sequence::reference reference;
112 typedef typename _Sequence::const_reference const_reference;
113 typedef typename _Sequence::size_type size_type;
114 typedef _Sequence container_type;
131 #ifndef __GXX_EXPERIMENTAL_CXX0X__
133 queue(
const _Sequence& __c = _Sequence())
141 queue(_Sequence&& __c = _Sequence())
142 :
c(std::move(__c)) { }
150 {
return c.empty(); }
164 __glibcxx_requires_nonempty();
175 __glibcxx_requires_nonempty();
186 __glibcxx_requires_nonempty();
197 __glibcxx_requires_nonempty();
212 {
c.push_back(__x); }
214 #ifdef __GXX_EXPERIMENTAL_CXX0X__
216 push(value_type&& __x)
217 {
c.push_back(std::move(__x)); }
219 template<
typename... _Args>
221 emplace(_Args&&... __args)
222 {
c.emplace_back(std::forward<_Args>(__args)...); }
239 __glibcxx_requires_nonempty();
243 #ifdef __GXX_EXPERIMENTAL_CXX0X__
246 noexcept(noexcept(swap(
c, __q.c)))
265 template<
typename _Tp,
typename _Seq>
268 {
return __x.
c == __y.
c; }
283 template<
typename _Tp,
typename _Seq>
286 {
return __x.
c < __y.c; }
289 template<
typename _Tp,
typename _Seq>
292 {
return !(__x == __y); }
295 template<
typename _Tp,
typename _Seq>
298 {
return __y < __x; }
301 template<
typename _Tp,
typename _Seq>
304 {
return !(__y < __x); }
307 template<
typename _Tp,
typename _Seq>
310 {
return !(__x < __y); }
312 #ifdef __GXX_EXPERIMENTAL_CXX0X__
313 template<
typename _Tp,
typename _Seq>
315 swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
316 noexcept(noexcept(__x.swap(__y)))
319 template<
typename _Tp,
typename _Seq,
typename _Alloc>
320 struct uses_allocator<queue<_Tp, _Seq>, _Alloc>
321 :
public uses_allocator<_Seq, _Alloc>::type { };
359 template<
typename _Tp,
typename _Sequence = vector<_Tp>,
360 typename _Compare = less<
typename _Sequence::value_type> >
364 typedef typename _Sequence::value_type _Sequence_value_type;
365 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
366 __glibcxx_class_requires(_Sequence, _SequenceConcept)
367 __glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept)
368 __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
369 __glibcxx_class_requires4(_Compare,
bool, _Tp, _Tp,
370 _BinaryFunctionConcept)
373 typedef typename _Sequence::value_type value_type;
374 typedef typename _Sequence::reference reference;
375 typedef typename _Sequence::const_reference const_reference;
376 typedef typename _Sequence::size_type size_type;
377 typedef _Sequence container_type;
388 #ifndef __GXX_EXPERIMENTAL_CXX0X__
391 const _Sequence& __s = _Sequence())
397 const _Sequence& __s)
403 _Sequence&& __s = _Sequence())
404 : c(std::move(__s)), comp(__x)
423 #ifndef __GXX_EXPERIMENTAL_CXX0X__
424 template<
typename _InputIterator>
426 const _Compare& __x = _Compare(),
427 const _Sequence& __s = _Sequence())
430 __glibcxx_requires_valid_range(__first, __last);
431 c.insert(c.end(), __first, __last);
432 std::make_heap(c.begin(), c.end(), comp);
435 template<
typename _InputIterator>
438 const _Sequence& __s)
441 __glibcxx_requires_valid_range(__first, __last);
442 c.insert(c.end(), __first, __last);
446 template<
typename _InputIterator>
448 const _Compare& __x = _Compare(),
449 _Sequence&& __s = _Sequence())
450 : c(std::move(__s)), comp(__x)
452 __glibcxx_requires_valid_range(__first, __last);
453 c.insert(c.end(), __first, __last);
463 {
return c.empty(); }
477 __glibcxx_requires_nonempty();
496 #ifdef __GXX_EXPERIMENTAL_CXX0X__
498 push(value_type&& __x)
500 c.push_back(std::move(__x));
504 template<
typename... _Args>
506 emplace(_Args&&... __args)
508 c.emplace_back(std::forward<_Args>(__args)...);
509 std::push_heap(c.begin(), c.end(), comp);
527 __glibcxx_requires_nonempty();
532 #ifdef __GXX_EXPERIMENTAL_CXX0X__
535 noexcept(noexcept(swap(c, __pq.c)) && noexcept(swap(comp, __pq.comp)))
539 swap(comp, __pq.comp);
546 #ifdef __GXX_EXPERIMENTAL_CXX0X__
547 template<
typename _Tp,
typename _Sequence,
typename _Compare>
549 swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
550 priority_queue<_Tp, _Sequence, _Compare>& __y)
551 noexcept(noexcept(__x.swap(__y)))
554 template<
typename _Tp,
typename _Sequence,
typename _Compare,
556 struct uses_allocator<priority_queue<_Tp, _Sequence, _Compare>, _Alloc>
557 :
public uses_allocator<_Sequence, _Alloc>::type { };
560 _GLIBCXX_END_NAMESPACE_VERSION
A standard container giving FIFO behavior.
void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
Construct a heap over a range using comparison functor.
void push(const value_type &__x)
Add data to the queue.
void pop()
Removes first element.
void pop()
Removes first element.
const_reference front() const
queue(const _Sequence &__c)
Default constructor creates no elements.
priority_queue(_InputIterator __first, _InputIterator __last, const _Compare &__x, const _Sequence &__s)
Builds a queue from a range.
void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
Push an element onto a heap using comparison functor.
const_reference back() const
void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
Pop an element off a heap using comparison functor.
void push(const value_type &__x)
Add data to the end of the queue.
const_reference top() const
A standard container automatically sorting its contents.
priority_queue(const _Compare &__x, const _Sequence &__s)
Default constructor creates no elements.