GNU g++  v5.2.1
GNU Standard C++
stl_queue.h File Reference

This is an internal header file, included by other library headers. More...

#include <bits/concept_check.h>
#include <debug/debug.h>
Include dependency graph for stl_queue.h:

Functions

namespace std _GLIBCXX_VISIBILITY (default)
 

Detailed Description

This is an internal header file, included by other library headers.

Do not attempt to use it directly. {queue}

Function Documentation

namespace std _GLIBCXX_VISIBILITY ( default  )

A standard container giving FIFO behavior.

Template Parameters
_TpType of element.
_SequenceType of underlying sequence, defaults to deque<_Tp>.

Meets many of the requirements of a container, but does not define anything to do with iterators. Very few of the other standard container interfaces are defined.

This is not a true container, but an adaptor. It holds another container, and provides a wrapper interface to that container. The wrapper is what enforces strict first-in-first-out queue behavior.

The second template parameter defines the type of the underlying sequence/container. It defaults to std::deque, but it can be any type that supports front, back, push_back, and pop_front, such as std::list or an appropriate user-defined type.

Members not found in normal containers are container_type, which is a typedef for the second Sequence parameter, and push and pop, which are standard queue/FIFO operations.

'c' is the underlying container. Maintainers wondering why this isn't uglified as per style guidelines should note that this name is specified in the standard, [23.2.3.1]. (Why? Presumably for the same reason that it's protected instead of private: to allow derivation. But none of the other containers allow for derivation. Odd.)

Default constructor creates no elements.

Returns true if the queue is empty.

Returns the number of elements in the queue.

Returns a read/write reference to the data at the first element of the queue.

Returns a read-only (constant) reference to the data at the first element of the queue.

Returns a read/write reference to the data at the last element of the queue.

Returns a read-only (constant) reference to the data at the last element of the queue.

Add data to the end of the queue.

Parameters
__xData to be added.

This is a typical queue operation. The function creates an element at the end of the queue and assigns the given data to it. The time complexity of the operation depends on the underlying sequence.

Removes first element.

This is a typical queue operation. It shrinks the queue by one. The time complexity of the operation depends on the underlying sequence.

Note that no data is returned, and if the first element's data is needed, it should be retrieved before pop() is called.

Queue equality comparison.

Parameters
__xA queue.
__yA queue of the same type as __x.
Returns
True iff the size and elements of the queues are equal.

This is an equivalence relation. Complexity and semantics depend on the underlying sequence type, but the expected rules are: this relation is linear in the size of the sequences, and queues are considered equivalent if their sequences compare equal.

Queue ordering relation.

Parameters
__xA queue.
__yA queue of the same type as x.
Returns
True iff __x is lexicographically less than __y.

This is an total ordering relation. Complexity and semantics depend on the underlying sequence type, but the expected rules are: this relation is linear in the size of the sequences, the elements must be comparable with <, and std::lexicographical_compare() is usually used to make the determination.

Based on operator==

Based on operator<

Based on operator<

Based on operator<

A standard container automatically sorting its contents.

Template Parameters
_TpType of element.
_SequenceType of underlying sequence, defaults to vector<_Tp>.
_CompareComparison function object type, defaults to less<_Sequence::value_type>.

This is not a true container, but an adaptor. It holds another container, and provides a wrapper interface to that container. The wrapper is what enforces priority-based sorting and queue behavior. Very few of the standard container/sequence interface requirements are met (e.g., iterators).

The second template parameter defines the type of the underlying sequence/container. It defaults to std::vector, but it can be any type that supports front(), push_back, pop_back, and random-access iterators, such as std::deque or an appropriate user-defined type.

The third template parameter supplies the means of making priority comparisons. It defaults to less<value_type> but can be anything defining a strict weak ordering.

Members not found in normal containers are container_type, which is a typedef for the second Sequence parameter, and push, pop, and top, which are standard queue operations.

Note
No equality/comparison operators are provided for priority_queue.
Sorting of the elements takes place as they are added to, and removed from, the priority_queue using the priority_queue's member functions. If you access the elements by other means, and change their data such that the sorting order would be different, the priority_queue will not re-sort the elements for you. (How could it know to do so?)

Default constructor creates no elements.

Builds a queue from a range.

Parameters
__firstAn input iterator.
__lastAn input iterator.
__xA comparison functor describing a strict weak ordering.
__sAn initial sequence with which to start.

Begins by copying __s, inserting a copy of the elements from [first,last) into the copy of __s, then ordering the copy according to __x.

For more information on function objects, see the documentation on functor base classes.

Returns true if the queue is empty.

Returns the number of elements in the queue.

Returns a read-only (constant) reference to the data at the first element of the queue.

Add data to the queue.

Parameters
__xData to be added.

This is a typical queue operation. The time complexity of the operation depends on the underlying sequence.

Removes first element.

This is a typical queue operation. It shrinks the queue by one. The time complexity of the operation depends on the underlying sequence.

Note that no data is returned, and if the first element's data is needed, it should be retrieved before pop() is called.

References __glibcxx_class_requires, __glibcxx_class_requires2, __glibcxx_class_requires4, __glibcxx_requires_nonempty, __glibcxx_requires_valid_range, std::__exception_ptr::operator!=(), std::__exception_ptr::operator==(), __gnu_debug::operator>(), __gnu_debug::operator>=(), and std::__exception_ptr::swap().

Here is the call graph for this function: