Invalid Heap

Hey I am using a priority queue, and at some point when I using push I get the invalid heap error. I have no idea what to do about it. Any help will be appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  bool Manager::UCS()
{
	priority_queue<Brick,vector<Brick>,ComparatorGreaterThan> myQueue;
	myQueue.push(myBoard->getRoot());
	mySet.insert(myBoard->getRoot().getCoorddinates());
	while (!myQueue.empty())
	{
		Brick parent = myQueue.top();
		myQueue.pop();
		mySet.erase(parent.getCoorddinates());
		if (parent.getSym() == 'G')
		{
			cout << parent.getTrackCostUpToMe();
			return true;
		}
		stack<Brick> tempStack;
		returnNeighbours(parent, &tempStack,myBoard->getNode(parent.getFatherX(),parent.getFatherY()));
		while (!tempStack.empty())
		{
			tempStack.top().setTrackCostUpToMe(parent.getTrackCostUpToMe());

				if (mySet.find(tempStack.top().getCoorddinates()) == mySet.end())
				{
					myQueue.push(tempStack.top());
					mySet.insert(tempStack.top().getCoorddinates());
					tempStack.pop();
				}
				else 
					tempStack.pop();
		}
	}
	return false;
}


I also have a functor here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Manager
{
private:
	Parser *p;
	Board* myBoard;
	string algorithm;
	string text;
	unsigned int size;
	stack<Brick> *myStack;
	stack<Brick> *solution;
	stack<Brick> *temp;
	unsigned int trackCost;
	set<pair<int,int>> mySet;

	struct ComparatorGreaterThan {
		bool operator() (const Brick lhs, const Brick rhs) {
			return (lhs.getTrackCostUpToMe() > rhs.getTrackCostUpToMe());
		}
	};
public:
	Manager();
	~Manager();
	void Start();
	void parseText();
	void presentBoard() const;
	const void checkNeighbours( int i,  int j,const int x,const int y,stack<Brick> *tempStack, const Brick father)const;
	void returnNeighbours(const Brick node, stack<Brick>* tempStack,const Brick father);
	bool DFS(const Brick node,const int depth,const Brick father)const;
	void parseSolution();
	void IDDFS();
	void printSolution()const;
	bool UCS();
};

Last edited on
Probem solved, forgot to update operator=
Topic archived. No new replies allowed.