src/cx/iterator.h

changeset 551
2946e13c89a4
parent 516
7bcea73303ce
child 628
1e2be40f0cb5
--- a/src/cx/iterator.h	Thu May 19 14:30:20 2022 +0200
+++ b/src/cx/iterator.h	Sat May 21 11:22:47 2022 +0200
@@ -46,17 +46,20 @@
     /**
      * True iff the iterator points to valid data.
      */
-    bool (*valid)(struct cx_iterator_s const *) __attribute__ ((__nonnull__));
+    __attribute__ ((__nonnull__))
+    bool (*valid)(struct cx_iterator_s const *);
 
     /**
      * Returns a pointer to the current element.
      */
-    void *(*current)(struct cx_iterator_s const *) __attribute__ ((__nonnull__));
+    __attribute__ ((__nonnull__))
+    void *(*current)(struct cx_iterator_s const *);
 
     /**
      * Advances the iterator.
      */
-    void (*next)(struct cx_iterator_s *) __attribute__ ((__nonnull__));
+    __attribute__ ((__nonnull__))
+    void (*next)(struct cx_iterator_s *);
 
     /**
      * Handle for the current element, if required.
@@ -69,6 +72,27 @@
     void *src_handle;
 
     /**
+     * Field for storing a key-value pair.
+     * May be used by iterators that iterate over k/v-collections.
+     */
+    struct {
+        /**
+         * A pointer to the key.
+         */
+        void *key;
+        /**
+         * A pointer to the value.
+         */
+        void *value;
+    } kv_data;
+
+    /**
+     * Field for storing a slot number.
+     * May be used by iterators that iterate over multi-bucket collections.
+     */
+    size_t slot;
+
+    /**
      * If the iterator is position-aware, contains the index of the element in the underlying collection.
      * Otherwise, this field is usually uninitialized.
      */

mercurial