src/cx/array_list.h

changeset 1605
55b13f583356
parent 1507
f4010cda9a2a
child 1606
f5883f6e42e7
equal deleted inserted replaced
1604:68b75c091028 1605:55b13f583356
764 /** 764 /**
765 * Allocates an array list for storing elements with @p elem_size bytes each. 765 * Allocates an array list for storing elements with @p elem_size bytes each.
766 * 766 *
767 * If @p elem_size is #CX_STORE_POINTERS, the created list stores pointers instead of 767 * If @p elem_size is #CX_STORE_POINTERS, the created list stores pointers instead of
768 * copies of the added elements, and the compare function will be automatically set 768 * copies of the added elements, and the compare function will be automatically set
769 * to cx_cmp_ptr(), if none is given. 769 * to cx_cmp_ptr().
770 * 770 *
771 * @param allocator the allocator for allocating the list memory 771 * @param allocator the allocator for allocating the list memory
772 * (if @c NULL, the cxDefaultAllocator will be used) 772 * (if @c NULL, the cxDefaultAllocator will be used)
773 * @param comparator the comparator for the elements
774 * (if @c NULL, and the list is not storing pointers, sort and find
775 * functions will not work)
776 * @param elem_size the size of each element in bytes 773 * @param elem_size the size of each element in bytes
777 * @param initial_capacity the initial number of elements the array can store 774 * @param initial_capacity the initial number of elements the array can store
778 * @return the created list 775 * @return the created list
779 */ 776 */
780 cx_attr_nodiscard 777 cx_attr_nodiscard
781 cx_attr_malloc 778 cx_attr_malloc
782 cx_attr_dealloc(cxListFree, 1) 779 cx_attr_dealloc(cxListFree, 1)
783 CX_EXPORT CxList *cxArrayListCreate(const CxAllocator *allocator, 780 CX_EXPORT CxList *cxArrayListCreate(const CxAllocator *allocator,
784 cx_compare_func comparator, size_t elem_size, size_t initial_capacity); 781 size_t elem_size, size_t initial_capacity);
785
786 /**
787 * Allocates an array list for storing elements with @p elem_size bytes each.
788 *
789 * The list will use the cxDefaultAllocator and @em NO compare function.
790 * If you want to call functions that need a compare function, you have to
791 * set it immediately after creation or use cxArrayListCreate().
792 *
793 * If @p elem_size is #CX_STORE_POINTERS, the created list stores pointers instead of
794 * copies of the added elements and the compare function will be automatically set
795 * to cx_cmp_ptr().
796 *
797 * @param elem_size (@c size_t) the size of each element in bytes
798 * @param initial_capacity (@c size_t) the initial number of elements the array can store
799 * @return the created list
800 */
801 #define cxArrayListCreateSimple(elem_size, initial_capacity) \
802 cxArrayListCreate(NULL, NULL, elem_size, initial_capacity)
803 782
804 #ifdef __cplusplus 783 #ifdef __cplusplus
805 } // extern "C" 784 } // extern "C"
806 #endif 785 #endif
807 786

mercurial