-
Notifications
You must be signed in to change notification settings - Fork 1
/
Matrix.hpp
44 lines (35 loc) · 1.15 KB
/
Matrix.hpp
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
#ifndef Matrix_h_
#define Matrix_h_
#include <functional>
class Matrix {
Matrix(Matrix const&) = delete;
Matrix& operator=(Matrix const&) = delete;
public:
Matrix(int h,
int w);
virtual ~Matrix();
virtual void print() const;
unsigned short get(int i,
int j) const;
virtual void set(int i,
int j,
unsigned short v);
void swap();
void forEach(std::function<unsigned short(int, int,
unsigned short,
int)>f);
void forEach(int start,
int end,
std::function<unsigned short(int, int,
unsigned short,
int)>f);
protected:
unsigned short **read, **write, **tmp;
int w, h;
private:
unsigned short mod(int x,
int y) const;
int countAlive(int x,
int y) const;
};
#endif // ifndef Matrix_h_