]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/iter.qh
Merge branch 'master' into TimePath/deathtypes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / iter.qh
1 #ifndef ITER_H
2 #define ITER_H
3
4 #define FOREACH_ARRAY(arr, start, end, cond, body) do { \
5     for (int i = start; i < end; ++i) {                 \
6         const noref entity it = arr[i];                 \
7         if (cond) { body }                              \
8     }                                                   \
9 } while(0)
10
11 #define FOREACH_LIST(list, next, cond, body) do {               \
12     noref int i = 0;                                            \
13     for (entity it = list##_first; it; (it = it.next, ++i)) {   \
14         if (cond) { body }                                      \
15     }                                                           \
16 } while(0)
17
18 #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)
19
20 #endif