OpenXcom
1.0
Open-source clone of the original X-Com
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
src
Battlescape
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
29
struct
OpenSetEntry
30
{
31
int
_cost;
32
PathfindingNode
*_node;
33
};
34
38
class
EntryCompare
39
{
40
public
:
47
bool
operator()
(
OpenSetEntry
*a,
OpenSetEntry
*b)
const
48
{
49
return
b->_cost < a->_cost;
50
}
51
};
52
56
class
PathfindingOpenSet
57
{
58
public
:
60
~PathfindingOpenSet
();
62
PathfindingNode
*
pop
();
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
OpenXcom::PathfindingOpenSet::push
void push(PathfindingNode *node)
Adds a node to the set.
Definition:
PathfindingOpenSet.cpp:77
OpenXcom::EntryCompare
Helper class to compare entries through pointers.
Definition:
PathfindingOpenSet.h:38
OpenXcom::PathfindingOpenSet::~PathfindingOpenSet
~PathfindingOpenSet()
Cleans up the set and frees allocated memory.
Definition:
PathfindingOpenSet.cpp:29
OpenXcom::OpenSetEntry
Definition:
PathfindingOpenSet.h:29
OpenXcom::PathfindingNode
A class that holds pathfinding info for a certain node on the map.
Definition:
PathfindingNode.h:33
OpenXcom::EntryCompare::operator()
bool operator()(OpenSetEntry *a, OpenSetEntry *b) const
Compares entries *a and *b.
Definition:
PathfindingOpenSet.h:47
OpenXcom::PathfindingOpenSet::empty
bool empty() const
Is the set empty?
Definition:
PathfindingOpenSet.h:66
OpenXcom::PathfindingOpenSet::pop
PathfindingNode * pop()
Gets the next node to check.
Definition:
PathfindingOpenSet.cpp:57
OpenXcom::PathfindingOpenSet
A class that holds references to the nodes to be examined in pathfinding.
Definition:
PathfindingOpenSet.h:56
Generated on Fri Jun 13 2014 20:52:37 for OpenXcom by
1.8.7