Cursors are used to iterate over the structure.
More...
Cursors are used to iterate over the structure.
Never add elements to the DynArr during the traversal. To remove elements, use the xbt_dynar_cursor_rm() function.
Do not call these function directly, but only within the xbt_dynar_foreach macro.
#define xbt_dynar_foreach |
( |
|
_dynar, |
|
|
|
_cursor, |
|
|
|
_data |
|
) |
| |
Iterates over the whole dynar.
- Parameters
-
_dynar | what to iterate over |
_cursor | an integer used as cursor |
_data | |
Here is an example of usage:
4 xbt_dynar_foreach (dyn,cpt,str) {
5 printf("Seen %s\n",str);
Note that underneath, that's a simple for loop with no real black magic involved. It's perfectly safe to interrupt a foreach with a break or a return statement.
#define xbt_dynar_foreach_ptr |
( |
|
_dynar, |
|
|
|
_cursor, |
|
|
|
_ptr |
|
) |
| |
Value:for ((_cursor) = 0 ; \
(_cursor)++ )
void * xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx)
Retrieve a pointer to the Nth element of a dynar.
Definition: dynar.c:237
Removes and free the entry pointed by the cursor.
This function can be used while traversing without problem.
static int _xbt_dynar_cursor_get |
( |
const xbt_dynar_t |
dynar, |
|
|
unsigned int |
idx, |
|
|
void *const |
dst |
|
) |
| |
|
inlinestatic |