59 * @return the created list |
59 * @return the created list |
60 */ |
60 */ |
61 cx_attr_nodiscard |
61 cx_attr_nodiscard |
62 cx_attr_malloc |
62 cx_attr_malloc |
63 cx_attr_dealloc(cxListFree, 1) |
63 cx_attr_dealloc(cxListFree, 1) |
|
64 cx_attr_export |
64 CxList *cxLinkedListCreate( |
65 CxList *cxLinkedListCreate( |
65 const CxAllocator *allocator, |
66 const CxAllocator *allocator, |
66 cx_compare_func comparator, |
67 cx_compare_func comparator, |
67 size_t elem_size |
68 size_t elem_size |
68 ); |
69 ); |
121 * @param found_index an optional pointer where the index of the found node |
123 * @param found_index an optional pointer where the index of the found node |
122 * (given that @p start has index 0) is stored |
124 * (given that @p start has index 0) is stored |
123 * @return the index of the element, if found - unspecified if not found |
125 * @return the index of the element, if found - unspecified if not found |
124 */ |
126 */ |
125 cx_attr_nonnull_arg(1, 4, 5) |
127 cx_attr_nonnull_arg(1, 4, 5) |
|
128 cx_attr_export |
126 void *cx_linked_list_find( |
129 void *cx_linked_list_find( |
127 const void *start, |
130 const void *start, |
128 ptrdiff_t loc_advance, |
131 ptrdiff_t loc_advance, |
129 ptrdiff_t loc_data, |
132 ptrdiff_t loc_data, |
130 cx_compare_func cmp_func, |
133 cx_compare_func cmp_func, |
196 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
202 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
197 * @param loc_next the location of a @c next pointer within your node struct (required) |
203 * @param loc_next the location of a @c next pointer within your node struct (required) |
198 * @param new_node a pointer to the node that shall be appended |
204 * @param new_node a pointer to the node that shall be appended |
199 */ |
205 */ |
200 cx_attr_nonnull_arg(5) |
206 cx_attr_nonnull_arg(5) |
|
207 cx_attr_export |
201 void cx_linked_list_add( |
208 void cx_linked_list_add( |
202 void **begin, |
209 void **begin, |
203 void **end, |
210 void **end, |
204 ptrdiff_t loc_prev, |
211 ptrdiff_t loc_prev, |
205 ptrdiff_t loc_next, |
212 ptrdiff_t loc_next, |
217 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
224 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
218 * @param loc_next the location of a @c next pointer within your node struct (required) |
225 * @param loc_next the location of a @c next pointer within your node struct (required) |
219 * @param new_node a pointer to the node that shall be prepended |
226 * @param new_node a pointer to the node that shall be prepended |
220 */ |
227 */ |
221 cx_attr_nonnull_arg(5) |
228 cx_attr_nonnull_arg(5) |
|
229 cx_attr_export |
222 void cx_linked_list_prepend( |
230 void cx_linked_list_prepend( |
223 void **begin, |
231 void **begin, |
224 void **end, |
232 void **end, |
225 ptrdiff_t loc_prev, |
233 ptrdiff_t loc_prev, |
226 ptrdiff_t loc_next, |
234 ptrdiff_t loc_next, |
234 * @param right the new successor of @p left |
242 * @param right the new successor of @p left |
235 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
243 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
236 * @param loc_next the location of a @c next pointer within your node struct (required) |
244 * @param loc_next the location of a @c next pointer within your node struct (required) |
237 */ |
245 */ |
238 cx_attr_nonnull |
246 cx_attr_nonnull |
|
247 cx_attr_export |
239 void cx_linked_list_link( |
248 void cx_linked_list_link( |
240 void *left, |
249 void *left, |
241 void *right, |
250 void *right, |
242 ptrdiff_t loc_prev, |
251 ptrdiff_t loc_prev, |
243 ptrdiff_t loc_next |
252 ptrdiff_t loc_next |
252 * @param right the successor of @p left |
261 * @param right the successor of @p left |
253 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
262 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
254 * @param loc_next the location of a @c next pointer within your node struct (required) |
263 * @param loc_next the location of a @c next pointer within your node struct (required) |
255 */ |
264 */ |
256 cx_attr_nonnull |
265 cx_attr_nonnull |
|
266 cx_attr_export |
257 void cx_linked_list_unlink( |
267 void cx_linked_list_unlink( |
258 void *left, |
268 void *left, |
259 void *right, |
269 void *right, |
260 ptrdiff_t loc_prev, |
270 ptrdiff_t loc_prev, |
261 ptrdiff_t loc_next |
271 ptrdiff_t loc_next |
274 * @param loc_next the location of a @c next pointer within your node struct (required) |
284 * @param loc_next the location of a @c next pointer within your node struct (required) |
275 * @param node the node after which to insert (@c NULL if you want to prepend the node to the list) |
285 * @param node the node after which to insert (@c NULL if you want to prepend the node to the list) |
276 * @param new_node a pointer to the node that shall be inserted |
286 * @param new_node a pointer to the node that shall be inserted |
277 */ |
287 */ |
278 cx_attr_nonnull_arg(6) |
288 cx_attr_nonnull_arg(6) |
|
289 cx_attr_export |
279 void cx_linked_list_insert( |
290 void cx_linked_list_insert( |
280 void **begin, |
291 void **begin, |
281 void **end, |
292 void **end, |
282 ptrdiff_t loc_prev, |
293 ptrdiff_t loc_prev, |
283 ptrdiff_t loc_next, |
294 ptrdiff_t loc_next, |
304 * @param node the node after which to insert (@c NULL to prepend the chain to the list) |
315 * @param node the node after which to insert (@c NULL to prepend the chain to the list) |
305 * @param insert_begin a pointer to the first node of the chain that shall be inserted |
316 * @param insert_begin a pointer to the first node of the chain that shall be inserted |
306 * @param insert_end a pointer to the last node of the chain (or NULL if the last node shall be determined) |
317 * @param insert_end a pointer to the last node of the chain (or NULL if the last node shall be determined) |
307 */ |
318 */ |
308 cx_attr_nonnull_arg(6) |
319 cx_attr_nonnull_arg(6) |
|
320 cx_attr_export |
309 void cx_linked_list_insert_chain( |
321 void cx_linked_list_insert_chain( |
310 void **begin, |
322 void **begin, |
311 void **end, |
323 void **end, |
312 ptrdiff_t loc_prev, |
324 ptrdiff_t loc_prev, |
313 ptrdiff_t loc_next, |
325 ptrdiff_t loc_next, |
329 * @param loc_next the location of a @c next pointer within your node struct (required) |
341 * @param loc_next the location of a @c next pointer within your node struct (required) |
330 * @param new_node a pointer to the node that shall be inserted |
342 * @param new_node a pointer to the node that shall be inserted |
331 * @param cmp_func a compare function that will receive the node pointers |
343 * @param cmp_func a compare function that will receive the node pointers |
332 */ |
344 */ |
333 cx_attr_nonnull_arg(1, 5, 6) |
345 cx_attr_nonnull_arg(1, 5, 6) |
|
346 cx_attr_export |
334 void cx_linked_list_insert_sorted( |
347 void cx_linked_list_insert_sorted( |
335 void **begin, |
348 void **begin, |
336 void **end, |
349 void **end, |
337 ptrdiff_t loc_prev, |
350 ptrdiff_t loc_prev, |
338 ptrdiff_t loc_next, |
351 ptrdiff_t loc_next, |
358 * @param loc_next the location of a @c next pointer within your node struct (required) |
371 * @param loc_next the location of a @c next pointer within your node struct (required) |
359 * @param insert_begin a pointer to the first node of the chain that shall be inserted |
372 * @param insert_begin a pointer to the first node of the chain that shall be inserted |
360 * @param cmp_func a compare function that will receive the node pointers |
373 * @param cmp_func a compare function that will receive the node pointers |
361 */ |
374 */ |
362 cx_attr_nonnull_arg(1, 5, 6) |
375 cx_attr_nonnull_arg(1, 5, 6) |
|
376 cx_attr_export |
363 void cx_linked_list_insert_sorted_chain( |
377 void cx_linked_list_insert_sorted_chain( |
364 void **begin, |
378 void **begin, |
365 void **end, |
379 void **end, |
366 ptrdiff_t loc_prev, |
380 ptrdiff_t loc_prev, |
367 ptrdiff_t loc_next, |
381 ptrdiff_t loc_next, |
389 * @param node the start node of the chain |
403 * @param node the start node of the chain |
390 * @param num the number of nodes to remove |
404 * @param num the number of nodes to remove |
391 * @return the actual number of nodes that were removed (can be less when the list did not have enough nodes) |
405 * @return the actual number of nodes that were removed (can be less when the list did not have enough nodes) |
392 */ |
406 */ |
393 cx_attr_nonnull_arg(5) |
407 cx_attr_nonnull_arg(5) |
|
408 cx_attr_export |
394 size_t cx_linked_list_remove_chain( |
409 size_t cx_linked_list_remove_chain( |
395 void **begin, |
410 void **begin, |
396 void **end, |
411 void **end, |
397 ptrdiff_t loc_prev, |
412 ptrdiff_t loc_prev, |
398 ptrdiff_t loc_next, |
413 ptrdiff_t loc_next, |
463 * @param loc_next the location of a @c next pointer within your node struct (required) |
480 * @param loc_next the location of a @c next pointer within your node struct (required) |
464 * @param loc_data the location of the @c data pointer within your node struct |
481 * @param loc_data the location of the @c data pointer within your node struct |
465 * @param cmp_func the compare function defining the sort order |
482 * @param cmp_func the compare function defining the sort order |
466 */ |
483 */ |
467 cx_attr_nonnull_arg(1, 6) |
484 cx_attr_nonnull_arg(1, 6) |
|
485 cx_attr_export |
468 void cx_linked_list_sort( |
486 void cx_linked_list_sort( |
469 void **begin, |
487 void **begin, |
470 void **end, |
488 void **end, |
471 ptrdiff_t loc_prev, |
489 ptrdiff_t loc_prev, |
472 ptrdiff_t loc_next, |
490 ptrdiff_t loc_next, |
487 * @param cmp_func the function to compare the elements |
505 * @param cmp_func the function to compare the elements |
488 * @return the first non-zero result of invoking @p cmp_func or: negative if the left list is smaller than the |
506 * @return the first non-zero result of invoking @p cmp_func or: negative if the left list is smaller than the |
489 * right list, positive if the left list is larger than the right list, zero if both lists are equal. |
507 * right list, positive if the left list is larger than the right list, zero if both lists are equal. |
490 */ |
508 */ |
491 cx_attr_nonnull_arg(5) |
509 cx_attr_nonnull_arg(5) |
|
510 cx_attr_export |
492 int cx_linked_list_compare( |
511 int cx_linked_list_compare( |
493 const void *begin_left, |
512 const void *begin_left, |
494 const void *begin_right, |
513 const void *begin_right, |
495 ptrdiff_t loc_advance, |
514 ptrdiff_t loc_advance, |
496 ptrdiff_t loc_data, |
515 ptrdiff_t loc_data, |
504 * @param end a pointer to the end node pointer (optional) |
523 * @param end a pointer to the end node pointer (optional) |
505 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
524 * @param loc_prev the location of a @c prev pointer within your node struct (negative if your struct does not have one) |
506 * @param loc_next the location of a @c next pointer within your node struct (required) |
525 * @param loc_next the location of a @c next pointer within your node struct (required) |
507 */ |
526 */ |
508 cx_attr_nonnull_arg(1) |
527 cx_attr_nonnull_arg(1) |
|
528 cx_attr_export |
509 void cx_linked_list_reverse( |
529 void cx_linked_list_reverse( |
510 void **begin, |
530 void **begin, |
511 void **end, |
531 void **end, |
512 ptrdiff_t loc_prev, |
532 ptrdiff_t loc_prev, |
513 ptrdiff_t loc_next |
533 ptrdiff_t loc_next |