387 void *insert_begin, |
387 void *insert_begin, |
388 cx_compare_func cmp_func |
388 cx_compare_func cmp_func |
389 ); |
389 ); |
390 |
390 |
391 /** |
391 /** |
392 * Removes a node from the linked list. |
392 * Removes a chain of nodes from the linked list. |
393 * |
393 * |
394 * If the node to remove is the begin (resp. end) node of the list and if \p begin (resp. \p end) |
394 * If one of the nodes to remove is the begin (resp. end) node of the list and if \p begin (resp. \p end) |
395 * addresses are provided, the pointers are adjusted accordingly. |
395 * addresses are provided, the pointers are adjusted accordingly. |
396 * |
396 * |
397 * The following combinations of arguments are valid (more arguments are optional): |
397 * The following combinations of arguments are valid (more arguments are optional): |
398 * \li \p loc_next and \p loc_prev (ancestor node is determined by using the prev pointer, overall O(1) performance) |
398 * \li \p loc_next and \p loc_prev (ancestor node is determined by using the prev pointer, overall O(1) performance) |
399 * \li \p loc_next and \p begin (ancestor node is determined by list traversal, overall O(n) performance) |
399 * \li \p loc_next and \p begin (ancestor node is determined by list traversal, overall O(n) performance) |
400 * |
400 * |
401 * \remark The \c next and \c prev pointers of the removed node are not cleared by this function and may still be used |
401 * \remark The \c next and \c prev pointers of the removed node are not cleared by this function and may still be used |
402 * to traverse to a former adjacent node in the list. |
402 * to traverse to a former adjacent node in the list, or within the chain. |
403 * |
403 * |
404 * @param begin a pointer to the begin node pointer (optional) |
404 * @param begin a pointer to the begin node pointer (optional) |
405 * @param end a pointer to the end node pointer (optional) |
405 * @param end a pointer to the end node pointer (optional) |
406 * @param loc_prev the location of a \c prev pointer within your node struct (negative if your struct does not have one) |
406 * @param loc_prev the location of a \c prev pointer within your node struct (negative if your struct does not have one) |
407 * @param loc_next the location of a \c next pointer within your node struct (required) |
407 * @param loc_next the location of a \c next pointer within your node struct (required) |
|
408 * @param node the start node of the chain |
|
409 * @param num the number of nodes to remove |
|
410 * @return the actual number of nodes that were removed (may be less when the list did not have enough nodes) |
|
411 */ |
|
412 __attribute__((__nonnull__(5))) |
|
413 size_t cx_linked_list_remove_chain( |
|
414 void **begin, |
|
415 void **end, |
|
416 ptrdiff_t loc_prev, |
|
417 ptrdiff_t loc_next, |
|
418 void *node, |
|
419 size_t num |
|
420 ); |
|
421 |
|
422 /** |
|
423 * Removes a node from the linked list. |
|
424 * |
|
425 * If the node to remove is the begin (resp. end) node of the list and if \p begin (resp. \p end) |
|
426 * addresses are provided, the pointers are adjusted accordingly. |
|
427 * |
|
428 * The following combinations of arguments are valid (more arguments are optional): |
|
429 * \li \p loc_next and \p loc_prev (ancestor node is determined by using the prev pointer, overall O(1) performance) |
|
430 * \li \p loc_next and \p begin (ancestor node is determined by list traversal, overall O(n) performance) |
|
431 * |
|
432 * \remark The \c next and \c prev pointers of the removed node are not cleared by this function and may still be used |
|
433 * to traverse to a former adjacent node in the list. |
|
434 * |
|
435 * @param begin a pointer to the begin node pointer (optional) |
|
436 * @param end a pointer to the end node pointer (optional) |
|
437 * @param loc_prev the location of a \c prev pointer within your node struct (negative if your struct does not have one) |
|
438 * @param loc_next the location of a \c next pointer within your node struct (required) |
408 * @param node the node to remove |
439 * @param node the node to remove |
409 */ |
440 */ |
410 __attribute__((__nonnull__(5))) |
441 __attribute__((__nonnull__(5))) |
411 void cx_linked_list_remove( |
442 static inline void cx_linked_list_remove( |
412 void **begin, |
443 void **begin, |
413 void **end, |
444 void **end, |
414 ptrdiff_t loc_prev, |
445 ptrdiff_t loc_prev, |
415 ptrdiff_t loc_next, |
446 ptrdiff_t loc_next, |
416 void *node |
447 void *node |
417 ); |
448 ) { |
418 |
449 cx_linked_list_remove_chain(begin, end, loc_prev, loc_next, node, 1); |
|
450 } |
419 |
451 |
420 /** |
452 /** |
421 * Determines the size of a linked list starting with \p node. |
453 * Determines the size of a linked list starting with \p node. |
422 * @param node the first node |
454 * @param node the first node |
423 * @param loc_next the location of the \c next pointer within the node struct |
455 * @param loc_next the location of the \c next pointer within the node struct |