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