21 #ifndef THUNDEREGG_LOOP_H
22 #define THUNDEREGG_LOOP_H
38 template<
int start,
int stop,
typename T>
42 static void inline loop_loop(T lambda)
45 ULoop<start + 1, stop, T>::loop_loop(lambda);
49 template<
int start,
typename T>
50 class ULoop<start, start, T>
53 static void inline loop_loop(T lambda) { lambda(start); }
59 static void inline loop_loop(T lambda) {}
71 template<
int start,
int stop,
typename T>
74 ULoop<start, stop, T>::loop_loop(lambda);
83 template<
int D,
int Dir,
typename T,
typename A>
87 static void inline nested_loop_loop(A coord, A start, A end, T lambda)
89 for (coord[Dir] = start[Dir]; coord[Dir] <= end[Dir]; coord[Dir]++) {
90 NestedLoop<D, Dir - 1, T, A>::nested_loop_loop(coord, start, end, lambda);
95 template<
int D,
typename T,
typename A>
96 class NestedLoop<D, 0, T, A>
99 static void inline nested_loop_loop(A coord, A start, A end, T lambda)
101 for (coord[0] = start[0]; coord[0] <= end[0]; coord[0]++) {
106 template<
typename T,
typename A>
107 class NestedLoop<0, -1, T, A>
110 static void inline nested_loop_loop(A coord, A, A, T lambda) { lambda(coord); }
124 template<
int D,
typename T,
typename A>
125 static inline void Nested(A start, A end, T lambda)
128 NestedLoop<D, D - 1, T, A>::nested_loop_loop(coord, start, end, lambda);
139 template<
int D,
typename V,
typename T>
142 Nested<D>(view.getStart(), view.getEnd(), lambda);
153 template<
int D,
typename V,
typename T>
156 Nested<D>(view.getGhostStart(), view.getGhostEnd(), lambda);