|
typedef struct s_xbt_dict_cursor * | xbt_dict_cursor_t |
| Cursor on dictionaries (opaque type)
|
|
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, ie 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 !!
#define xbt_dict_foreach |
( |
|
dict, |
|
|
|
cursor, |
|
|
|
key, |
|
|
|
data |
|
) |
| |
- Parameters
-
- Note
- An example of usage:
1 xbt_dict_cursor_t cursor = NULL;
5 xbt_dict_foreach(head, cursor, key, data) {
6 printf("Key %s with data %s\n",key,data);
Get current key.
- Parameters
-
- Returns
- the current key
Get current data.
- Parameters
-
- Returns
- the current data
void xbt_dict_cursor_set_data |
( |
xbt_dict_cursor_t |
cursor, |
|
|
void * |
data, |
|
|
void_f_pvoid_t |
free_ctn |
|
) |
| |
Set current data.
- Parameters
-
cursor | the cursor |
data | the new data |
free_ctn | the function to free the new data |
Create the cursor if it does not exists. Rewind it in any case.
- Parameters
-
| dict | on what to let the cursor iterate |
[out] | cursor | dest address |
int xbt_dict_cursor_get_or_free |
( |
xbt_dict_cursor_t * |
cursor, |
|
|
char ** |
key, |
|
|
void ** |
data |
|
) |
| |
Get current data, or free the cursor if there is no data left.
- Returns
- true if it's ok, false if there is no more data