Priority queue of struct

Hello, I have the following struct:

1
2
3
4
5
6
7
typedef struct {
  string state;
  string parent;
  string action;
  int pathcost;
  int depth;
} node;


I need to create a priority queue based on this, which will prioritize based on the pathcost value. I can't find much on this. Also, if you know how this can be passed as a parameter recursively, I appreciate any code help there. Thanks for your time.
Need more information on the recursion part.

A queue is a first-in-first-out(FIFO) data structure.
A priority queue just bumps up elements as they are inserted to the end of their priority line.
Thinks of a priority queue having multiple waiting "lines" each with their own priority.
So when a new person comes along to wait he/she would wait at the end of the appropiate line based on their priority.
The queue would store all these waiting "lines" in one list sorted by priority.
There is a priority queue available in stl

http://www.cplusplus.com/reference/stl/priority_queue/

You need a comparison function between two structures which orders them by pathcost. You can add operator< to your class or have a separate comparison function


Topic archived. No new replies allowed.