src/cx/list.h

changeset 629
6c81ee4f11ad
parent 628
1e2be40f0cb5
child 630
ac5e7f789048
equal deleted inserted replaced
628:1e2be40f0cb5 629:6c81ee4f11ad
128 struct cx_list_s *list, 128 struct cx_list_s *list,
129 void const *elem 129 void const *elem
130 ); 130 );
131 131
132 /** 132 /**
133 * Member function for adding multiple elements.
134 */
135 size_t (*add_array)(
136 struct cx_list_s *list,
137 void const *array,
138 size_t n
139 );
140
141 /**
133 * Member function for inserting an element. 142 * Member function for inserting an element.
134 */ 143 */
135 int (*insert)( 144 int (*insert)(
136 struct cx_list_s *list, 145 struct cx_list_s *list,
137 size_t index, 146 size_t index,
207 * Adds an item to the end of the list. 216 * Adds an item to the end of the list.
208 * 217 *
209 * @param list the list 218 * @param list the list
210 * @param elem a pointer to the element to add 219 * @param elem a pointer to the element to add
211 * @return zero on success, non-zero on memory allocation failure 220 * @return zero on success, non-zero on memory allocation failure
221 * @see cxListAddArray()
212 */ 222 */
213 __attribute__((__nonnull__)) 223 __attribute__((__nonnull__))
214 static inline int cxListAdd( 224 static inline int cxListAdd(
215 CxList *list, 225 CxList *list,
216 void const *elem 226 void const *elem
217 ) { 227 ) {
218 return list->cl->add(list, elem); 228 return list->cl->add(list, elem);
229 }
230
231 /**
232 * Adds multiple items to the end of the list.
233 *
234 * This method is more efficient than invoking cxListAdd() multiple times.
235 *
236 * If there is not enough memory to add all elements, the returned value is
237 * less than \p n.
238 *
239 * @param list the list
240 * @param array a pointer to the elements to add
241 * @param n the number of elements to add
242 * @return the number of added elements
243 */
244 __attribute__((__nonnull__))
245 static inline size_t cxListAddArray(
246 CxList *list,
247 void const *array,
248 size_t n
249 ) {
250 return list->cl->add_array(list, array, n);
219 } 251 }
220 252
221 /** 253 /**
222 * Inserts an item at the specified index. 254 * Inserts an item at the specified index.
223 * 255 *

mercurial