#include <stl_queue.h>
Public Member Functions | |
priority_queue (const _Compare &__x=_Compare(), const _Sequence &__s=_Sequence()) | |
Default constructor creates no elements. | |
template<typename _InputIterator> | |
priority_queue (_InputIterator __first, _InputIterator __last, const _Compare &__x=_Compare(), const _Sequence &__s=_Sequence()) | |
Builds a queue from a range. | |
bool | empty () const |
size_type | size () const |
const_reference | top () const |
void | push (const value_type &__x) |
Add data to the queue. | |
void | pop () |
Removes first element. | |
Protected Attributes | |
_Sequence | c |
_Compare | comp |
Private Types | |
typedef _Sequence::value_type | _Sequence_value_type |
typedef _Sequence::const_reference | const_reference |
typedef _Sequence::size_type | size_type |
typedef _Sequence | container_type |
Private Member Functions | |
__glibcxx_class_requires (_Tp, _SGIAssignableConcept) __glibcxx_class_requires(_Sequence | |
_SequenceConcept | __glibcxx_class_requires (_Sequence, _RandomAccessContainerConcept) __glibcxx_class_requires2(_Tp |
Private Attributes | |
_SequenceConcept | _Sequence_value_type |
_SequenceConcept _SameTypeConcept __glibcxx_class_requires4(_Compare, bool, _Tp, _Tp, _BinaryFunctionConcept) public typedef _Sequence::reference | reference |
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.
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?)
Definition at line 337 of file stl_queue.h.
typedef _Sequence::value_type std::priority_queue< _Tp, _Sequence, _Compare >::_Sequence_value_type [private] |
Definition at line 340 of file stl_queue.h.
typedef _Sequence::const_reference std::priority_queue< _Tp, _Sequence, _Compare >::const_reference [private] |
Definition at line 350 of file stl_queue.h.
typedef _Sequence std::priority_queue< _Tp, _Sequence, _Compare >::container_type [private] |
Definition at line 352 of file stl_queue.h.
typedef _Sequence::size_type std::priority_queue< _Tp, _Sequence, _Compare >::size_type [private] |
Definition at line 351 of file stl_queue.h.
std::priority_queue< _Tp, _Sequence, _Compare >::priority_queue | ( | const _Compare & | __x = _Compare() , |
|
const _Sequence & | __s = _Sequence() | |||
) | [inline, explicit] |
Default constructor creates no elements.
Definition at line 364 of file stl_queue.h.
References std::make_heap().
std::priority_queue< _Tp, _Sequence, _Compare >::priority_queue | ( | _InputIterator | __first, | |
_InputIterator | __last, | |||
const _Compare & | __x = _Compare() , |
|||
const _Sequence & | __s = _Sequence() | |||
) | [inline] |
Builds a queue from a range.
first | An input iterator. | |
last | An input iterator. | |
x | A comparison functor describing a strict weak ordering. | |
s | An initial sequence with which to start. |
For more information on function objects, see the documentation on functor base classes.
Definition at line 385 of file stl_queue.h.
References __glibcxx_requires_valid_range, std::priority_queue< _Tp, _Sequence, _Compare >::c, std::priority_queue< _Tp, _Sequence, _Compare >::comp, and std::make_heap().
_SequenceConcept std::priority_queue< _Tp, _Sequence, _Compare >::__glibcxx_class_requires | ( | _Sequence | , | |
_RandomAccessContainerConcept | ||||
) | [private] |
std::priority_queue< _Tp, _Sequence, _Compare >::__glibcxx_class_requires | ( | _Tp | , | |
_SGIAssignableConcept | ||||
) | [private] |
bool std::priority_queue< _Tp, _Sequence, _Compare >::empty | ( | ) | const [inline] |
Returns true if the queue is empty.
Definition at line 399 of file stl_queue.h.
References std::priority_queue< _Tp, _Sequence, _Compare >::c.
void std::priority_queue< _Tp, _Sequence, _Compare >::pop | ( | ) | [inline] |
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.
Definition at line 451 of file stl_queue.h.
References __glibcxx_requires_nonempty, __throw_exception_again, std::priority_queue< _Tp, _Sequence, _Compare >::c, std::priority_queue< _Tp, _Sequence, _Compare >::comp, and std::pop_heap().
void std::priority_queue< _Tp, _Sequence, _Compare >::push | ( | const value_type & | __x | ) | [inline] |
Add data to the queue.
x | Data to be added. |
Definition at line 425 of file stl_queue.h.
References __throw_exception_again, std::priority_queue< _Tp, _Sequence, _Compare >::c, std::priority_queue< _Tp, _Sequence, _Compare >::comp, and std::push_heap().
size_type std::priority_queue< _Tp, _Sequence, _Compare >::size | ( | ) | const [inline] |
Returns the number of elements in the queue.
Definition at line 403 of file stl_queue.h.
References std::priority_queue< _Tp, _Sequence, _Compare >::c.
const_reference std::priority_queue< _Tp, _Sequence, _Compare >::top | ( | ) | const [inline] |
Returns a read-only (constant) reference to the data at the first element of the queue.
Definition at line 410 of file stl_queue.h.
References __glibcxx_requires_nonempty, and std::priority_queue< _Tp, _Sequence, _Compare >::c.
_SequenceConcept std::priority_queue< _Tp, _Sequence, _Compare >::_Sequence_value_type [private] |
Definition at line 344 of file stl_queue.h.
_Sequence std::priority_queue< _Tp, _Sequence, _Compare >::c [protected] |
Definition at line 356 of file stl_queue.h.
Referenced by std::priority_queue< _Tp, _Sequence, _Compare >::empty(), std::priority_queue< _Tp, _Sequence, _Compare >::pop(), std::priority_queue< _Tp, _Sequence, _Compare >::priority_queue(), std::priority_queue< _Tp, _Sequence, _Compare >::push(), std::priority_queue< _Tp, _Sequence, _Compare >::size(), and std::priority_queue< _Tp, _Sequence, _Compare >::top().
_Compare std::priority_queue< _Tp, _Sequence, _Compare >::comp [protected] |
Definition at line 357 of file stl_queue.h.
Referenced by std::priority_queue< _Tp, _Sequence, _Compare >::pop(), std::priority_queue< _Tp, _Sequence, _Compare >::priority_queue(), and std::priority_queue< _Tp, _Sequence, _Compare >::push().
_SequenceConcept _SameTypeConcept __glibcxx_class_requires4 (_Compare, bool, _Tp,_Tp,_BinaryFunctionConcept) public typedef _Sequence::reference std::priority_queue< _Tp, _Sequence, _Compare >::reference [private] |
Definition at line 345 of file stl_queue.h.