54 * @param comparator the comparator for the elements |
54 * @param comparator the comparator for the elements |
55 * @param item_size the size of each element in bytes |
55 * @param item_size the size of each element in bytes |
56 * @return the created list |
56 * @return the created list |
57 */ |
57 */ |
58 CxList *cxLinkedListCreate( |
58 CxList *cxLinkedListCreate( |
59 CxAllocator *allocator, |
59 CxAllocator const *allocator, |
60 CxListComparator comparator, |
60 CxListComparator comparator, |
61 size_t item_size |
61 size_t item_size |
62 ) __attribute__((__nonnull__)); |
62 ) __attribute__((__nonnull__)); |
63 |
63 |
64 /** |
64 /** |
69 * @param allocator the allocator for allocating the list nodes |
69 * @param allocator the allocator for allocating the list nodes |
70 * @param comparator the comparator for the elements |
70 * @param comparator the comparator for the elements |
71 * @return the created list |
71 * @return the created list |
72 */ |
72 */ |
73 CxList *cxPointerLinkedListCreate( |
73 CxList *cxPointerLinkedListCreate( |
74 CxAllocator *allocator, |
74 CxAllocator const *allocator, |
75 CxListComparator comparator |
75 CxListComparator comparator |
76 ) __attribute__((__nonnull__)); |
76 ) __attribute__((__nonnull__)); |
77 |
77 |
78 /** |
78 /** |
79 * Creates a linked list using the data from an array. |
79 * Creates a linked list using the data from an array. |
84 * @param num_items the number of items |
84 * @param num_items the number of items |
85 * @param array the array data |
85 * @param array the array data |
86 * @return the created list |
86 * @return the created list |
87 */ |
87 */ |
88 CxList *cxLinkedListFromArray( |
88 CxList *cxLinkedListFromArray( |
89 CxAllocator *allocator, |
89 CxAllocator const *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 void const *array |
93 void const *array |
94 ) __attribute__((__nonnull__)); |
94 ) __attribute__((__nonnull__)); |
109 * @param loc_advance the location of the pointer to advance |
109 * @param loc_advance the location of the pointer to advance |
110 * @param index the search index |
110 * @param index the search index |
111 * @return the node found at the specified index |
111 * @return the node found at the specified index |
112 */ |
112 */ |
113 void *cx_linked_list_at( |
113 void *cx_linked_list_at( |
114 void *start, |
114 void const *start, |
115 size_t start_index, |
115 size_t start_index, |
116 ptrdiff_t loc_advance, |
116 ptrdiff_t loc_advance, |
117 size_t index |
117 size_t index |
118 ) __attribute__((__nonnull__)); |
118 ) __attribute__((__nonnull__)); |
119 |
119 |
148 * @param node a pointer to a node in the list |
148 * @param node a pointer to a node in the list |
149 * @param loc_prev the location of the \c prev pointer |
149 * @param loc_prev the location of the \c prev pointer |
150 * @return a pointer to the first node |
150 * @return a pointer to the first node |
151 */ |
151 */ |
152 void *cx_linked_list_first( |
152 void *cx_linked_list_first( |
153 void *node, |
153 void const *node, |
154 ptrdiff_t loc_prev |
154 ptrdiff_t loc_prev |
155 ) __attribute__((__nonnull__)); |
155 ) __attribute__((__nonnull__)); |
156 |
156 |
157 /** |
157 /** |
158 * Finds the last node in a linked list. |
158 * Finds the last node in a linked list. |
164 * @param node a pointer to a node in the list |
164 * @param node a pointer to a node in the list |
165 * @param loc_next the location of the \c next pointer |
165 * @param loc_next the location of the \c next pointer |
166 * @return a pointer to the last node |
166 * @return a pointer to the last node |
167 */ |
167 */ |
168 void *cx_linked_list_last( |
168 void *cx_linked_list_last( |
169 void *node, |
169 void const *node, |
170 ptrdiff_t loc_next |
170 ptrdiff_t loc_next |
171 ) __attribute__((__nonnull__)); |
171 ) __attribute__((__nonnull__)); |
172 |
172 |
173 /** |
173 /** |
174 * Finds the predecessor of a node in case it is not linked. |
174 * Finds the predecessor of a node in case it is not linked. |
179 * @param loc_next the location of the \c next pointer |
179 * @param loc_next the location of the \c next pointer |
180 * @param node the successor of the node to find |
180 * @param node the successor of the node to find |
181 * @return the node or \c NULL if \p node has no predecessor |
181 * @return the node or \c NULL if \p node has no predecessor |
182 */ |
182 */ |
183 void *cx_linked_list_prev( |
183 void *cx_linked_list_prev( |
184 void *begin, |
184 void const *begin, |
185 ptrdiff_t loc_next, |
185 ptrdiff_t loc_next, |
186 void *node |
186 void const *node |
187 ) __attribute__((__nonnull__)); |
187 ) __attribute__((__nonnull__)); |
188 |
188 |
189 /** |
189 /** |
190 * Adds a new node to a linked list. |
190 * Adds a new node to a linked list. |
191 * The node must not be part of any list already. |
191 * The node must not be part of any list already. |