OpenXcom
1.0
Open-source clone of the original X-Com
src
Battlescape
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
27
struct
OpenSetEntry
28
{
29
int
_cost;
30
PathfindingNode
*_node;
31
};
32
36
class
EntryCompare
37
{
38
public
:
45
bool
operator()
(
OpenSetEntry
*a,
OpenSetEntry
*b)
const
46
{
47
return
b->_cost < a->_cost;
48
}
49
};
50
54
class
PathfindingOpenSet
55
{
56
public
:
58
~PathfindingOpenSet
();
60
PathfindingNode
*
pop
();
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
}
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:36
OpenXcom::PathfindingOpenSet::~PathfindingOpenSet
~PathfindingOpenSet()
Cleans up the set and frees allocated memory.
Definition:
PathfindingOpenSet.cpp:29
OpenXcom::OpenSetEntry
Definition:
PathfindingOpenSet.h:27
OpenXcom::PathfindingNode
A class that holds pathfinding info for a certain node on the map.
Definition:
PathfindingNode.h:31
OpenXcom::PathfindingOpenSet::empty
bool empty() const
Is the set empty?
Definition:
PathfindingOpenSet.h:64
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:54
OpenXcom::EntryCompare::operator()
bool operator()(OpenSetEntry *a, OpenSetEntry *b) const
Compares entries *a and *b.
Definition:
PathfindingOpenSet.h:45
OpenXcom
Definition:
BaseInfoState.cpp:40
Generated by
1.8.14