SimGrid 3.7.1
Scalable simulation of distributed systems
|
Defines | |
#define | xbt_dict_foreach(dict, cursor, key, data) |
Typedefs | |
typedef struct s_xbt_dict_cursor * | xbt_dict_cursor_t |
Cursor on dictionaries (opaque type) | |
Functions | |
xbt_dict_cursor_t | xbt_dict_cursor_new (const xbt_dict_t dict) |
Creator. | |
void | xbt_dict_cursor_free (xbt_dict_cursor_t *cursor) |
Destructor. | |
void | xbt_dict_cursor_rewind (xbt_dict_cursor_t cursor) |
Reinitialize the cursor. Mandatory after removal or add in dict. | |
char * | xbt_dict_cursor_get_key (xbt_dict_cursor_t cursor) |
Get current key. | |
void * | xbt_dict_cursor_get_data (xbt_dict_cursor_t cursor) |
Get current data. | |
void | xbt_dict_cursor_set_data (xbt_dict_cursor_t cursor, void *data, void_f_pvoid_t free_ctn) |
Set current data. | |
void | xbt_dict_cursor_first (const xbt_dict_t dict, xbt_dict_cursor_t *cursor) |
Create the cursor if it does not exists. Rewind it in any case. | |
void | xbt_dict_cursor_step (xbt_dict_cursor_t cursor) |
Move to the next element. | |
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. |
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); }
#define xbt_dict_foreach | ( | dict, | |
cursor, | |||
key, | |||
data | |||
) |
dict | a xbt_dict_t iterator |
cursor | an xbt_dict_cursor_t used as cursor |
key | a char* |
data | a void** output |
xbt_dict_cursor_t cursor = NULL; char *key; char *data; xbt_dict_foreach(head, cursor, key, data) { printf("Key %s with data %s\n",key,data); }
xbt_dict_cursor_t xbt_dict_cursor_new | ( | const xbt_dict_t | dict | ) |
Creator.
dict | the dict |
void xbt_dict_cursor_free | ( | xbt_dict_cursor_t * | cursor | ) |
Destructor.
cursor | poor victim |
char* xbt_dict_cursor_get_key | ( | xbt_dict_cursor_t | cursor | ) |
Get current key.
cursor,: | the cursor |
void* xbt_dict_cursor_get_data | ( | xbt_dict_cursor_t | cursor | ) |
Get current data.
cursor | the cursor |
void xbt_dict_cursor_set_data | ( | xbt_dict_cursor_t | cursor, |
void * | data, | ||
void_f_pvoid_t | free_ctn | ||
) |
Set current data.
cursor | the cursor |
data | the new data |
free_ctn | the function to free the new data |
void xbt_dict_cursor_first | ( | const xbt_dict_t | dict, |
xbt_dict_cursor_t * | cursor | ||
) |
Create the cursor if it does not exists. Rewind it in any case.
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.
Back to the main Simgrid Documentation page |
The version of SimGrid documented here is v3.7.1. Documentation of other versions can be found in their respective archive files (directory doc/html). |
Generated by ![]() |