forked from MeLikeyCode/PacmanPathfindingDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.h
More file actions
48 lines (39 loc) · 909 Bytes
/
Node.h
File metadata and controls
48 lines (39 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef NODE_H
#define NODE_H
#include <vector>
class Graph;
/// Represents a node.
/// @author Abdullah Aghazadah
/// @date 4-20-15
///
/// A Node object is defined by its x and y values. Two Nodes are equivalent if they have the
/// same x and y values.
///
/// @see Graph PathGrid Edge
class Node{
public:
// constructors
Node();
Node( int x, int y); // every node needs an x and y coordinate - it is what defines them!
// readers (getters)
int x() const;
int y() const;
// modifiers (setters)
void setX( int x);
void setY( int y);
private:
int x_;
int y_;
};
// non member comparison operator
bool operator==(const Node& lhs, const Node& rhs);
// make node hashable
namespace std {
template <> struct hash<Node>
{
size_t operator()(const Node& node) const{
return hash<int>()(node.x()) + hash<int>()(node.y());
}
};
}
#endif // NODE_H