1 /* |
1 /* |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 * |
3 * |
4 * Copyright 2013 Olaf Wintermann. All rights reserved. |
4 * Copyright 2015 Olaf Wintermann. All rights reserved. |
5 * |
5 * |
6 * Redistribution and use in source and binary forms, with or without |
6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are met: |
7 * modification, are permitted provided that the following conditions are met: |
8 * |
8 * |
9 * 1. Redistributions of source code must retain the above copyright |
9 * 1. Redistributions of source code must retain the above copyright |
167 void ucx_list_free_a(UcxAllocator *allocator, UcxList *list); |
167 void ucx_list_free_a(UcxAllocator *allocator, UcxList *list); |
168 |
168 |
169 /** |
169 /** |
170 * Inserts an element at the end of the list. |
170 * Inserts an element at the end of the list. |
171 * |
171 * |
172 * 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 retrieved with |
173 * ucx_list_last(). |
173 * ucx_list_last(). |
174 * |
174 * |
175 * @param list the list where to append the data, or <code>NULL</code> to |
175 * @param list the list where to append the data, or <code>NULL</code> to |
176 * create a new list |
176 * create a new list |
177 * @param data the data to insert |
177 * @param data the data to insert |
271 * @param list the list to retrieve the element from |
271 * @param list the list to retrieve the element from |
272 * @param index index of the element to return |
272 * @param index index of the element to return |
273 * @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 |
274 * index is greater than the list size |
274 * index is greater than the list size |
275 */ |
275 */ |
276 UcxList *ucx_list_get(const UcxList *list, int index); |
276 UcxList *ucx_list_get(const UcxList *list, size_t index); |
277 |
277 |
278 /** |
278 /** |
279 * Returns the index of an element. |
279 * Returns the index of an element. |
280 * |
280 * |
281 * @param list the list where to search for the element |
281 * @param list the list where to search for the element |
348 * If the first element is removed, the list pointer changes. So it is |
348 * If the first element is removed, the list pointer changes. So it is |
349 * <i>highly recommended</i> to <i>always</i> update the pointer by calling |
349 * <i>highly recommended</i> to <i>always</i> update the pointer by calling |
350 * <code>mylist = ucx_list_remove(mylist, myelem);</code>. |
350 * <code>mylist = ucx_list_remove(mylist, myelem);</code>. |
351 * |
351 * |
352 * @param list the list from which the element shall be removed |
352 * @param list the list from which the element shall be removed |
353 * @param element the element to removed |
353 * @param element the element to remove |
354 * @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 |
355 * is now empty |
355 * is now empty |
356 */ |
356 */ |
357 UcxList *ucx_list_remove(UcxList *list, UcxList *element); |
357 UcxList *ucx_list_remove(UcxList *list, UcxList *element); |
358 |
358 |
361 * |
361 * |
362 * See ucx_list_remove() for details. |
362 * See ucx_list_remove() for details. |
363 * |
363 * |
364 * @param allocator the allocator to use |
364 * @param allocator the allocator to use |
365 * @param list the list from which the element shall be removed |
365 * @param list the list from which the element shall be removed |
366 * @param element the element to removed |
366 * @param element the element to remove |
367 * @return returns the updated list pointer or <code>NULL</code>, if the list |
367 * @return returns the updated list pointer or <code>NULL</code>, if the list |
368 * @see ucx_list_remove() |
368 * @see ucx_list_remove() |
369 */ |
369 */ |
370 UcxList *ucx_list_remove_a(UcxAllocator *allocator, UcxList *list, |
370 UcxList *ucx_list_remove_a(UcxAllocator *allocator, UcxList *list, |
371 UcxList *element); |
371 UcxList *element); |