/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/DynamicArray.h

  • Committer: Gustav Hartvigsson
  • Date: 2015-07-12 19:04:18 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150712190418-yi9rfito5ovnf6dy
* Made the code more easy to read.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
 
59
59
typedef struct SDynamicArrayPrivate SDynamicArrayPrivate;
60
60
 
61
 
struct SDynamicArray {
 
61
struct
 
62
SDynamicArray {
62
63
  SDynamicArrayPrivate * priv;
63
64
  size_t max_size;
64
65
  size_t last_item;
77
78
 *        Normally a function with the signature <tt> (DynamicArray * self,
78
79
          spointer item, spointer data) </tt> should be used but cast to FreeFunc.
79
80
 */
80
 
SDynamicArray * s_dynamic_array_new (size_t len, FreeFunc free_func);
 
81
SDynamicArray *
 
82
s_dynamic_array_new (size_t len, FreeFunc free_func);
81
83
 
82
84
/**
83
85
 * Frees the dynamic array.
84
86
 * 
85
87
 * after this is run the data will be lost.
86
88
 */
87
 
void s_dynamic_array_free (SDynamicArray * self, sboolean free_data);
 
89
void
 
90
s_dynamic_array_free (SDynamicArray * self, sboolean free_data);
88
91
 
89
92
 
90
93
/**
91
94
 * Get an item from the array.
92
95
 */
93
 
spointer s_dynamic_array_get (SDynamicArray * self, size_t index);
 
96
spointer
 
97
s_dynamic_array_get (SDynamicArray * self, size_t index);
94
98
 
95
99
/**
96
100
 *
97
101
 */
98
 
void s_dynamic_array_set (SDynamicArray * self, size_t index, spointer item);
 
102
void
 
103
s_dynamic_array_set (SDynamicArray * self, size_t index, spointer item);
99
104
 
100
105
/**
101
106
 * Get the size of the array, this is not the same as the length of the array.
104
109
 * 
105
110
 * To get the length of the array use s_dynamic_array_len ().
106
111
 */
107
 
size_t s_dynamic_array_size (SDynamicArray * self);
 
112
size_t
 
113
s_dynamic_array_size (SDynamicArray * self);
108
114
 
109
115
/**
110
116
 * Get the index of the last item in the array.
113
119
 * This is not the last item added to the array, necessary, it is the index
114
120
 * if the item that has the highest position in the array.
115
121
 */
116
 
size_t s_dynamic_array_last_item (SDynamicArray * self);
 
122
size_t
 
123
s_dynamic_array_last_item (SDynamicArray * self);
117
124
 
118
125
/**
119
126
 * Dumps a copy of the array. Must be cast.
122
129
 * 
123
130
 * Is null-terminated.
124
131
 */
125
 
spointer* s_dynamic_array_dump_array (SDynamicArray * self);
 
132
spointer *
 
133
s_dynamic_array_dump_array (SDynamicArray * self);
126
134
 
127
135
/**
128
136
 * Use a function on the array.
129
137
 */
130
 
void s_dynamic_array_for_each (SDynamicArray * self, ForEachFunc func,
 
138
void
 
139
s_dynamic_array_for_each (SDynamicArray * self, ForEachFunc func,
131
140
                             spointer data);
132
141
 
133
142
/** TODO
134
143
 * same as s_dynamic_array_for_each (), with the difference that it returns a new
135
144
 * SDynamicArray.
136
145
 */
137
 
SDynamicArray * s_dynamic_array_for_each_with_return (SDynamicArray * self,
 
146
SDynamicArray *
 
147
s_dynamic_array_for_each_with_return (SDynamicArray * self,
138
148
                                                   ForEachFunc func,
139
149
                                                   spointer data);
140
150