src/cx/list.h

changeset 647
2e6e9d9f2159
parent 641
d402fead3386
child 655
7340c4255f1f
equal deleted inserted replaced
646:dfd0403ff8b6 647:2e6e9d9f2159
162 struct cx_list_s *list, 162 struct cx_list_s *list,
163 size_t index 163 size_t index
164 ); 164 );
165 165
166 /** 166 /**
167 * Member function for swapping two elements.
168 */
169 int (*swap)(
170 struct cx_list_s *list,
171 size_t i,
172 size_t j
173 );
174
175 /**
167 * Member function for element lookup. 176 * Member function for element lookup.
168 */ 177 */
169 void *(*at)( 178 void *(*at)(
170 struct cx_list_s const *list, 179 struct cx_list_s const *list,
171 size_t index 180 size_t index
399 ) { 408 ) {
400 return list->cl->remove(list, index); 409 return list->cl->remove(list, index);
401 } 410 }
402 411
403 /** 412 /**
413 * Swaps two items in the list.
414 *
415 * Implementations should only allocate temporary memory for the swap, if
416 * it is necessary.
417 *
418 * @param list the list
419 * @param i the index of the first element
420 * @param j the index of the second element
421 * @return zero on success, non-zero if one of the indices is out of bounds
422 */
423 __attribute__((__nonnull__))
424 static inline int cxListSwap(
425 CxList *list,
426 size_t i,
427 size_t j
428 ) {
429 return list->cl->swap(list, i, j);
430 }
431
432 /**
404 * Returns a pointer to the element at the specified index. 433 * Returns a pointer to the element at the specified index.
405 * 434 *
406 * @param list the list 435 * @param list the list
407 * @param index the index of the element 436 * @param index the index of the element
408 * @return a pointer to the element or \c NULL if the index is out of bounds 437 * @return a pointer to the element or \c NULL if the index is out of bounds

mercurial