88 CxList cxLinkedListFromArray( |
88 CxList cxLinkedListFromArray( |
89 CxAllocator allocator, |
89 CxAllocator allocator, |
90 CxListComparator comparator, |
90 CxListComparator comparator, |
91 size_t item_size, |
91 size_t item_size, |
92 size_t num_items, |
92 size_t num_items, |
93 const void *array |
93 void const *array |
94 ) __attribute__((__nonnull__)); |
94 ) __attribute__((__nonnull__)); |
95 |
95 |
96 /** |
96 /** |
97 * Deallocates the memory of the entire list. |
97 * Deallocates the memory of the entire list. |
98 * |
98 * |
137 * @param cmp_func a compare function to compare \p elem against the node data |
137 * @param cmp_func a compare function to compare \p elem against the node data |
138 * @param elem a pointer to the element to find |
138 * @param elem a pointer to the element to find |
139 * @return the index of the element or a past-one index if the element could not be found |
139 * @return the index of the element or a past-one index if the element could not be found |
140 */ |
140 */ |
141 size_t cx_linked_list_find( |
141 size_t cx_linked_list_find( |
142 void *start, |
142 void const *start, |
143 ptrdiff_t loc_advance, |
143 ptrdiff_t loc_advance, |
144 ptrdiff_t loc_data, |
144 ptrdiff_t loc_data, |
145 bool follow_ptr, |
145 bool follow_ptr, |
146 CxListComparator cmp_func, |
146 CxListComparator cmp_func, |
147 void *elem |
147 void const *elem |
148 ) __attribute__((__nonnull__)); |
148 ) __attribute__((__nonnull__)); |
149 |
149 |
150 /** |
150 /** |
151 * Finds the first node in a linked list. |
151 * Finds the first node in a linked list. |
152 * |
152 * |
353 * @param node the first node |
353 * @param node the first node |
354 * @param loc_next the location of the \c next pointer within the node struct |
354 * @param loc_next the location of the \c next pointer within the node struct |
355 * @return the size of the list or zero if \p node is \c NULL |
355 * @return the size of the list or zero if \p node is \c NULL |
356 */ |
356 */ |
357 size_t cx_linked_list_size( |
357 size_t cx_linked_list_size( |
358 void *node, |
358 void const *node, |
359 ptrdiff_t loc_next |
359 ptrdiff_t loc_next |
360 ); |
360 ); |
361 |
361 |
362 /** |
362 /** |
363 * Sorts a linked list based on a comparison function. |
363 * Sorts a linked list based on a comparison function. |
414 * If \c true, the data at \p loc_data is assumed to be a pointer, dereferenced, and then passed to \p cmp_func. |
414 * If \c true, the data at \p loc_data is assumed to be a pointer, dereferenced, and then passed to \p cmp_func. |
415 * @param cmp_func the function to compare the elements |
415 * @param cmp_func the function to compare the elements |
416 * @return |
416 * @return |
417 */ |
417 */ |
418 int cx_linked_list_compare( |
418 int cx_linked_list_compare( |
419 void *begin_left, |
419 void const *begin_left, |
420 void *begin_right, |
420 void const *begin_right, |
421 ptrdiff_t loc_advance, |
421 ptrdiff_t loc_advance, |
422 ptrdiff_t loc_data, |
422 ptrdiff_t loc_data, |
423 bool follow_ptr, |
423 bool follow_ptr, |
424 CxListComparator cmp_func |
424 CxListComparator cmp_func |
425 ) __attribute__((__nonnull__(6))); |
425 ) __attribute__((__nonnull__(6))); |