| 168 * Member function for reversing the order of the items. |
168 * Member function for reversing the order of the items. |
| 169 */ |
169 */ |
| 170 void (*reverse)(struct cx_list_s *list); |
170 void (*reverse)(struct cx_list_s *list); |
| 171 |
171 |
| 172 /** |
172 /** |
| |
173 * Optional member function for changing the capacity. |
| |
174 * If the list does not support overallocation, this can be set to @c NULL. |
| |
175 */ |
| |
176 int (*change_capacity)(struct cx_list_s *list, size_t new_capacity); |
| |
177 |
| |
178 /** |
| 173 * Member function for returning an iterator pointing to the specified index. |
179 * Member function for returning an iterator pointing to the specified index. |
| 174 */ |
180 */ |
| 175 struct cx_iterator_s (*iterator)(const struct cx_list_s *list, size_t index, bool backward); |
181 struct cx_iterator_s (*iterator)(const struct cx_list_s *list, size_t index, bool backward); |
| 176 }; |
182 }; |
| 177 |
183 |
| 1145 * @see cxListUnion() |
1151 * @see cxListUnion() |
| 1146 */ |
1152 */ |
| 1147 cx_attr_nonnull |
1153 cx_attr_nonnull |
| 1148 CX_EXPORT int cxListUnionSimple(CxList *dst, const CxList *src, const CxList *other); |
1154 CX_EXPORT int cxListUnionSimple(CxList *dst, const CxList *src, const CxList *other); |
| 1149 |
1155 |
| |
1156 /** |
| |
1157 * Asks the list to reserve enough memory for a given total number of elements. |
| |
1158 * |
| |
1159 * List implementations are free to choose if reserving memory upfront makes |
| |
1160 * sense. |
| |
1161 * For example, array-based implementations usually do support reserving memory |
| |
1162 * for additional elements while linked lists usually don't. |
| |
1163 * |
| |
1164 * @note When the requested capacity is smaller than the current size, |
| |
1165 * this function returns zero without performing any action. |
| |
1166 * |
| |
1167 * @param list the list |
| |
1168 * @param capacity the expected total number of elements |
| |
1169 * @retval zero on success or when overallocation is not supported |
| |
1170 * @retval non-zero when an allocation error occurred |
| |
1171 * @see cxListShrink() |
| |
1172 */ |
| |
1173 cx_attr_nonnull |
| |
1174 CX_EXPORT int cxListReserve(CxList *list, size_t capacity); |
| |
1175 |
| |
1176 /** |
| |
1177 * Advises the list to free any overallocated memory. |
| |
1178 * |
| |
1179 * Lists that do not support overallocation simply return zero. |
| |
1180 * |
| |
1181 * This function usually returns zero, except for very special and custom |
| |
1182 * list and/or allocator implementations where freeing memory can fail. |
| |
1183 * |
| |
1184 * @param list the list |
| |
1185 * @return usually zero |
| |
1186 */ |
| |
1187 cx_attr_nonnull |
| |
1188 CX_EXPORT int cxListShrink(CxList *list); |
| |
1189 |
| 1150 #ifdef __cplusplus |
1190 #ifdef __cplusplus |
| 1151 } // extern "C" |
1191 } // extern "C" |
| 1152 #endif |
1192 #endif |
| 1153 |
1193 |
| 1154 #endif // UCX_LIST_H |
1194 #endif // UCX_LIST_H |