218 |
223 |
219 /** |
224 /** |
220 * Common type for all list implementations. |
225 * Common type for all list implementations. |
221 */ |
226 */ |
222 typedef struct cx_list_s CxList; |
227 typedef struct cx_list_s CxList; |
|
228 |
|
229 /** |
|
230 * Invokes the destructor function for a specific element. |
|
231 * |
|
232 * Usually only used by list implementations. There should be no need |
|
233 * to invoke this function manually. |
|
234 * |
|
235 * @param list the list |
|
236 * @param elem the element |
|
237 */ |
|
238 __attribute__((__nonnull__)) |
|
239 void cx_list_invoke_destructor( |
|
240 struct cx_list_s const *list, |
|
241 void *elem |
|
242 ); |
223 |
243 |
224 /** |
244 /** |
225 * Advises the list to store copies of the objects (default mode of operation). |
245 * Advises the list to store copies of the objects (default mode of operation). |
226 * |
246 * |
227 * Retrieving objects from this list will yield pointers to the copies stored |
247 * Retrieving objects from this list will yield pointers to the copies stored |
396 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1); |
416 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1); |
397 } |
417 } |
398 |
418 |
399 /** |
419 /** |
400 * Removes the element at the specified index. |
420 * Removes the element at the specified index. |
|
421 * |
|
422 * If an element destructor function is specified, it is called before |
|
423 * removing the element. |
|
424 * |
401 * @param list the list |
425 * @param list the list |
402 * @param index the index of the element |
426 * @param index the index of the element |
403 * @return zero on success, non-zero if the index is out of bounds |
427 * @return zero on success, non-zero if the index is out of bounds |
404 */ |
428 */ |
405 __attribute__((__nonnull__)) |
429 __attribute__((__nonnull__)) |
406 static inline int cxListRemove( |
430 static inline int cxListRemove( |
407 CxList *list, |
431 CxList *list, |
408 size_t index |
432 size_t index |
409 ) { |
433 ) { |
410 return list->cl->remove(list, index); |
434 return list->cl->remove(list, index); |
|
435 } |
|
436 |
|
437 /** |
|
438 * Removes all elements from this list. |
|
439 * |
|
440 * If an element destructor function is specified, it is called for each |
|
441 * element before removing them. |
|
442 * |
|
443 * @param list the list |
|
444 */ |
|
445 __attribute__((__nonnull__)) |
|
446 static inline void cxListClear(CxList *list) { |
|
447 list->cl->clear(list); |
411 } |
448 } |
412 |
449 |
413 /** |
450 /** |
414 * Swaps two items in the list. |
451 * Swaps two items in the list. |
415 * |
452 * |