/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to src/Matrix.h

  • Committer: Gustav Hartvigsson
  • Date: 2015-07-12 17:44:05 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150712174405-bjm8dpmsfz3c1ww4
* Added preliminary Matrix type and functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
/**
 
14
 * A SMatrix is a 2d, square array.
 
15
 */
 
16
typedef struct _SMatrix SMatrix;
 
17
 
 
18
 
 
19
SMatrix *
 
20
s_matrix_new (size_t width, size_t height);
 
21
 
 
22
void
 
23
s_matrix_free (SMatrix * self, bool free_data);
 
24
 
 
25
/**
 
26
 * Reallocate a SMatrix from one tuple width to an other.
 
27
 *
 
28
 * @note The new tupel size must be larger then the laset, or it will be
 
29
 * tursicated.
 
30
 *
 
31
 * @note You need to free the old SMatrix yourself, this is to avoid memory
 
32
 * leaks.
 
33
 */
 
34
SMatrix *
 
35
s_matrix_realloc (SMatrix * self, size_t width);
 
36
 
 
37
/**
 
38
 * Get element y in tuple x.
 
39
 *
 
40
 * Equivilant to matrix[x][y] wolud be in static 2d arrays.
 
41
 */
 
42
spointer
 
43
s_matrix_get (SMatrix * self, size_t x, size_t y);
 
44
 
 
45
void
 
46
s_matrix_set (SMatrix * self, size_t x, size_t y, spointer data);
 
47
 
 
48
spointer *
 
49
s_matrix_get_tupel (SMatrix * self, size_t x);
 
50
 
 
51
void
 
52
s_matrix_append (SMatrix * self, spointer data);
 
53
 
 
54
SDynamicArray *
 
55
s_matrix_get_tupel_as_dynamic_array (SMatrix * self, size_t x);
 
56
 
 
57
/**
 
58
 * This itterates over each tuple. giving the tuple as the item in the
 
59
 * callback function.
 
60
 */
 
61
void
 
62
s_matrix_foreach (SMatrix * self, ForEachFunc callback, spointer data);
 
63
 
 
64
#endif /*__GAME_MATRIX__ */