bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
|
60
by Gustav Hartvigsson
* Added preliminary Matrix type and functions. |
1 |
#ifndef __GAME_MATRIX__
|
2 |
#define __GAME_MATRIX__
|
|
3 |
||
4 |
#include <string.h> |
|
5 |
#include <stdlib.h> |
|
6 |
#include <stdbool.h> |
|
7 |
#include <stdio.h> |
|
8 |
||
9 |
||
10 |
#include "defs.h" |
|
11 |
#include "DynamicArray.h" |
|
12 |
||
13 |
/**
|
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
14 |
* @file
|
15 |
* @defgroup SMatrix SMatrix
|
|
16 |
* @addtogroup SMatrix
|
|
17 |
* @{
|
|
|
60
by Gustav Hartvigsson
* Added preliminary Matrix type and functions. |
18 |
* A SMatrix is a 2d, square array.
|
19 |
*/
|
|
20 |
typedef struct _SMatrix SMatrix; |
|
21 |
||
22 |
||
23 |
SMatrix * |
|
24 |
s_matrix_new (size_t width, size_t height); |
|
25 |
||
26 |
void
|
|
27 |
s_matrix_free (SMatrix * self, bool free_data); |
|
28 |
||
29 |
/**
|
|
30 |
* Reallocate a SMatrix from one tuple width to an other.
|
|
31 |
*
|
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
32 |
* @note The new tuple size must be larger then the last, or it will be
|
33 |
* turnicated.
|
|
|
60
by Gustav Hartvigsson
* Added preliminary Matrix type and functions. |
34 |
*
|
35 |
* @note You need to free the old SMatrix yourself, this is to avoid memory
|
|
36 |
* leaks.
|
|
37 |
*/
|
|
38 |
SMatrix * |
|
39 |
s_matrix_realloc (SMatrix * self, size_t width); |
|
40 |
||
41 |
/**
|
|
42 |
* Get element y in tuple x.
|
|
43 |
*
|
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
44 |
* Equivalent to matrix[x][y] would be in static 2d arrays.
|
|
60
by Gustav Hartvigsson
* Added preliminary Matrix type and functions. |
45 |
*/
|
46 |
spointer
|
|
47 |
s_matrix_get (SMatrix * self, size_t x, size_t y); |
|
48 |
||
49 |
void
|
|
50 |
s_matrix_set (SMatrix * self, size_t x, size_t y, spointer data); |
|
51 |
||
52 |
spointer * |
|
53 |
s_matrix_get_tupel (SMatrix * self, size_t x); |
|
54 |
||
55 |
void
|
|
56 |
s_matrix_append (SMatrix * self, spointer data); |
|
57 |
||
58 |
SDynamicArray * |
|
59 |
s_matrix_get_tupel_as_dynamic_array (SMatrix * self, size_t x); |
|
60 |
||
61 |
/**
|
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
62 |
* This iterates over each tuple. giving the tuple as the item in the
|
|
60
by Gustav Hartvigsson
* Added preliminary Matrix type and functions. |
63 |
* callback function.
|
64 |
*/
|
|
65 |
void
|
|
66 |
s_matrix_foreach (SMatrix * self, ForEachFunc callback, spointer data); |
|
67 |
||
|
62
by Gustav Hartvigsson
* General documentation clean up. |
68 |
/** @} */
|
69 |
||
|
60
by Gustav Hartvigsson
* Added preliminary Matrix type and functions. |
70 |
#endif /*__GAME_MATRIX__ */ |