| 808 * Creates an iterator over the elements of an array containing pointers. |
811 * Creates an iterator over the elements of an array containing pointers. |
| 809 * |
812 * |
| 810 * The iterator will yield the elements themselves, which are supposed to |
813 * The iterator will yield the elements themselves, which are supposed to |
| 811 * be pointers. |
814 * be pointers. |
| 812 * |
815 * |
| |
816 * This iterator cannot be used to remove elements |
| |
817 * because it does not get a modifiable reference to the array's size. |
| |
818 * |
| 813 * @param array the name of the array |
819 * @param array the name of the array |
| 814 * @return an iterator over the elements |
820 * @return an iterator over the elements |
| 815 * @see cx_array_iterator() |
821 * @see cx_array_iterator() |
| 816 */ |
822 */ |
| 817 #define cx_array_iterator_ptr(array) \ |
823 #define cx_array_iterator_ptr(array) \ |
| 818 cx_array_iterator_ptr_((CxArray*)&(array)) |
824 cx_array_iterator_ptr_((CxArray*)&(array)) |
| |
825 |
| |
826 |
| |
827 /** |
| |
828 * Removes elements from the array. |
| |
829 * |
| |
830 * Internal function - do not use. |
| |
831 * |
| |
832 * @param array a pointer to the array structure |
| |
833 * @param elem_size the size of one element |
| |
834 * @param index the index of the first element to remove |
| |
835 * @param n the number of elements to remove |
| |
836 * @param fast indicates whether tail elements should be copied into the gap |
| |
837 */ |
| |
838 cx_attr_nonnull |
| |
839 CX_EXPORT void cx_array_remove_(CxArray *array, size_t elem_size, size_t index, size_t n, bool fast); |
| |
840 |
| |
841 /** |
| |
842 * Removes one element from the array. |
| |
843 * |
| |
844 * Tail elements are all moved by one. If you don't need a stable order |
| |
845 * in the array, consider using cx_array_remove_fast(). |
| |
846 * |
| |
847 * If the index is out of bounds, this function does nothing. |
| |
848 * |
| |
849 * @param array the name of the array |
| |
850 * @param index (@c size_t) the index of the element to remove |
| |
851 * @see cx_array_remove_fast() |
| |
852 */ |
| |
853 #define cx_array_remove(array, index) \ |
| |
854 cx_array_remove_((CxArray*)&(array), sizeof((array).data[0]), index, 1, false) |
| |
855 |
| |
856 /** |
| |
857 * Removes one element from the array. |
| |
858 * |
| |
859 * The gap will be filled with a copy of the last element in the array. |
| |
860 * This changes the order of elements. If you want a stable order, |
| |
861 * use cx_array_remove() instead. |
| |
862 * |
| |
863 * If the index is out of bounds, this function does nothing. |
| |
864 * |
| |
865 * @param array the name of the array |
| |
866 * @param index (@c size_t) the index of the element to remove |
| |
867 * @see cx_array_remove() |
| |
868 */ |
| |
869 #define cx_array_remove_fast(array, index) \ |
| |
870 cx_array_remove_((CxArray*)&(array), sizeof((array).data[0]), index, 1, true) |
| |
871 |
| |
872 /** |
| |
873 * Removes multiple elements from the array. |
| |
874 * |
| |
875 * Tail elements are all moved to close the gap. If you don't need a stable |
| |
876 * order in the array, consider using cx_array_remove_array_fast(). |
| |
877 * |
| |
878 * If the index is out of bounds, this function does nothing. |
| |
879 * If @n overflows the array, this function removes as many elements as it can. |
| |
880 * |
| |
881 * @param array the name of the array |
| |
882 * @param index (@c size_t) the index of the first element to remove |
| |
883 * @param n (@c size_t) the number of elements to remove |
| |
884 * @see cx_array_remove_array_fast() |
| |
885 */ |
| |
886 #define cx_array_remove_array(array, index, n) \ |
| |
887 cx_array_remove_((CxArray*)&(array), sizeof((array).data[0]), index, n, false) |
| |
888 |
| |
889 /** |
| |
890 * Removes multiple elements from the array. |
| |
891 * |
| |
892 * Tail elements are copied into the gap. If you have more tail elements |
| |
893 * than the number of elements that are removed, this will change the order |
| |
894 * of elements. If you want a stable order, use cx_array_remove_array() instead. |
| |
895 * |
| |
896 * If the index is out of bounds, this function does nothing. |
| |
897 * If @n overflows the array, this function removes as many elements as it can. |
| |
898 * |
| |
899 * @param array the name of the array |
| |
900 * @param index (@c size_t) the index of the first element to remove |
| |
901 * @param n (@c size_t) the number of elements to remove |
| |
902 * @see cx_array_remove_array() |
| |
903 */ |
| |
904 #define cx_array_remove_array_fast(array, index, n) \ |
| |
905 cx_array_remove_((CxArray*)&(array), sizeof((array).data[0]), index, n, true) |
| 819 |
906 |
| 820 /** |
907 /** |
| 821 * Deallocates an array. |
908 * Deallocates an array. |
| 822 * |
909 * |
| 823 * Internal function - do not use. |
910 * Internal function - do not use. |