Don't get impressed, there is a lot of functions here, but traversing a dictionary is immediate with the
xbt_dict_foreach macro.
You only need the other functions in rare cases (they are not used directly in SG itself).
Here is an example (assuming that the dictionary contains strings, i.e., that the data
argument of xbt_dict_set was always a null-terminated char*):
xbt_dict_cursor_t cursor=NULL;
char *key,*data;
xbt_dict_foreach(dict,cursor,key,data) {
printf(" - Seen: %s->%s\n",key,data);
}
@warning Do not add or remove entries to the cache while traversing !!
◆ xbt_dict_foreach
#define xbt_dict_foreach |
( |
|
dict, |
|
|
|
cursor, |
|
|
|
key, |
|
|
|
data |
|
) |
| |
- Parameters
-
- Note
- An example of usage:
char *key;
char *data;
printf("Key %s with data %s\n",key,data);
}
◆ xbt_dict_cursor_t
Cursor on dictionaries (opaque type)
◆ xbt_dict_cursor_get_elm()
◆ xbt_dict_cursor_new()
◆ xbt_dict_cursor_free()
◆ xbt_dict_cursor_rewind()
◆ xbt_dict_cursor_get_key()
◆ xbt_dict_cursor_get_data()
◆ xbt_dict_cursor_first()
◆ xbt_dict_cursor_step()
◆ xbt_dict_cursor_get_or_free()
int xbt_dict_cursor_get_or_free |
( |
xbt_dict_cursor_t * |
cursor, |
|
|
char ** |
key, |
|
|
void ** |
data |
|
) |
| |