I am altering a relaxed A* program to use A* instead. As part of the A* algorithm there is the check:
if neighbor not in openSet
openSet.add(neighbor)
The openSet is a:
multiset<cells> OPL;
With cells being:
struct cells {
int currentCell;
float fCost;
};
So, I would like to add this check whether the neighbor already exists in the openSet to my code. However, a struct in a multiset is something I've not worked with before. The solution I've arrived at for now was inspired by this thread and works as such:
for (std::multiset<cells>::iterator it = OPL.begin(); it != OPL.end(); it++)
{
cells const & f = *it;
if(f.currentCell==neighborCell){
return false;
}
}
return true;
However, this seems inefficient. Originally I tried to see if I could use OPL.find() or something instead of having to run through the entire openSet each time, but I couldn't get it to work.
So I've come here to see whether some smart people have a better solution I can use and learn from ^^?