Repository navigation
Expand file tree
/
Copy pathcgameoflife.cpp
More file actions
60 lines (51 loc) · 1.42 KB
/
Copy pathcgameoflife.cpp
File metadata and controls
60 lines (51 loc) · 1.42 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
55
56
57
58
59
60
#include "cgameoflife.h"
#include "gameoflife.h"
c_gameoflife_t* cgameoflife_alloc(int rows, int cols)
{
auto* wrapper = new c_gameoflife_t();
wrapper->data = new GameOfLife(rows, cols);
return wrapper;
}
void cgameoflife_dealloc(c_gameoflife_t* board)
{
auto* ptr = (GameOfLife*)board->data;
delete (GameOfLife*)ptr;
ptr = nullptr;
}
c_gameoflife_t* cgameoflife_clone(c_gameoflife_t* board)
{
auto* ptr = (GameOfLife*)board->data;
auto* wrapper = new c_gameoflife_t();
wrapper->data = new GameOfLife(*ptr);
return wrapper;
}
void cgameoflife_generate_board(c_gameoflife_t* board)
{
auto* ptr = (GameOfLife*)board->data;
ptr->generate_board();
}
uint8_t cgameoflife_count_alive_neighbors(c_gameoflife_t* board, int row, int col)
{
auto* ptr = (GameOfLife*)board->data;
return ptr->count_alive_neighbors(row, col);
}
size_t cgameoflife_count_alive_cells(c_gameoflife_t* board)
{
auto* ptr = (GameOfLife*)board->data;
return ptr->count_alive_cells();
}
void cgameoflife_update_board(c_gameoflife_t* board)
{
auto* ptr = (GameOfLife*)board->data;
ptr->update_board();
}
bool cgameoflife_get_cell(c_gameoflife_t* board, int row, int col)
{
auto* ptr = (GameOfLife*)board->data;
return ptr->get_cell(row, col);
}
void cgameoflife_set_cell(c_gameoflife_t* board, int row, int col, bool value)
{
auto* ptr = (GameOfLife*)board->data;
ptr->set_cell(row, col, value);
}