| 789 /** |
800 /** |
| 790 * Returns an iterator pointing to the first item of the list. |
801 * Returns an iterator pointing to the first item of the list. |
| 791 * |
802 * |
| 792 * The returned iterator is position-aware. |
803 * The returned iterator is position-aware. |
| 793 * |
804 * |
| 794 * If the list is empty, a past-the-end iterator will be returned. |
805 * If the list is empty or @c NULL, a past-the-end iterator will be returned. |
| 795 * |
806 * |
| 796 * @param list the list |
807 * @param list the list |
| 797 * @return a new iterator |
808 * @return a new iterator |
| 798 */ |
809 */ |
| 799 cx_attr_nonnull |
|
| 800 cx_attr_nodiscard |
810 cx_attr_nodiscard |
| 801 static inline CxIterator cxListIterator(const CxList *list) { |
811 static inline CxIterator cxListIterator(const CxList *list) { |
| |
812 if (list == NULL) list = cxEmptyList; |
| 802 return list->cl->iterator(list, 0, false); |
813 return list->cl->iterator(list, 0, false); |
| 803 } |
814 } |
| 804 |
815 |
| 805 /** |
816 /** |
| 806 * Returns a mutating iterator pointing to the first item of the list. |
817 * Returns a mutating iterator pointing to the first item of the list. |
| 807 * |
818 * |
| 808 * The returned iterator is position-aware. |
819 * The returned iterator is position-aware. |
| 809 * |
820 * |
| 810 * If the list is empty, a past-the-end iterator will be returned. |
821 * If the list is empty or @c NULL, a past-the-end iterator will be returned. |
| 811 * |
822 * |
| 812 * @param list the list |
823 * @param list the list |
| 813 * @return a new iterator |
824 * @return a new iterator |
| 814 */ |
825 */ |
| 815 cx_attr_nonnull |
|
| 816 cx_attr_nodiscard |
826 cx_attr_nodiscard |
| 817 static inline CxIterator cxListMutIterator(CxList *list) { |
827 static inline CxIterator cxListMutIterator(CxList *list) { |
| |
828 if (list == NULL) list = cxEmptyList; |
| 818 return cxListMutIteratorAt(list, 0); |
829 return cxListMutIteratorAt(list, 0); |
| 819 } |
830 } |
| 820 |
831 |
| 821 |
832 |
| 822 /** |
833 /** |
| 823 * Returns a backwards iterator pointing to the last item of the list. |
834 * Returns a backwards iterator pointing to the last item of the list. |
| 824 * |
835 * |
| 825 * The returned iterator is position-aware. |
836 * The returned iterator is position-aware. |
| 826 * |
837 * |
| 827 * If the list is empty, a past-the-end iterator will be returned. |
838 * If the list is empty or @c NULL, a past-the-end iterator will be returned. |
| 828 * |
839 * |
| 829 * @param list the list |
840 * @param list the list |
| 830 * @return a new iterator |
841 * @return a new iterator |
| 831 */ |
842 */ |
| 832 cx_attr_nonnull |
|
| 833 cx_attr_nodiscard |
843 cx_attr_nodiscard |
| 834 static inline CxIterator cxListBackwardsIterator(const CxList *list) { |
844 static inline CxIterator cxListBackwardsIterator(const CxList *list) { |
| |
845 if (list == NULL) list = cxEmptyList; |
| 835 return list->cl->iterator(list, list->collection.size - 1, true); |
846 return list->cl->iterator(list, list->collection.size - 1, true); |
| 836 } |
847 } |
| 837 |
848 |
| 838 /** |
849 /** |
| 839 * Returns a mutating backwards iterator pointing to the last item of the list. |
850 * Returns a mutating backwards iterator pointing to the last item of the list. |
| 840 * |
851 * |
| 841 * The returned iterator is position-aware. |
852 * The returned iterator is position-aware. |
| 842 * |
853 * |
| 843 * If the list is empty, a past-the-end iterator will be returned. |
854 * If the list is empty or @c NULL, a past-the-end iterator will be returned. |
| 844 * |
855 * |
| 845 * @param list the list |
856 * @param list the list |
| 846 * @return a new iterator |
857 * @return a new iterator |
| 847 */ |
858 */ |
| 848 cx_attr_nonnull |
|
| 849 cx_attr_nodiscard |
859 cx_attr_nodiscard |
| 850 static inline CxIterator cxListMutBackwardsIterator(CxList *list) { |
860 static inline CxIterator cxListMutBackwardsIterator(CxList *list) { |
| |
861 if (list == NULL) list = cxEmptyList; |
| 851 return cxListMutBackwardsIteratorAt(list, list->collection.size - 1); |
862 return cxListMutBackwardsIteratorAt(list, list->collection.size - 1); |
| 852 } |
863 } |
| 853 |
864 |
| 854 /** |
865 /** |
| 855 * Returns the index of the first element that equals @p elem. |
866 * Returns the index of the first element that equals @p elem. |