src/ucx/cx/list.h

changeset 504
c094afcdfb27
parent 490
d218607f5a7e
equal deleted inserted replaced
503:aeaf7db26fac 504:c094afcdfb27
68 * The class definition for arbitrary lists. 68 * The class definition for arbitrary lists.
69 */ 69 */
70 struct cx_list_class_s { 70 struct cx_list_class_s {
71 /** 71 /**
72 * Destructor function. 72 * Destructor function.
73 *
74 * Implementations SHALL invoke the content destructor functions if provided
75 * and SHALL deallocate the list memory, if an allocator is provided.
73 */ 76 */
74 void (*destructor)(struct cx_list_s *list); 77 void (*destructor)(struct cx_list_s *list);
75 78
76 /** 79 /**
77 * Member function for inserting a single elements. 80 * Member function for inserting a single element.
78 * Implementors SHOULD see to performant implementations for corner cases. 81 * Implementors SHOULD see to performant implementations for corner cases.
79 */ 82 */
80 int (*insert_element)( 83 int (*insert_element)(
81 struct cx_list_s *list, 84 struct cx_list_s *list,
82 size_t index, 85 size_t index,
140 struct cx_list_s const *list, 143 struct cx_list_s const *list,
141 void const *elem 144 void const *elem
142 ); 145 );
143 146
144 /** 147 /**
145 * Member function for sorting the list in place. 148 * Member function for sorting the list in-place.
146 */ 149 */
147 void (*sort)(struct cx_list_s *list); 150 void (*sort)(struct cx_list_s *list);
148 151
149 /** 152 /**
150 * Member function for comparing this list to another list of the same type. 153 * Member function for comparing this list to another list of the same type.
579 ) { 582 ) {
580 return list->cl->find(list, elem); 583 return list->cl->find(list, elem);
581 } 584 }
582 585
583 /** 586 /**
584 * Sorts the list in place. 587 * Sorts the list in-place.
585 * 588 *
586 * \remark The underlying sort algorithm is implementation defined. 589 * \remark The underlying sort algorithm is implementation defined.
587 * 590 *
588 * @param list the list 591 * @param list the list
589 */ 592 */
630 * @param list the list which shall be destroyed 633 * @param list the list which shall be destroyed
631 */ 634 */
632 __attribute__((__nonnull__)) 635 __attribute__((__nonnull__))
633 void cxListDestroy(CxList *list); 636 void cxListDestroy(CxList *list);
634 637
638 /**
639 * A shared instance of an empty list.
640 *
641 * Writing to that list is undefined.
642 */
643 extern CxList * const cxEmptyList;
644
645
635 #ifdef __cplusplus 646 #ifdef __cplusplus
636 } // extern "C" 647 } // extern "C"
637 #endif 648 #endif
638 649
639 #endif // UCX_LIST_H 650 #endif // UCX_LIST_H

mercurial