src/cx/list.h

changeset 1618
ef7cab6eb131
parent 1605
55b13f583356
equal deleted inserted replaced
1617:d4385f35f8b0 1618:ef7cab6eb131
58 CX_COLLECTION_BASE; 58 CX_COLLECTION_BASE;
59 /** 59 /**
60 * The list class definition. 60 * The list class definition.
61 */ 61 */
62 const cx_list_class *cl; 62 const cx_list_class *cl;
63 /**
64 * The actual implementation in case the list class is delegating.
65 */
66 const cx_list_class *climpl;
67 }; 63 };
68 64
69 /** 65 /**
70 * The class definition for arbitrary lists. 66 * The class definition for arbitrary lists.
71 */ 67 */
306 * ) { 302 * ) {
307 * if (allocator == NULL) { 303 * if (allocator == NULL) {
308 * allocator = cxDefaultAllocator; 304 * allocator = cxDefaultAllocator;
309 * } 305 * }
310 * 306 *
311 * MyCustomList *list = cxCalloc(allocator, 1, sizeof(MyCustomList)); 307 * MyCustomList *list = cxZalloc(allocator, sizeof(MyCustomList));
312 * if (list == NULL) return NULL; 308 * if (list == NULL) return NULL;
313 * 309 *
314 * // initialize 310 * // initialize
315 * cx_list_init((CxList*)list, &my_custom_list_class, 311 * cx_list_init((CxList*)list, &my_custom_list_class,
316 * allocator, elem_size); 312 * allocator, elem_size);
328 */ 324 */
329 cx_attr_nonnull_arg(1, 2, 3) 325 cx_attr_nonnull_arg(1, 2, 3)
330 CX_EXPORT void cx_list_init(struct cx_list_s *list, 326 CX_EXPORT void cx_list_init(struct cx_list_s *list,
331 struct cx_list_class_s *cl, const struct cx_allocator_s *allocator, 327 struct cx_list_class_s *cl, const struct cx_allocator_s *allocator,
332 size_t elem_size); 328 size_t elem_size);
329
330 /**
331 * A @c cx_compare_func2 compatible wrapper for the compare functions of a list.
332 *
333 * @param left first element
334 * @param right second element
335 * @param list the list which is comparing the elements
336 * @return the comparison result
337 */
338 cx_attr_nonnull
339 CX_EXPORT int cx_list_compare_wrapper(
340 const void *left, const void *right, void *list);
333 341
334 /** 342 /**
335 * Returns the number of elements currently stored in the list. 343 * Returns the number of elements currently stored in the list.
336 * 344 *
337 * @param list the list 345 * @param list the list

mercurial