OpenXcom  1.0
Open-source clone of the original X-Com
PathfindingOpenSet.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <queue>
21 
22 namespace OpenXcom
23 {
24 
25 class PathfindingNode;
26 
28 {
29  int _cost;
30  PathfindingNode *_node;
31 };
32 
37 {
38 public:
46  {
47  return b->_cost < a->_cost;
48  }
49 };
50 
55 {
56 public:
62  void push(PathfindingNode *node);
64  bool empty() const { return _queue.empty(); }
65 
66 private:
67  std::priority_queue<OpenSetEntry*, std::vector<OpenSetEntry*>, EntryCompare> _queue;
68 
70  void removeDiscarded();
71 };
72 
73 }
void push(PathfindingNode *node)
Adds a node to the set.
Definition: PathfindingOpenSet.cpp:77
Helper class to compare entries through pointers.
Definition: PathfindingOpenSet.h:36
~PathfindingOpenSet()
Cleans up the set and frees allocated memory.
Definition: PathfindingOpenSet.cpp:29
Definition: PathfindingOpenSet.h:27
A class that holds pathfinding info for a certain node on the map.
Definition: PathfindingNode.h:31
bool empty() const
Is the set empty?
Definition: PathfindingOpenSet.h:64
PathfindingNode * pop()
Gets the next node to check.
Definition: PathfindingOpenSet.cpp:57
A class that holds references to the nodes to be examined in pathfinding.
Definition: PathfindingOpenSet.h:54
bool operator()(OpenSetEntry *a, OpenSetEntry *b) const
Compares entries *a and *b.
Definition: PathfindingOpenSet.h:45
Definition: BaseInfoState.cpp:40