+/* Convenience macros for iteration.
+
+ These macros automatically use BT_DATA to obtain the data elements that
+ encapsulate bt nodes, which often saves typing and can make code easier to
+ read. Refer to the large comment near the top of this file for an example.
+
+ These macros evaluate their arguments many times. */
+#define BT_FIRST(STRUCT, MEMBER, BT) \
+ BT_NULLABLE_DATA (bt_first (BT), STRUCT, MEMBER)
+#define BT_NEXT(DATA, STRUCT, MEMBER, BT) \
+ BT_NULLABLE_DATA (bt_next (BT, &(DATA)->MEMBER), STRUCT, MEMBER)
+#define BT_FOR_EACH(DATA, STRUCT, MEMBER, BT) \
+ for ((DATA) = BT_FIRST (STRUCT, MEMBER, BT); \
+ (DATA) != NULL; \
+ (DATA) = BT_NEXT (DATA, STRUCT, MEMBER, BT))
+#define BT_FOR_EACH_SAFE(DATA, NEXT, STRUCT, MEMBER, BT) \
+ for ((DATA) = BT_FIRST (STRUCT, MEMBER, BT); \
+ ((DATA) != NULL \
+ ? ((NEXT) = BT_NEXT (DATA, STRUCT, MEMBER, BT), 1) \
+ : 0); \
+ (DATA) = (NEXT))
+