SimGrid  3.18
Versatile Simulation of Distributed Systems

Detailed Description

Careful, those functions assume that the key is null-terminated.

Functions

void xbt_dict_set (xbt_dict_t dict, const char *key, void *data, void_f_pvoid_t free_ctn)
 Add data to the dict (null-terminated key) More...
 
voidxbt_dict_get (xbt_dict_t dict, const char *key)
 Retrieve data from the dict (null-terminated key) More...
 
voidxbt_dict_get_or_null (xbt_dict_t dict, const char *key)
 like xbt_dict_get(), but returning nullptr when not found More...
 
char * xbt_dict_get_key (xbt_dict_t dict, const void *data)
 retrieve the key associated to that object. More...
 
 XBT_ATTRIB_DEPRECATED_v321 ("xbt_dict is dying. v3.21 will turn this warning into an error.") extern char *xbt_dict_get_elm_key(xbt_dictelm_t elem)
 
xbt_dictelm_t xbt_dict_get_elm (xbt_dict_t dict, const char *key)
 Retrieve element from the dict (null-terminated key) More...
 
xbt_dictelm_t xbt_dict_get_elm_or_null (xbt_dict_t dict, const char *key)
 like xbt_dict_get_elm(), but returning nullptr when not found More...
 
void xbt_dict_remove (xbt_dict_t dict, const char *key)
 Remove data from the dict (null-terminated key) More...
 
void xbt_dict_reset (xbt_dict_t dict)
 Remove all data from the dict. More...
 
int xbt_dict_length (xbt_dict_t dict)
 Return the number of elements in the dict. More...
 
void xbt_dict_dump (xbt_dict_t dict, void(*output)(void *))
 Outputs the content of the structure (debugging purpose) More...
 
int xbt_dict_is_empty (xbt_dict_t dict)
 test if the dict is empty or not More...
 

Function Documentation

◆ xbt_dict_set()

void xbt_dict_set ( xbt_dict_t  dict,
const char *  key,
void data,
void_f_pvoid_t  free_ctn 
)

Add data to the dict (null-terminated key)

Parameters
dictthe dict
keythe key to set the new data
datathe data to add in the dict
free_ctnfunction to call with (data as argument) when data is removed from the dictionary. This param will only be considered when the dict was instantiated with xbt_dict_new() and not xbt_dict_new_homogeneous()

set the data in the structure under the key, which is anull terminated string.

◆ xbt_dict_get()

void* xbt_dict_get ( xbt_dict_t  dict,
const char *  key 
)

Retrieve data from the dict (null-terminated key)

Parameters
dictthe dealer of data
keythe key to find data
Returns
the data that we are looking for

Search the given key. Throws not_found_error when not found. Check xbt_dict_get_or_null() for a version returning nullptr without exception when not found.

◆ xbt_dict_get_or_null()

void* xbt_dict_get_or_null ( xbt_dict_t  dict,
const char *  key 
)

like xbt_dict_get(), but returning nullptr when not found

◆ xbt_dict_get_key()

char* xbt_dict_get_key ( xbt_dict_t  dict,
const void data 
)

retrieve the key associated to that object.

Warning, that's a linear search

Returns nullptr if the object cannot be found

◆ XBT_ATTRIB_DEPRECATED_v321()

XBT_ATTRIB_DEPRECATED_v321 ( "xbt_dict is dying. v3.21 will turn this warning into an error."  )

◆ xbt_dict_get_elm()

xbt_dictelm_t xbt_dict_get_elm ( xbt_dict_t  dict,
const char *  key 
)

Retrieve element from the dict (null-terminated key)

Parameters
dictthe dealer of data
keythe key to find data
Returns
the s_xbt_dictelm_t that we are looking for

Search the given key. Throws not_found_error when not found. Check xbt_dict_get_or_null() for a version returning nullptr without exception when not found.

◆ xbt_dict_get_elm_or_null()

xbt_dictelm_t xbt_dict_get_elm_or_null ( xbt_dict_t  dict,
const char *  key 
)

like xbt_dict_get_elm(), but returning nullptr when not found

◆ xbt_dict_remove()

void xbt_dict_remove ( xbt_dict_t  dict,
const char *  key 
)

Remove data from the dict (null-terminated key)

Parameters
dictthe dict
keythe key of the data to be removed

Remove the entry associated with the given key

◆ xbt_dict_reset()

void xbt_dict_reset ( xbt_dict_t  dict)

Remove all data from the dict.

◆ xbt_dict_length()

int xbt_dict_length ( xbt_dict_t  dict)

Return the number of elements in the dict.

Parameters
dicta dictionary

◆ xbt_dict_dump()

void xbt_dict_dump ( xbt_dict_t  dict,
void_f_pvoid_t  output 
)

Outputs the content of the structure (debugging purpose)

Parameters
dictthe exibitionist
outputa function to dump each data in the tree (check xbt_dict_dump_output_string)

Outputs the content of the structure. (for debugging purpose). output is a function to output the data. If nullptr, data won't be displayed.

◆ xbt_dict_is_empty()

int xbt_dict_is_empty ( xbt_dict_t  dict)

test if the dict is empty or not