src/cx/list.h

changeset 1343
b2ba79f4cb62
parent 1341
dc88d2ece7e4
child 1346
2d24f7bae4c9
equal deleted inserted replaced
1342:fe3ac6b1cf57 1343:b2ba79f4cb62
870 /** 870 /**
871 * Returns an iterator pointing to the item at the specified index. 871 * Returns an iterator pointing to the item at the specified index.
872 * 872 *
873 * The returned iterator is position-aware. 873 * The returned iterator is position-aware.
874 * 874 *
875 * If the index is out of range, a past-the-end iterator will be returned. 875 * If the index is out of range or @p list is @c NULL, a past-the-end iterator will be returned.
876 * 876 *
877 * @param list the list 877 * @param list the list
878 * @param index the index where the iterator shall point at 878 * @param index the index where the iterator shall point at
879 * @return a new iterator 879 * @return a new iterator
880 */ 880 */
881 cx_attr_nonnull
882 cx_attr_nodiscard 881 cx_attr_nodiscard
883 static inline CxIterator cxListIteratorAt( 882 static inline CxIterator cxListIteratorAt(
884 const CxList *list, 883 const CxList *list,
885 size_t index 884 size_t index
886 ) { 885 ) {
886 if (list == NULL) list = cxEmptyList;
887 return list->cl->iterator(list, index, false); 887 return list->cl->iterator(list, index, false);
888 } 888 }
889 889
890 /** 890 /**
891 * Returns a backwards iterator pointing to the item at the specified index. 891 * Returns a backwards iterator pointing to the item at the specified index.
892 * 892 *
893 * The returned iterator is position-aware. 893 * The returned iterator is position-aware.
894 * 894 *
895 * If the index is out of range, a past-the-end iterator will be returned. 895 * If the index is out of range or @p list is @c NULL, a past-the-end iterator will be returned.
896 * 896 *
897 * @param list the list 897 * @param list the list
898 * @param index the index where the iterator shall point at 898 * @param index the index where the iterator shall point at
899 * @return a new iterator 899 * @return a new iterator
900 */ 900 */
901 cx_attr_nonnull
902 cx_attr_nodiscard 901 cx_attr_nodiscard
903 static inline CxIterator cxListBackwardsIteratorAt( 902 static inline CxIterator cxListBackwardsIteratorAt(
904 const CxList *list, 903 const CxList *list,
905 size_t index 904 size_t index
906 ) { 905 ) {
906 if (list == NULL) list = cxEmptyList;
907 return list->cl->iterator(list, index, true); 907 return list->cl->iterator(list, index, true);
908 } 908 }
909 909
910 /** 910 /**
911 * Returns a mutating iterator pointing to the item at the specified index. 911 * Returns a mutating iterator pointing to the item at the specified index.

mercurial