src/cx/list.h

changeset 1433
81c301a59b7c
parent 1429
6e0c3a8a914a
equal deleted inserted replaced
1432:fb82e7a92258 1433:81c301a59b7c
86 void *(*insert_element)(struct cx_list_s *list, size_t index, const void *data); 86 void *(*insert_element)(struct cx_list_s *list, size_t index, const void *data);
87 87
88 /** 88 /**
89 * Member function for inserting multiple elements. 89 * Member function for inserting multiple elements.
90 * 90 *
91 * The data pointer may be @c NULL, in which case the function shall only allocate memory.
92 * Returns the number of successfully inserted or allocated elements.
93 *
91 * @see cx_list_default_insert_array() 94 * @see cx_list_default_insert_array()
92 */ 95 */
93 size_t (*insert_array)(struct cx_list_s *list, size_t index, const void *data, size_t n); 96 size_t (*insert_array)(struct cx_list_s *list, size_t index, const void *data, size_t n);
94 97
95 /** 98 /**
96 * Member function for inserting sorted elements into a sorted list. 99 * Member function for inserting sorted elements into a sorted list.
100 * Returns the number of successfully inserted elements.
97 * 101 *
98 * @see cx_list_default_insert_sorted() 102 * @see cx_list_default_insert_sorted()
99 */ 103 */
100 size_t (*insert_sorted)(struct cx_list_s *list, const void *sorted_data, size_t n); 104 size_t (*insert_sorted)(struct cx_list_s *list, const void *sorted_data, size_t n);
101 105
102 /** 106 /**
103 * Member function for inserting multiple elements if they do not exist. 107 * Member function for inserting multiple elements if they do not exist.
104 * 108 * Implementations shall return the number of successfully processed elements
109 * (including those which were not added because they are already contained).
105 * @see cx_list_default_insert_unique() 110 * @see cx_list_default_insert_unique()
106 */ 111 */
107 size_t (*insert_unique)(struct cx_list_s *list, const void *sorted_data, size_t n); 112 size_t (*insert_unique)(struct cx_list_s *list, const void *sorted_data, size_t n);
108 113
109 /** 114 /**
357 * 362 *
358 * @param list the list 363 * @param list the list
359 * @param array a pointer to the elements to add 364 * @param array a pointer to the elements to add
360 * @param n the number of elements to add 365 * @param n the number of elements to add
361 * @return the number of added elements 366 * @return the number of added elements
367 * @see cxListEmplaceArray()
362 */ 368 */
363 cx_attr_nonnull 369 cx_attr_nonnull
364 CX_EXPORT size_t cxListAddArray(CxList *list, const void *array, size_t n); 370 CX_EXPORT size_t cxListAddArray(CxList *list, const void *array, size_t n);
365 371
366 /** 372 /**
387 * 393 *
388 * @param list the list 394 * @param list the list
389 * @param index the index where to emplace the element 395 * @param index the index where to emplace the element
390 * @return a pointer to the allocated memory; @c NULL when the operation fails, or the index is out-of-bounds 396 * @return a pointer to the allocated memory; @c NULL when the operation fails, or the index is out-of-bounds
391 * @see cxListEmplace() 397 * @see cxListEmplace()
398 * @see cxListEmplaceArrayAt()
392 * @see cxListInsert() 399 * @see cxListInsert()
393 */ 400 */
394 cx_attr_nonnull 401 cx_attr_nonnull
395 CX_EXPORT void *cxListEmplaceAt(CxList *list, size_t index); 402 CX_EXPORT void *cxListEmplaceAt(CxList *list, size_t index);
396 403
404 * @see cxListEmplaceAt() 411 * @see cxListEmplaceAt()
405 * @see cxListAdd() 412 * @see cxListAdd()
406 */ 413 */
407 cx_attr_nonnull 414 cx_attr_nonnull
408 CX_EXPORT void *cxListEmplace(CxList *list); 415 CX_EXPORT void *cxListEmplace(CxList *list);
416
417 /**
418 * Allocates memory for multiple elements and returns an iterator.
419 *
420 * The iterator will only iterate over the successfully allocated elements.
421 * The @c elem_count attribute is set to that number, and the @c index attribute
422 * will range from zero to @c elem_count minus one.
423 *
424 * @remark When the list is storing pointers, the iterator will iterate over
425 * the @c void** elements.
426 *
427 * @param list the list
428 * @param index the index where to insert the new data
429 * @param n the number of elements for which to allocate the memory
430 * @return an iterator, iterating over the new memory
431 * @see cxListEmplaceAt()
432 * @see cxListInsertArray()
433 */
434 cx_attr_nonnull
435 CX_EXPORT CxIterator cxListEmplaceArrayAt(CxList *list, size_t index, size_t n);
436
437 /**
438 * Allocates memory for multiple elements and returns an iterator.
439 *
440 * The iterator will only iterate over the successfully allocated elements.
441 * The @c elem_count attribute is set to that number, and the @c index attribute
442 * will range from zero to @c elem_count minus one.
443 *
444 * @remark When the list is storing pointers, the iterator will iterate over
445 * the @c void** elements.
446 *
447 * @param list the list
448 * @param n the number of elements for which to allocate the memory
449 * @return an iterator, iterating over the new memory
450 * @see cxListEmplace()
451 * @see cxListAddArray()
452 */
453 cx_attr_nonnull
454 CX_EXPORT CxIterator cxListEmplaceArray(CxList *list, size_t n);
409 455
410 /** 456 /**
411 * Inserts an item into a sorted list. 457 * Inserts an item into a sorted list.
412 * 458 *
413 * If the list is not sorted already, the behavior is undefined. 459 * If the list is not sorted already, the behavior is undefined.
452 * @param list the list 498 * @param list the list
453 * @param index the index where to add the elements 499 * @param index the index where to add the elements
454 * @param array a pointer to the elements to add 500 * @param array a pointer to the elements to add
455 * @param n the number of elements to add 501 * @param n the number of elements to add
456 * @return the number of added elements 502 * @return the number of added elements
503 * @see cxListEmplaceArrayAt()
457 */ 504 */
458 cx_attr_nonnull 505 cx_attr_nonnull
459 CX_EXPORT size_t cxListInsertArray(CxList *list, size_t index, const void *array, size_t n); 506 CX_EXPORT size_t cxListInsertArray(CxList *list, size_t index, const void *array, size_t n);
460 507
461 /** 508 /**

mercurial