More fixes in Map::findPath

Fixed the styling, std::unique and removed the priority_queue comment
This commit is contained in:
sakagushi 2014-02-06 03:36:19 -02:00
parent 43524a9127
commit ff617c3fab
1 changed files with 5 additions and 5 deletions

View File

@ -697,7 +697,6 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
} }
std::unordered_map<Position, Node*, PositionHasher> nodes; std::unordered_map<Position, Node*, PositionHasher> nodes;
//std::priority_queue<Node*, std::vector<Node*>, LessNode> searchList;
std::deque<Node*> searchList; std::deque<Node*> searchList;
Node *currentNode = new Node(startPos); Node *currentNode = new Node(startPos);
@ -798,11 +797,12 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
} }
std::sort(searchList.begin(), searchList.end(), [](Node *a, Node *b) { return a->totalCost < b->totalCost; }); std::sort(searchList.begin(), searchList.end(), [](Node *a, Node *b) { return a->totalCost < b->totalCost; });
std::unique(searchList.begin(), searchList.end()); auto end = std::unique(searchList.begin(), searchList.end());
searchList.resize(std::distance(searchList.begin(), end));
currentNode->evaluated = true; currentNode->evaluated = true;
currentNode = nullptr; currentNode = nullptr;
while(searchList.size() > 0 && !currentNode) { while(!searchList.empty() && !currentNode) {
Node *node = searchList.front(); Node *node = searchList.front();
searchList.pop_front(); searchList.pop_front();