Detailed Description
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 <tt>data</tt> 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 !!
Macro Definition Documentation
#define xbt_dict_foreach |
( |
|
dict, |
|
|
|
cursor, |
|
|
|
key, |
|
|
|
data |
|
) |
| |
@param dict a \ref xbt_dict_t iterator
@param cursor an \ref xbt_dict_cursor_t used as cursor
@param key a char*
@param data a void** output
- Note
- An example of usage:
char *key;
char *data;
printf("Key %s with data %s\n",key,data);
}
Function Documentation
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