src/cx/list.h

changeset 664
af5bf4603a5d
parent 655
7340c4255f1f
child 666
b5dd654deb3b
equal deleted inserted replaced
663:d50b5dc1e058 664:af5bf4603a5d
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 removing all elements.
168 */
169 void (*clear)(struct cx_list_s *list);
170
171 /**
167 * Member function for swapping two elements. 172 * Member function for swapping two elements.
168 */ 173 */
169 int (*swap)( 174 int (*swap)(
170 struct cx_list_s *list, 175 struct cx_list_s *list,
171 size_t i, 176 size_t i,
218 223
219 /** 224 /**
220 * Common type for all list implementations. 225 * Common type for all list implementations.
221 */ 226 */
222 typedef struct cx_list_s CxList; 227 typedef struct cx_list_s CxList;
228
229 /**
230 * Invokes the destructor function for a specific element.
231 *
232 * Usually only used by list implementations. There should be no need
233 * to invoke this function manually.
234 *
235 * @param list the list
236 * @param elem the element
237 */
238 __attribute__((__nonnull__))
239 void cx_list_invoke_destructor(
240 struct cx_list_s const *list,
241 void *elem
242 );
223 243
224 /** 244 /**
225 * Advises the list to store copies of the objects (default mode of operation). 245 * Advises the list to store copies of the objects (default mode of operation).
226 * 246 *
227 * Retrieving objects from this list will yield pointers to the copies stored 247 * Retrieving objects from this list will yield pointers to the copies stored
396 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1); 416 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1);
397 } 417 }
398 418
399 /** 419 /**
400 * Removes the element at the specified index. 420 * Removes the element at the specified index.
421 *
422 * If an element destructor function is specified, it is called before
423 * removing the element.
424 *
401 * @param list the list 425 * @param list the list
402 * @param index the index of the element 426 * @param index the index of the element
403 * @return zero on success, non-zero if the index is out of bounds 427 * @return zero on success, non-zero if the index is out of bounds
404 */ 428 */
405 __attribute__((__nonnull__)) 429 __attribute__((__nonnull__))
406 static inline int cxListRemove( 430 static inline int cxListRemove(
407 CxList *list, 431 CxList *list,
408 size_t index 432 size_t index
409 ) { 433 ) {
410 return list->cl->remove(list, index); 434 return list->cl->remove(list, index);
435 }
436
437 /**
438 * Removes all elements from this list.
439 *
440 * If an element destructor function is specified, it is called for each
441 * element before removing them.
442 *
443 * @param list the list
444 */
445 __attribute__((__nonnull__))
446 static inline void cxListClear(CxList *list) {
447 list->cl->clear(list);
411 } 448 }
412 449
413 /** 450 /**
414 * Swaps two items in the list. 451 * Swaps two items in the list.
415 * 452 *

mercurial