97 * <code>NULL</code>) |
98 * <code>NULL</code>) |
98 * @param data additional data for the copy_func() |
99 * @param data additional data for the copy_func() |
99 * @return a pointer to the copy |
100 * @return a pointer to the copy |
100 */ |
101 */ |
101 UcxList *ucx_list_clone(UcxList *list, copy_func cpyfnc, void* data); |
102 UcxList *ucx_list_clone(UcxList *list, copy_func cpyfnc, void* data); |
|
103 |
102 /** |
104 /** |
103 * Creates an element-wise copy of a list using an UcxAllocator. |
105 * Creates an element-wise copy of a list using an UcxAllocator. |
104 * |
106 * |
105 * See ucx_list_clone() for details. |
107 * See ucx_list_clone() for details. |
106 * |
108 * |
150 * to ucx_list_first() on the argument must return the argument itself) |
152 * to ucx_list_first() on the argument must return the argument itself) |
151 * |
153 * |
152 * @param list the list to free |
154 * @param list the list to free |
153 */ |
155 */ |
154 void ucx_list_free(UcxList *list); |
156 void ucx_list_free(UcxList *list); |
|
157 |
155 /** |
158 /** |
156 * Destroys the entire list using an UcxAllocator. |
159 * Destroys the entire list using an UcxAllocator. |
157 * |
160 * |
158 * See ucx_list_free() for details. |
161 * See ucx_list_free() for details. |
159 * |
162 * |
160 * @param allocator the allocator to use |
163 * @param allocator the allocator to use |
161 * @param list the list to free |
164 * @param list the list to free |
162 * @see ucx_list_free() |
165 * @see ucx_list_free() |
163 */ |
166 */ |
164 void ucx_list_free_a(UcxAllocator *allocator, UcxList *list); |
167 void ucx_list_free_a(UcxAllocator *allocator, UcxList *list); |
|
168 |
165 /** |
169 /** |
166 * Inserts an element at the end of the list. |
170 * Inserts an element at the end of the list. |
167 * |
171 * |
168 * This is generally an O(n) operation, as the end of the list is seeked with |
172 * This is generally an O(n) operation, as the end of the list is seeked with |
169 * ucx_list_last(). |
173 * ucx_list_last(). |
173 * @param data the data to insert |
177 * @param data the data to insert |
174 * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to |
178 * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to |
175 * the newly created list otherwise |
179 * the newly created list otherwise |
176 */ |
180 */ |
177 UcxList *ucx_list_append(UcxList *list, void *data); |
181 UcxList *ucx_list_append(UcxList *list, void *data); |
|
182 |
178 /** |
183 /** |
179 * Inserts an element at the end of the list using an UcxAllocator. |
184 * Inserts an element at the end of the list using an UcxAllocator. |
180 * |
185 * |
181 * See ucx_list_append() for details. |
186 * See ucx_list_append() for details. |
182 * |
187 * |
187 * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to |
192 * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to |
188 * the newly created list otherwise |
193 * the newly created list otherwise |
189 * @see ucx_list_append() |
194 * @see ucx_list_append() |
190 */ |
195 */ |
191 UcxList *ucx_list_append_a(UcxAllocator *allocator, UcxList *list, void *data); |
196 UcxList *ucx_list_append_a(UcxAllocator *allocator, UcxList *list, void *data); |
|
197 |
192 /** |
198 /** |
193 * Inserts an element at the beginning of the list. |
199 * Inserts an element at the beginning of the list. |
194 * |
200 * |
195 * You <i>should</i> overwrite the old list pointer by calling |
201 * You <i>should</i> overwrite the old list pointer by calling |
196 * <code>mylist = ucx_list_prepend(mylist, mydata);</code>. However, you may |
202 * <code>mylist = ucx_list_prepend(mylist, mydata);</code>. However, you may |
202 * a new list |
208 * a new list |
203 * @param data the data to insert |
209 * @param data the data to insert |
204 * @return a pointer to the new list head |
210 * @return a pointer to the new list head |
205 */ |
211 */ |
206 UcxList *ucx_list_prepend(UcxList *list, void *data); |
212 UcxList *ucx_list_prepend(UcxList *list, void *data); |
|
213 |
207 /** |
214 /** |
208 * Inserts an element at the beginning of the list using an UcxAllocator. |
215 * Inserts an element at the beginning of the list using an UcxAllocator. |
209 * |
216 * |
210 * See ucx_list_prepend() for details. |
217 * See ucx_list_prepend() for details. |
211 * |
218 * |
215 * @param data the data to insert |
222 * @param data the data to insert |
216 * @return a pointer to the new list head |
223 * @return a pointer to the new list head |
217 * @see ucx_list_prepend() |
224 * @see ucx_list_prepend() |
218 */ |
225 */ |
219 UcxList *ucx_list_prepend_a(UcxAllocator *allocator, UcxList *list, void *data); |
226 UcxList *ucx_list_prepend_a(UcxAllocator *allocator, UcxList *list, void *data); |
|
227 |
220 /** |
228 /** |
221 * Concatenates two lists. |
229 * Concatenates two lists. |
222 * |
230 * |
223 * Either of the two arguments may be <code>NULL</code>. |
231 * Either of the two arguments may be <code>NULL</code>. |
224 * |
232 * |
230 * @param list2 second list |
238 * @param list2 second list |
231 * @return if <code>list1</code> is <code>NULL</code>, <code>list2</code> is |
239 * @return if <code>list1</code> is <code>NULL</code>, <code>list2</code> is |
232 * returned, otherwise <code>list1</code> is returned |
240 * returned, otherwise <code>list1</code> is returned |
233 */ |
241 */ |
234 UcxList *ucx_list_concat(UcxList *list1, UcxList *list2); |
242 UcxList *ucx_list_concat(UcxList *list1, UcxList *list2); |
|
243 |
235 /** |
244 /** |
236 * Returns the first element of a list. |
245 * Returns the first element of a list. |
237 * |
246 * |
238 * If the argument is the list pointer, it is directly returned. Otherwise |
247 * If the argument is the list pointer, it is directly returned. Otherwise |
239 * this function traverses to the first element of the list and returns the |
248 * this function traverses to the first element of the list and returns the |
241 * |
250 * |
242 * @param elem one element of the list |
251 * @param elem one element of the list |
243 * @return the first element of the list, the specified element is a member of |
252 * @return the first element of the list, the specified element is a member of |
244 */ |
253 */ |
245 UcxList *ucx_list_first(const UcxList *elem); |
254 UcxList *ucx_list_first(const UcxList *elem); |
|
255 |
246 /** |
256 /** |
247 * Returns the last element of a list. |
257 * Returns the last element of a list. |
248 * |
258 * |
249 * If the argument has no successor, it is the last element and therefore |
259 * If the argument has no successor, it is the last element and therefore |
250 * directly returned. Otherwise this function traverses to the last element of |
260 * directly returned. Otherwise this function traverses to the last element of |
252 * |
262 * |
253 * @param elem one element of the list |
263 * @param elem one element of the list |
254 * @return the last element of the list, the specified element is a member of |
264 * @return the last element of the list, the specified element is a member of |
255 */ |
265 */ |
256 UcxList *ucx_list_last(const UcxList *elem); |
266 UcxList *ucx_list_last(const UcxList *elem); |
|
267 |
257 /** |
268 /** |
258 * Returns the list element at the specified index. |
269 * Returns the list element at the specified index. |
259 * |
270 * |
260 * @param list the list to retrieve the element from |
271 * @param list the list to retrieve the element from |
261 * @param index index of the element to return |
272 * @param index index of the element to return |
262 * @return the element at the specified index or <code>NULL</code>, if the |
273 * @return the element at the specified index or <code>NULL</code>, if the |
263 * index is greater than the list size |
274 * index is greater than the list size |
264 */ |
275 */ |
265 UcxList *ucx_list_get(const UcxList *list, int index); |
276 UcxList *ucx_list_get(const UcxList *list, int index); |
|
277 |
266 /** |
278 /** |
267 * Returns the index of an element. |
279 * Returns the index of an element. |
268 * |
280 * |
269 * @param list the list where to search for the element |
281 * @param list the list where to search for the element |
270 * @param elem the element to find |
282 * @param elem the element to find |
271 * @return the index of the element or -1 if the list does not contain the |
283 * @return the index of the element or -1 if the list does not contain the |
272 * element |
284 * element |
273 */ |
285 */ |
274 ssize_t ucx_list_indexof(const UcxList *list, const UcxList *elem); |
286 ssize_t ucx_list_indexof(const UcxList *list, const UcxList *elem); |
|
287 |
275 /** |
288 /** |
276 * Returns the element count of the list. |
289 * Returns the element count of the list. |
277 * |
290 * |
278 * @param list the list whose elements are counted |
291 * @param list the list whose elements are counted |
279 * @return the element count |
292 * @return the element count |
280 */ |
293 */ |
281 size_t ucx_list_size(const UcxList *list); |
294 size_t ucx_list_size(const UcxList *list); |
|
295 |
282 /** |
296 /** |
283 * Returns the index of an element containing the specified data. |
297 * Returns the index of an element containing the specified data. |
284 * |
298 * |
285 * This function uses a cmp_func() to compare the data of each list element |
299 * This function uses a cmp_func() to compare the data of each list element |
286 * with the specified data. If no cmp_func is provided, the pointers are |
300 * with the specified data. If no cmp_func is provided, the pointers are |
295 * @param data additional data for the compare function |
309 * @param data additional data for the compare function |
296 * @return the index of the element containing the specified data or -1 if the |
310 * @return the index of the element containing the specified data or -1 if the |
297 * data is not found in this list |
311 * data is not found in this list |
298 */ |
312 */ |
299 ssize_t ucx_list_find(UcxList *list, void *elem, cmp_func cmpfnc, void *data); |
313 ssize_t ucx_list_find(UcxList *list, void *elem, cmp_func cmpfnc, void *data); |
|
314 |
300 /** |
315 /** |
301 * Checks, if a list contains a specific element. |
316 * Checks, if a list contains a specific element. |
302 * |
317 * |
303 * An element is found, if ucx_list_find() returns a value greater than -1. |
318 * An element is found, if ucx_list_find() returns a value greater than -1. |
304 * |
319 * |
338 * @param element the element to removed |
353 * @param element the element to removed |
339 * @return returns the updated list pointer or <code>NULL</code>, if the list |
354 * @return returns the updated list pointer or <code>NULL</code>, if the list |
340 * is now empty |
355 * is now empty |
341 */ |
356 */ |
342 UcxList *ucx_list_remove(UcxList *list, UcxList *element); |
357 UcxList *ucx_list_remove(UcxList *list, UcxList *element); |
|
358 |
343 /** |
359 /** |
344 * Removes an element from the list using an UcxAllocator. |
360 * Removes an element from the list using an UcxAllocator. |
345 * |
361 * |
346 * See ucx_list_remove() for details. |
362 * See ucx_list_remove() for details. |
347 * |
363 * |