Using priority_queue

Hello, i have some objects that I would want to keep in a priority, my question is how to make them in order by a specific value from the object

how do I make Brick, to be in order by cost in the queue?
1
2
3
4
5
6
7
8
9
10
  class Brick
{
private:
	pair<unsigned int,unsigned int> coordinates;
	char sym;
	unsigned int cost;
	bool isChecked;
public:
//////


Thanks for the help!
You can sort your data and then put it in the queue.
C++ come with a priority_queue. Have a look at
http://www.cplusplus.com/reference/queue/priority_queue/
I see, but it's something that I can't do. I need to implement Uniform-Cost-Search, so I don't have all the data at once, and it depends on the nodes. The pseudo code says to use priority_queue, so that's what I am trying to do.
@Thomas1965 I read it, but I didn't understand how to force to make the comparison by a specific value.
The priority_queue by default uses < to compare the elements; if you overload < for your class to compare costs, then that is how they will be sorted.
thanks Zhuge
Topic archived. No new replies allowed.