aboutsummaryrefslogtreecommitdiff
path: root/linked_list.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-02-15 18:09:00 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-15 20:03:45 +0100
commit05b5d8547f5f98ca4b907bf6a21564e2384740a6 (patch)
treed1a5c0a856f938721b92076e328ef22647fcaddb /linked_list.h
parentAdd toggle for node data output. (diff)
downloadcalp-05b5d8547f5f98ca4b907bf6a21564e2384740a6.tar.gz
calp-05b5d8547f5f98ca4b907bf6a21564e2384740a6.tar.xz
Improve FOR macro.
Diffstat (limited to 'linked_list.h')
-rw-r--r--linked_list.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/linked_list.h b/linked_list.h
index 8c09d5e0..909a38a8 100644
--- a/linked_list.h
+++ b/linked_list.h
@@ -69,14 +69,20 @@ FMT_F(LLIST(TYPE));
/* Iterator */
+#define __PRE_LLIST(T, l, set) \
+ T* l; LINK(T)* __INTER(l);
+
+#define PRE_FOR_LLIST(T) __PRE_LLIST
+
// #define __BEG_LLIST(v, set) v = (set)->head
-#define __BEG_LLIST(l, set) l = FIRST(set)
-#define BEG_LLIST(T) LINK(T)* __BEG_LLIST
+#define __BEG_LLIST(T, l, set) __INTER(l) = FIRST(set), l = L(__INTER(l))
+#define BEG_LLIST(T) __BEG_LLIST
-#define __END_LLIST(l, set) l != (set)->tail
+#define __END_LLIST(T, l, set) __INTER(l) != (set)->tail
#define END_LLIST(T) __END_LLIST
-#define __NXT_LLIST(l, set) l = l->after
+#define __NXT_LLIST(T, l, set) __INTER(l) = __INTER(l)->after, l = L(__INTER(l))
+// #define __NXT_LLIST(T, l, set) l = L(__INTER(l) = __INTER(l)->after)
#define NXT_LLIST(T) __NXT_LLIST
#endif /* TYPE */