diff -r 3dc9075df822 -r eb9e7bd40a8e src/cx/iterator.h --- a/src/cx/iterator.h Sat Jan 29 14:32:04 2022 +0100 +++ b/src/cx/iterator.h Sun Jan 30 14:19:00 2022 +0100 @@ -40,36 +40,23 @@ #include "common.h" /** - * Iterator value type. - * An iterator points to a certain element in an (possibly unbounded) chain of elements. - * Iterators that are based on collections (which have a defined "first" element), are supposed - * to be "position-aware", which means that they keep track of the current index within the collection. - * - * @note Objects that are pointed to by an iterator are mutable through that iterator. However, if the - * iterator is based on a collection and the underlying collection is mutated (elements added or removed), - * the iterator becomes invalid (regardless of what cxIteratorValid() returns) and MUST be re-obtained - * from the collection. - */ -typedef struct cx_iterator_s CxIterator; - -/** * Internal iterator struct - use CxIterator. */ struct cx_iterator_s { /** * True iff the iterator points to valid data. */ - bool (*valid)(CxIterator const *) __attribute__ ((__nonnull__)); + bool (*valid)(struct cx_iterator_s const *) __attribute__ ((__nonnull__)); /** * Returns a pointer to the current element. */ - void *(*current)(CxIterator const *) __attribute__ ((__nonnull__)); + void *(*current)(struct cx_iterator_s const *) __attribute__ ((__nonnull__)); /** * Advances the iterator. */ - void (*next)(CxIterator *) __attribute__ ((__nonnull__)); + void (*next)(struct cx_iterator_s *) __attribute__ ((__nonnull__)); /** * Handle for the current element, if required. @@ -96,6 +83,19 @@ }; /** + * Iterator value type. + * An iterator points to a certain element in an (possibly unbounded) chain of elements. + * Iterators that are based on collections (which have a defined "first" element), are supposed + * to be "position-aware", which means that they keep track of the current index within the collection. + * + * @note Objects that are pointed to by an iterator are mutable through that iterator. However, if the + * iterator is based on a collection and the underlying collection is mutated (elements added or removed), + * the iterator becomes invalid (regardless of what cxIteratorValid() returns) and MUST be re-obtained + * from the collection. + */ +typedef struct cx_iterator_s CxIterator; + +/** * Checks if the iterator points to valid data. * * This is especially false for past-the-end iterators.