src/cx/iterator.h

changeset 500
eb9e7bd40a8e
parent 497
b182a8b8a1af
child 516
7bcea73303ce
     1.1 --- a/src/cx/iterator.h	Sat Jan 29 14:32:04 2022 +0100
     1.2 +++ b/src/cx/iterator.h	Sun Jan 30 14:19:00 2022 +0100
     1.3 @@ -40,36 +40,23 @@
     1.4  #include "common.h"
     1.5  
     1.6  /**
     1.7 - * Iterator value type.
     1.8 - * An iterator points to a certain element in an (possibly unbounded) chain of elements.
     1.9 - * Iterators that are based on collections (which have a defined "first" element), are supposed
    1.10 - * to be "position-aware", which means that they keep track of the current index within the collection.
    1.11 - *
    1.12 - * @note Objects that are pointed to by an iterator are mutable through that iterator. However, if the
    1.13 - * iterator is based on a collection and the underlying collection is mutated (elements added or removed),
    1.14 - * the iterator becomes invalid (regardless of what cxIteratorValid() returns) and MUST be re-obtained
    1.15 - * from the collection.
    1.16 - */
    1.17 -typedef struct cx_iterator_s CxIterator;
    1.18 -
    1.19 -/**
    1.20   * Internal iterator struct - use CxIterator.
    1.21   */
    1.22  struct cx_iterator_s {
    1.23      /**
    1.24       * True iff the iterator points to valid data.
    1.25       */
    1.26 -    bool (*valid)(CxIterator const *) __attribute__ ((__nonnull__));
    1.27 +    bool (*valid)(struct cx_iterator_s const *) __attribute__ ((__nonnull__));
    1.28  
    1.29      /**
    1.30       * Returns a pointer to the current element.
    1.31       */
    1.32 -    void *(*current)(CxIterator const *) __attribute__ ((__nonnull__));
    1.33 +    void *(*current)(struct cx_iterator_s const *) __attribute__ ((__nonnull__));
    1.34  
    1.35      /**
    1.36       * Advances the iterator.
    1.37       */
    1.38 -    void (*next)(CxIterator *) __attribute__ ((__nonnull__));
    1.39 +    void (*next)(struct cx_iterator_s *) __attribute__ ((__nonnull__));
    1.40  
    1.41      /**
    1.42       * Handle for the current element, if required.
    1.43 @@ -96,6 +83,19 @@
    1.44  };
    1.45  
    1.46  /**
    1.47 + * Iterator value type.
    1.48 + * An iterator points to a certain element in an (possibly unbounded) chain of elements.
    1.49 + * Iterators that are based on collections (which have a defined "first" element), are supposed
    1.50 + * to be "position-aware", which means that they keep track of the current index within the collection.
    1.51 + *
    1.52 + * @note Objects that are pointed to by an iterator are mutable through that iterator. However, if the
    1.53 + * iterator is based on a collection and the underlying collection is mutated (elements added or removed),
    1.54 + * the iterator becomes invalid (regardless of what cxIteratorValid() returns) and MUST be re-obtained
    1.55 + * from the collection.
    1.56 + */
    1.57 +typedef struct cx_iterator_s CxIterator;
    1.58 +
    1.59 +/**
    1.60   * Checks if the iterator points to valid data.
    1.61   *
    1.62   * This is especially false for past-the-end iterators.

mercurial