-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathMap.h
More file actions
54 lines (44 loc) · 1.47 KB
/
Map.h
File metadata and controls
54 lines (44 loc) · 1.47 KB
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
49
50
51
52
53
54
#pragma once
#include <vector>
#include <utility>
#include <assert.h>
namespace Mapping {
typedef std::pair<int, int> Point;
typedef std::vector<Point> PointList;
class Map {
public:
virtual void Dump(const char* file, const PointList& points) const = 0;
virtual void CleanUp(void) const = 0;
virtual int GetWidth(void) const = 0;
virtual int GetHeight(void) const = 0;
virtual int GetMapData(const Point& point, bool abs) const = 0;
virtual bool IsValidPoint(const Point& point, bool abs) const = 0;
virtual bool SpaceHasFlag(int flag, const Point& point, bool abs) const = 0;
virtual bool PathHasFlag(int flag, const PointList& points, bool abs) const = 0;
virtual void AllowCritSpace(void) const = 0;
};
template <typename T> class Matrix {
private:
typedef std::vector<T> TList;
std::vector<TList> points;
int width, height;
public:
Matrix() : width(0), height(0) {
}
Matrix(int height, int width, T fill) {
this->width = width;
this->height = height;
points = std::vector<TList>(height);
for (int i = 0; i < height; i++)
points[i] = TList(width, fill);
}
T __fastcall GetPoint(int x, int y) const {
assert(x < height && y < width);
return points[x][y];
}
void SetPoint(int x, int y, T value) {
assert(x < height && y < width);
points[x][y] = value;
}
};
} // namespace Mapping