ucx/ucx.h

changeset 121
311cac04d079
parent 116
234920008754
child 127
5418bda21896
equal deleted inserted replaced
120:8170f658f017 121:311cac04d079
43 #define _Bool bool 43 #define _Bool bool
44 #define restrict 44 #define restrict
45 #endif 45 #endif
46 extern "C" { 46 extern "C" {
47 #endif 47 #endif
48
49 /**
50 * Generic loop statement for lists.
51 *
52 * The first argument is the type of the list and its elements (e.g. UcxList).
53 * The structure invariant of the list must be as follows:
54 * <ul>
55 * <li>a first (non-<code>NULL</code>) element</li>
56 * <li>for each element a reference to the <code>next</code> element (the
57 * variable name of the pointer MUST be <code>next</code>)</li>
58 * <li>the last element of the list MUST have the <code>next</code> pointer
59 * set to <code>NULL</code></li>
60 * </ul>
61 *
62 * The second argument is a pointer to the list. In most cases this will be the
63 * pointer to the first element of the list, but it may also be an arbitrary
64 * element of the list. The iteration will then start with that element.
65 *
66 * The third argument is the name of the iteration variable. The scope of
67 * this variable is limited to the <code>UCX_FOREACH</code> statement.
68 *
69 * @param type The type of <b>both</b> the list and the element
70 * @param list The first element of the list
71 * @param elem The variable name of the element
72 */
73 #define UCX_FOREACH(type,list,elem) \
74 for (type elem = list ; elem != NULL ; elem = elem->next)
75 48
76 /** 49 /**
77 * Function pointer to a compare function. 50 * Function pointer to a compare function.
78 * 51 *
79 * The compare function shall take three arguments: the two values that shall be 52 * The compare function shall take three arguments: the two values that shall be

mercurial