src/cx/linked_list.h

changeset 879
9c24a4eb5ac9
parent 878
1c1ee61c01f9
equal deleted inserted replaced
878:1c1ee61c01f9 879:9c24a4eb5ac9
322 void *insert_begin, 322 void *insert_begin,
323 void *insert_end 323 void *insert_end
324 ) __attribute__((__nonnull__(6))); 324 ) __attribute__((__nonnull__(6)));
325 325
326 /** 326 /**
327 * Inserts a node into a sorted linked list.
328 * The new node must not be part of any list already.
329 *
330 * If the list starting with the node pointed to by \p begin is not sorted
331 * already, the behavior is undefined.
332 *
333 * @param begin a pointer to the begin node pointer (required)
334 * @param end a pointer to the end node pointer (if your list has one)
335 * @param loc_prev the location of a \c prev pointer within your node struct (negative if your struct does not have one)
336 * @param loc_next the location of a \c next pointer within your node struct (required)
337 * @param new_node a pointer to the node that shall be inserted
338 * @param cmp_func a compare function that will receive the node pointers
339 */
340 void cx_linked_list_insert_sorted(
341 void **begin,
342 void **end,
343 ptrdiff_t loc_prev,
344 ptrdiff_t loc_next,
345 void *new_node,
346 cx_compare_func cmp_func
347 ) __attribute__((__nonnull__(1, 5, 6)));
348
349 /**
350 * Inserts a chain of nodes into a sorted linked list.
351 * The chain must not be part of any list already.
352 *
353 * If either the list starting with the node pointed to by \p begin or the list
354 * starting with \p insert_begin is not sorted, the behavior is undefined.
355 *
356 * \attention In contrast to cx_linked_list_insert_chain(), the source chain
357 * will be broken and inserted into the target list so that the resulting list
358 * will be sorted according to \p cmp_func. That means, each node in the source
359 * chain may be re-linked with nodes from the target list.
360 *
361 * @param begin a pointer to the begin node pointer (required)
362 * @param end a pointer to the end node pointer (if your list has one)
363 * @param loc_prev the location of a \c prev pointer within your node struct (negative if your struct does not have one)
364 * @param loc_next the location of a \c next pointer within your node struct (required)
365 * @param insert_begin a pointer to the first node of the chain that shall be inserted
366 * @param cmp_func a compare function that will receive the node pointers
367 */
368 void cx_linked_list_insert_sorted_chain(
369 void **begin,
370 void **end,
371 ptrdiff_t loc_prev,
372 ptrdiff_t loc_next,
373 void *insert_begin,
374 cx_compare_func cmp_func
375 ) __attribute__((__nonnull__(1, 5, 6)));
376
377 /**
327 * Removes a node from the linked list. 378 * Removes a node from the linked list.
328 * 379 *
329 * If the node to remove is the begin (resp. end) node of the list and if \p begin (resp. \p end) 380 * If the node to remove is the begin (resp. end) node of the list and if \p begin (resp. \p end)
330 * addresses are provided, the pointers are adjusted accordingly. 381 * addresses are provided, the pointers are adjusted accordingly.
331 * 382 *

mercurial