224 size_t idx1, |
224 size_t idx1, |
225 size_t idx2 |
225 size_t idx2 |
226 ) __attribute__((__nonnull__)); |
226 ) __attribute__((__nonnull__)); |
227 |
227 |
228 /** |
228 /** |
229 * Allocates an array list for storing elements with \p item_size bytes each. |
229 * Allocates an array list for storing elements with \p elem_size bytes each. |
230 * |
230 * |
231 * If \p item_size is CX_STORE_POINTERS, the created list will be created as if |
231 * If \p elem_size is CX_STORE_POINTERS, the created list will be created as if |
232 * cxListStorePointers() was called immediately after creation and the compare |
232 * cxListStorePointers() was called immediately after creation and the compare |
233 * function will be automatically set to cx_cmp_ptr(), if none is given. |
233 * function will be automatically set to cx_cmp_ptr(), if none is given. |
234 * |
234 * |
235 * @param allocator the allocator for allocating the list memory |
235 * @param allocator the allocator for allocating the list memory |
236 * (if \c NULL the cxDefaultAllocator will be used) |
236 * (if \c NULL the cxDefaultAllocator will be used) |
237 * @param comparator the comparator for the elements |
237 * @param comparator the comparator for the elements |
238 * (if \c NULL, and the list is not storing pointers, sort and find |
238 * (if \c NULL, and the list is not storing pointers, sort and find |
239 * functions will not work) |
239 * functions will not work) |
240 * @param item_size the size of each element in bytes |
240 * @param elem_size the size of each element in bytes |
241 * @param initial_capacity the initial number of elements the array can store |
241 * @param initial_capacity the initial number of elements the array can store |
242 * @return the created list |
242 * @return the created list |
243 */ |
243 */ |
244 CxList *cxArrayListCreate( |
244 CxList *cxArrayListCreate( |
245 CxAllocator const *allocator, |
245 CxAllocator const *allocator, |
246 cx_compare_func comparator, |
246 cx_compare_func comparator, |
247 size_t item_size, |
247 size_t elem_size, |
248 size_t initial_capacity |
248 size_t initial_capacity |
249 ); |
249 ); |
250 |
250 |
251 /** |
251 /** |
252 * Allocates an array list for storing elements with \p item_size bytes each. |
252 * Allocates an array list for storing elements with \p elem_size bytes each. |
253 * |
253 * |
254 * The list will use the cxDefaultAllocator and \em NO compare function. |
254 * The list will use the cxDefaultAllocator and \em NO compare function. |
255 * If you want to call functions that need a compare function, you have to |
255 * If you want to call functions that need a compare function, you have to |
256 * set it immediately after creation or use cxArrayListCreate(). |
256 * set it immediately after creation or use cxArrayListCreate(). |
257 * |
257 * |
258 * If \p item_size is CX_STORE_POINTERS, the created list will be created as if |
258 * If \p elem_size is CX_STORE_POINTERS, the created list will be created as if |
259 * cxListStorePointers() was called immediately after creation and the compare |
259 * cxListStorePointers() was called immediately after creation and the compare |
260 * function will be automatically set to cx_cmp_ptr(). |
260 * function will be automatically set to cx_cmp_ptr(). |
261 * |
261 * |
262 * @param item_size the size of each element in bytes |
262 * @param elem_size the size of each element in bytes |
263 * @param initial_capacity the initial number of elements the array can store |
263 * @param initial_capacity the initial number of elements the array can store |
264 * @return the created list |
264 * @return the created list |
265 */ |
265 */ |
266 #define cxArrayListCreateSimple(item_size, initial_capacity) \ |
266 #define cxArrayListCreateSimple(elem_size, initial_capacity) \ |
267 cxArrayListCreate(NULL, NULL, item_size, initial_capacity) |
267 cxArrayListCreate(NULL, NULL, elem_size, initial_capacity) |
268 |
268 |
269 #ifdef __cplusplus |
269 #ifdef __cplusplus |
270 } // extern "C" |
270 } // extern "C" |
271 #endif |
271 #endif |
272 |
272 |