I am using a multiset to store a collection of objects ordered, I am using operator< to establish the order criteria, but I am doing something wrong because when I iterate through the multiset printing a trace, I can see that they are not ordered at all.... I'm really blocked with this issue...
I try to simplify my code here:
class CellSearch
{
public:
bool operator<(const CellSearch & C) const;
int getF() const { return _G + _H; }
private:
int _G;
int _H;
}
...
bool CellSearch::operator< (const CellSearch& C) const
{
return (this->getF() < C.getF());
}
the way I declare the multiset is:
std::multiset<CellSearch*> myOpenList;
and I insert a new element this way:
....
CellSearch *actualSearch = new CellSearch(start);
addOpenList(actualSearch, myOpenList);
And here is the function:
void Grid::addOpenList(CellSearch* actual, std::multiset<CellSearch*>& openList)
{
openList.insert(actual);
}
Is my first time using multiset...actually is my first container that is not a vector :) Can you see something wrong here?
I tried to summarize the code, I hope not too much...