#include <iostream>
#include <queue>
#include "pqueue.h"

using namespace std;

/* a priority_queue-nak nincsen iterátora.
   ezért hack-elünk egyet:
 */

template <typename T>
class my_priority_queue : public std::priority_queue<T>
{
public:
    typedef typename std::priority_queue<T>::container_type::iterator iterator;
    typedef typename std::priority_queue<T>::container_type::const_iterator const_iterator;

    iterator begin() { return std::priority_queue<T>::c.begin(); }
    const_iterator begin() const { return std::priority_queue<T>::c.begin(); }
    iterator end() { return std::priority_queue<T>::c.end(); }
    const_iterator end() const { return std::priority_queue<T>::c.end(); }
};

int main()
{
    my_priority_queue<int> mpq;
    mpq.push(4); mpq.push(9); mpq.push(3); mpq.push(1); mpq.push(4);

    cout << mpq.top() << endl;

    for ( my_priority_queue<int>::iterator it = mpq.begin();
                      it != mpq.end(); ++it)
    {
        cout << *it << " ";
    }
    cout << endl;

    *mpq.begin() = 2;   // very nasty :)

    // this is why we have no iterator for priority queue
    cout << mpq.top() << endl;
    cout << "=================================" << endl;

    pqueue<int> pq;
    pq.push(4); pq.push(9); pq.push(3); pq.push(1); pq.push(4);
    for ( pqueue<int>::const_iterator ci = pq.begin();
            ci != pq.end(); ++ci)
    {
        cout << *ci << " ";
    }
    cout << endl;

    // cout << *pq1.begin() << endl;
    cout << pq.pop() << endl;

    return 0;
}