# std::priority_queue< Type, Sequence, Compare > Class Template Reference
[Containers, Sequences]

A standard container automatically sorting its contents. More...

`#include <stl_queue.h>`

List of all members.

## 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.

## Detailed Description

### template<typename Type, typename Sequence = vector<Type>, typename Compare = less<typename Sequence::value_type>>
class std::priority_queue< Type, Sequence, Compare >

A standard container automatically sorting its contents.

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 sorting and first-in-first-out 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/FIFO 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?)

Definition at line 339 of file stl_queue.h.

## Constructor & Destructor Documentation

template<typename Type, typename Sequence = vector<Type>, typename Compare = less<typename Sequence::value_type>>
std::priority_queue< Type, Sequence, Compare >::priority_queue | ( | const Compare & | x = `Compare()`,
|  | const Sequence & | s = `Sequence()`
| ) | `[inline, explicit]`

| Default constructor creates no elements. Definition at line 366 of file stl_queue.h. References std::make_heap().

template<typename Type, typename Sequence = vector<Type>, typename Compare = less<typename Sequence::value_type>>
template<typename InputIterator>
std::priority_queue< Type, Sequence, Compare >::priority_queue | ( | InputIterator | first,
|  | InputIterator | last,
|  | const Compare & | x = `Compare()`,
|  | const Sequence & | s = `Sequence()`
| ) | `[inline]`

  | Builds a queue from a range. Parameters:
  | 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.
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. Definition at line 387 of file stl_queue.h. References std::make_heap().

## Member Function Documentation

template<typename Type, typename Sequence = vector<Type>, typename Compare = less<typename Sequence::value_type>>
bool std::priority_queue< Type, Sequence, Compare >::empty | ( |  | ) | const`[inline]`

| Returns true if the queue is empty. Definition at line 401 of file stl_queue.h.

template<typename Type, typename Sequence = vector<Type>, typename Compare = less<typename Sequence::value_type>>
void std::priority_queue< Type, 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 453 of file stl_queue.h. References std::pop_heap().

template<typename Type, typename Sequence = vector<Type>, typename Compare = less<typename Sequence::value_type>>
void std::priority_queue< Type, Sequence, Compare >::push | ( | const value_type & | x | ) | `[inline]`

  | Add data to the queue. Parameters:
  | x | Data to be added.
This is a typical queue operation. The time complexity of the operation depends on the underlying sequence. Definition at line 427 of file stl_queue.h. References std::priority_queue< Type, Sequence, Compare >::push(), and std::push_heap(). Referenced by std::priority_queue< Type, Sequence, Compare >::push().

template<typename Type, typename Sequence = vector<Type>, typename Compare = less<typename Sequence::value_type>>
size_type std::priority_queue< Type, Sequence, Compare >::size | ( |  | ) | const`[inline]`

| Returns the number of elements in the queue. Definition at line 405 of file stl_queue.h.

template<typename Type, typename Sequence = vector<Type>, typename Compare = less<typename Sequence::value_type>>
const_reference std::priority_queue< Type, Sequence, Compare >::top | ( |  | ) | const`[inline]`

| Returns a read-only (constant) reference to the data at the first element of the queue. Definition at line 412 of file stl_queue.h.

The documentation for this class was generated from the following file:

- stl_queue.h