-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid.h
41 lines (35 loc) · 773 Bytes
/
grid.h
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
#ifndef H_GRID
#define H_GRID
using namespace std;
struct Node {
// give access to private members for printing
friend ostream &operator<<( ostream &out, const Node& n);
Node();
Node(int _x, int _y);
Node(const Node& n);
bool operator==(const Node& n) const;
bool operator!=(const Node& n) const;
bool operator < (const Node& n) const;
int x;
int y;
};
ostream& operator<<(ostream& os, const Node& n);
class Grid {
public:
Grid(int h, int w);
~Grid();
int operator()(int i, int j);
int operator()(Node n);
int get(int i, int j);
int get(Node n);
bool set(int i, int j, int value);
bool ok(int i, int j);
int width();
int height();
private:
bool InBounds(int i, int j);
int* data;
int maxwidth;
int maxheight;
};
#endif