|
priority_queue::priority_queuepublic member function
explicit priority_queue ( const Compare& x = Compare(), const Container& y = Container() ); template <class InputIterator> priority_queue ( InputIterator first, InputIterator last, const Compare& x = Compare(), const Container& y = Container() ); Construct priority queue Constructs a priority_queue container adaptor object.A container adaptor keeps a container object as data. This container object is a copy of parameter y, if any, otherwise it is an empty container. Because priority_queues satisfy the heap property the element popped from it is always the highest in the container. But the exact ordering criterium to determine this may be any that follow a strict weak ordering, which may be modified with an appropiate y parameter. The function effectively initializes the comparison and container objects and calls algorithm make_heap accordingly. Parameters
Example
The example does not produce any output, but it constructs different priority_queue objects: First is empty. Second contains the four ints defined for myints, with 60 (the highest) at its top. Third has the same four ints, but because it uses greater instead of the default (which is less), it has 10 as its top element. Fourth, fifth and sixth are very similar to first: they are all empty, except that these use mycomparison for comparisons, which is a special comparison function that behaves differently depending on a flag set on construction. ComplexityUp to linear in the number of initial elements.
|