src/ucx/cx/array_list.h

changeset 490
d218607f5a7e
parent 438
22eca559aded
equal deleted inserted replaced
489:921f83a8943f 490:d218607f5a7e
99 99
100 /** 100 /**
101 * Copies elements from one array to another. 101 * Copies elements from one array to another.
102 * 102 *
103 * The elements are copied to the \p target array at the specified \p index, 103 * The elements are copied to the \p target array at the specified \p index,
104 * overwriting possible elements. The index must be in range of the current 104 * overwriting possible elements. The \p index does not need to be in range of
105 * array \p size. If the number of elements added would extend the array's size, 105 * the current array \p size. If the new index plus the number of elements added
106 * and \p capacity is not \c NULL, the remaining capacity is used. 106 * would extend the array's size, and \p capacity is not \c NULL, the remaining
107 * capacity is used.
107 * 108 *
108 * If the capacity is insufficient to hold the new data, a reallocation 109 * If the capacity is insufficient to hold the new data, a reallocation
109 * attempt is made, unless the allocator is set to \c NULL, in which case 110 * attempt is made, unless the allocator is set to \c NULL, in which case
110 * this function ultimately returns a failure. 111 * this function ultimately returns a failure.
111 * 112 *
149 ) __attribute__((__nonnull__)); 150 ) __attribute__((__nonnull__));
150 151
151 /** 152 /**
152 * Allocates an array list for storing elements with \p item_size bytes each. 153 * Allocates an array list for storing elements with \p item_size bytes each.
153 * 154 *
155 * If \p item_size is CX_STORE_POINTERS, the created list will be created as if
156 * cxListStorePointers() was called immediately after creation.
157 *
154 * @param allocator the allocator for allocating the list memory 158 * @param allocator the allocator for allocating the list memory
159 * (if \c NULL the cxDefaultAllocator will be used)
155 * @param comparator the comparator for the elements 160 * @param comparator the comparator for the elements
161 * (if \c NULL sort and find functions will not work)
156 * @param item_size the size of each element in bytes 162 * @param item_size the size of each element in bytes
157 * @param initial_capacity the initial number of elements the array can store 163 * @param initial_capacity the initial number of elements the array can store
158 * @return the created list 164 * @return the created list
159 */ 165 */
160 CxList *cxArrayListCreate( 166 CxList *cxArrayListCreate(
161 CxAllocator const *allocator, 167 CxAllocator const *allocator,
162 CxListComparator comparator, 168 cx_compare_func comparator,
163 size_t item_size, 169 size_t item_size,
164 size_t initial_capacity 170 size_t initial_capacity
165 ) __attribute__((__nonnull__)); 171 );
166 172
173 /**
174 * Allocates an array list for storing elements with \p item_size bytes each.
175 *
176 * The list will use the cxDefaultAllocator and \em NO compare function.
177 * If you want to call functions that need a compare function, you have to
178 * set it immediately after creation or use cxArrayListCreate().
179 *
180 * If \p item_size is CX_STORE_POINTERS, the created list will be created as if
181 * cxListStorePointers() was called immediately after creation.
182 *
183 * @param item_size the size of each element in bytes
184 * @param initial_capacity the initial number of elements the array can store
185 * @return the created list
186 */
187 #define cxArrayListCreateSimple(item_size, initial_capacity) \
188 cxArrayListCreate(NULL, NULL, item_size, initial_capacity)
167 189
168 #ifdef __cplusplus 190 #ifdef __cplusplus
169 } // extern "C" 191 } // extern "C"
170 #endif 192 #endif
171 193

mercurial