src/cx/iterator.h

changeset 551
2946e13c89a4
parent 516
7bcea73303ce
child 628
1e2be40f0cb5
     1.1 --- a/src/cx/iterator.h	Thu May 19 14:30:20 2022 +0200
     1.2 +++ b/src/cx/iterator.h	Sat May 21 11:22:47 2022 +0200
     1.3 @@ -46,17 +46,20 @@
     1.4      /**
     1.5       * True iff the iterator points to valid data.
     1.6       */
     1.7 -    bool (*valid)(struct cx_iterator_s const *) __attribute__ ((__nonnull__));
     1.8 +    __attribute__ ((__nonnull__))
     1.9 +    bool (*valid)(struct cx_iterator_s const *);
    1.10  
    1.11      /**
    1.12       * Returns a pointer to the current element.
    1.13       */
    1.14 -    void *(*current)(struct cx_iterator_s const *) __attribute__ ((__nonnull__));
    1.15 +    __attribute__ ((__nonnull__))
    1.16 +    void *(*current)(struct cx_iterator_s const *);
    1.17  
    1.18      /**
    1.19       * Advances the iterator.
    1.20       */
    1.21 -    void (*next)(struct cx_iterator_s *) __attribute__ ((__nonnull__));
    1.22 +    __attribute__ ((__nonnull__))
    1.23 +    void (*next)(struct cx_iterator_s *);
    1.24  
    1.25      /**
    1.26       * Handle for the current element, if required.
    1.27 @@ -69,6 +72,27 @@
    1.28      void *src_handle;
    1.29  
    1.30      /**
    1.31 +     * Field for storing a key-value pair.
    1.32 +     * May be used by iterators that iterate over k/v-collections.
    1.33 +     */
    1.34 +    struct {
    1.35 +        /**
    1.36 +         * A pointer to the key.
    1.37 +         */
    1.38 +        void *key;
    1.39 +        /**
    1.40 +         * A pointer to the value.
    1.41 +         */
    1.42 +        void *value;
    1.43 +    } kv_data;
    1.44 +
    1.45 +    /**
    1.46 +     * Field for storing a slot number.
    1.47 +     * May be used by iterators that iterate over multi-bucket collections.
    1.48 +     */
    1.49 +    size_t slot;
    1.50 +
    1.51 +    /**
    1.52       * If the iterator is position-aware, contains the index of the element in the underlying collection.
    1.53       * Otherwise, this field is usually uninitialized.
    1.54       */

mercurial