I am trying to implement priority queue using heap in c++.The code given below is working fine.But i want to generate a file containing priority (integer)and value(char or string)associated to it. Now use this file as input it to the code below to generate a sequence of values in increasing order of priorities.
#include<queue>
#include <utility>
int main()
{
std::priority_queue<std::pair<int, std::string> > pq;
pq.push(std::make_pair(3, "Clear drains"));
pq.push(std::make_pair(4, "Feed cat"));
pq.push(std::make_pair(5, "Make tea"));
pq.push(std::make_pair(1, "Solve RC tasks"));
pq.push(std::make_pair(2, "Tax return"));
while (!pq.empty())
{
std::cout << pq.top().first << ", " << pq.top().second << std::endl;
pq.pop();
}
return 0;
}