template<class T,
class Cont = vector<T>,
class Pred = less<Cont::value_type> >
class priority_queue {
public:
typedef Cont::allocator_type allocator_type;
typedef Cont::value_type value_type;
typedef Cont::size_type size_type;
explicit priority_queue(const Pred& pr = Pred(),
const allocator_type& al = allocator_type());
priority_queue(const value_type *first, const value_type *last,
const Pred& pr = Pred(), const allocator_type& al = allocator_type());
bool empty() const;
size_type size() const;
allocator_type get_allocator() const;
value_type& top();
const value_type& top() const;
void push(const value_type& x);
void pop();
protected:
Cont c;
Pred comp;
};
The template class describes an object that controls a varying-length sequence of elements. The object allocates and
frees storage for the sequence it controls through a protected object named c, of class Cont. The type T of elements in
the controlled sequence must match value_type.
The sequence is ordered using a protected object named comp. After each insertion or removal of the top element (at
position zero), for the iterators P0 and Pi designating elements at positions 0 and i, comp(*P0, *Pi) is false. (For
the default template parameter less<Cont::value_type>, the top element of the sequence compares largest, or
highest priority.)
An object of class Cont must supply random-access iterators and several public members defined the same as for
deque and vector (both of which are suitable candidates for class Cont). The required members are:
typedef T value_type;
typedef T0 size_type;
Cont(const A& al);
Cont(InIt first, InIt last, const allocator_type& al);
bool empty() const;
size_type size() const;
allocator_type get_allocator() const;
const value_type& front() const;
value_type& front();
void push_back(const value_type& x);
void pop_back();
Here, T0 is an unspecified type that meets the stated requirements.