/+junk/c_sdl_joypad_ducktape

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/c_sdl_joypad_ducktape

« back to all changes in this revision

Viewing changes to DynamicArray.h

  • Committer: Gustav Hartvigsson
  • Date: 2014-01-11 23:32:10 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20140111233210-2lnw8934cjd5p848
* reorganising code to be remove extra typedefs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef __H_DYNAMIC_ARRAY__
2
 
#define __H_DYNAMIC_ARRAY__
3
1
#include <stdlib.h>
4
2
 
5
3
/*
28
26
#define ARRAY_PADDING 8
29
27
 
30
28
/**
31
 
 * an opaque data structure that represents the dynamic array.
32
 
 */
33
 
typedef struct _DynamicArray DynamicArray;
34
 
 
35
 
/**
36
29
 * Represents a for each function.
37
30
 * 
38
31
 * @param self the dynamic array.
40
33
 * @returns data to be put in a new DynamicArray, if used with
41
34
 * dynamic_array_for_each_with_return.
42
35
 */
43
 
typedef void * (* ForEachFunc)(DynamicArray * self, void * item, void * data);
 
36
typedef void * (* ForEachFunc)(DynamicArray * self, void * data);
44
37
 
 
38
/**
 
39
 * an opaque data structure that represents the dynamic array.
 
40
 */
 
41
typedef struct _DynamicArray DynamicArray;
45
42
 
46
43
/**
47
44
 * Create a new dynamic array.
49
46
 * @param len The length of the initial array.
50
47
 * @param item_size The size of the items to be stored.
51
48
 */
52
 
DynamicArray * dynamic_array_new (size_t len);
 
49
DymamicArray * dynamic_array_new (size_t len);
53
50
 
54
51
/**
55
52
 * Frees the dynamic array.
62
59
/**
63
60
 * Get an item from the array.
64
61
 */
65
 
void * dynamic_array_get (DynamicArray * self, size_t index);
 
62
void * dynamic_array_get (DynamicArray * self, int index);
66
63
 
67
64
/**
68
65
 * Get the length of the array.
71
68
 
72
69
 
73
70
/**
74
 
 * Get the size of the array, this is not the same as the length of the array.
75
 
 * The size is the number of elements that can be allocated without resizing
76
 
 * the array.
77
 
 * 
78
 
 * To get the length of the array use dynamic_array_len ().
79
 
 */
80
 
size_t dynamic_array_size (DynamicArray * self);
81
 
 
82
 
 
83
 
/**
84
71
 * Add an item to the array.
85
72
 */
86
73
void dynamic_array_add (DynamicArray * self, void * item);
87
74
 
88
75
/**
89
 
 * Dumps a copy of the array. Must be cast.
 
76
 * Dumps a copy of the. Must be cast.
90
77
 * 
91
78
 * Is not freed when the dynamic array is freed.
92
79
 * 
108
95
                                                   ForEachFunc func,
109
96
                                                   void * data);
110
97
 
111
 
#endif /* #define __H_DYNAMIC_ARRAY__ */